DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: help in dynamic query in Pro*C

Threaded View

  1. #2
    Join Date
    Jan 2001
    Posts
    2,828
    Hi

    EXEC SQL SELECT * FROM :tablename WHERE :attribute_name=:value;

    You cannot do that in any language be it pl/sql ,pro *C VB etc.

    The table name and the atribute name has to be known before hand

    what you need to do is first prepare the sql statment in your case
    SELECT * FROM :tablename WHERE :attribute_name=:value;
    as a string

    something like
    Code:
    char *sql = "select * from "    ;
    char *tabname=" tablename ";  /* can be a param that is passed */
    char *predicate=" where  "     ;
    char *column_name ="attribute_name";
    
    /*now you need to concat the strings */
    strcat(sql,tabname);
    strcat(sql,predicate);
    strcat(sql,column_name);
    
    now having constructed the string you need to prepare it and execute it
    EXEC SQL EXECUTE IMMEDIATE :sql using :value
    regards
    Hrishy
    Last edited by hrishy; 10-09-2005 at 11:29 AM.

Posting Permissions

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


Click Here to Expand Forum to Full Width