Results 1 to 2 of 2

Thread: C and ORACLE

  1. #1
    Join Date
    Jul 2004
    Posts
    5

    Unanswered: C and ORACLE

    I would like to pass a table name through a parameter.
    The following statement isn't working (tableName is declared as a char*):
    EXEC SQL DECLARE cur CURSOR FOR SELECT * FROM :tableName;

    Any Ideas?

    THANKS

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    I don't really "do" Pro*C, but I happened to be looking at some Pro*C with dynamic SQL the other day. It looked rather like this:
    Code:
    EXEC SQL BEGIN DECLARE SECTION;
       static VARCHAR h_select [1000];
    EXEC SQL END DECLARE SECTION;
    
       strcpy(h_select.arr,"SELECT * FROM ");
       strcat(h_select.arr,table_name);
    
       EXEC SQL PREPARE prep_csr FROM :h_select;
       EXEC SQL DECLARE csr CURSOR FOR prep_csr;
       EXEC SQL OPEN csr;
    I can't guarantee I got that syntax quite right

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •