Re: Pro*C --- How to pass a value into a host variable !!
From: William Nunn <nunnw_at_bcstec.ca.boeing.com>
Date: Thu, 23 Mar 1995 15:35:28 GMT
Message-ID: <D5wGn5.9Mn_at_bcstec.ca.boeing.com>
Date: Thu, 23 Mar 1995 15:35:28 GMT
Message-ID: <D5wGn5.9Mn_at_bcstec.ca.boeing.com>
Yih-feng Hwang (CS 688) (yhwang) wrote:
: Hi there,
: I have a problem about how to pass a value (string) into a host variable
: ( :name_of_table and :name_of_attribute) in a SQL (listed below)
: EXEC SQL SELECT *
: FROM :name_of_table
: WHERE :name_of_attribute;
: Any suggestions/comments will be very useful for myself !!
: Thanks in advanced,
: yhwang_at_fusion.site.gmu.edu
EXEC SQL BEGIN DECLARE SECTION;
char select_stmt[120];
EXEC SQL END DECLARE SECTION;
memmove(select_stmt,"SELECT * FROM "); strncat(select_stmt,table_name); strncat(select_stmt," WHERE "); strncat(select_stmt,col1_name); strncat(select_stmt," = "); strncat(select_stmt,col2_name);
EXEC SQL PREPARE sql_stmt FROM :select_stmt; EXEC SQL EXECUTE sql_stmt;
See page 9-10 of your Programmer's Guide to the Precompilers.
Hope this helps,
William Nunn
Received on Thu Mar 23 1995 - 16:35:28 CET