Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> column name passed as a variable

column name passed as a variable

From: Sandy <sandra.maccaferri_at_go.ecitele.com>
Date: 19 Feb 2003 12:49:21 -0800
Message-ID: <549adcaa.0302191249.64c1684a@posting.google.com>


I am new to Oracle application programming. We are using Oracle Pro C/C++ and and Oracle 7 database. I am trying to pass a column name into a SQL EXEC statement. If I explicitly name the column, the query returns the expected results. However, if I try to pass variable, the returned value is the column name. Can someone tell me what I am doing wrong?

Thanks,

EXEC SQL 	BEGIN DECLARE SECTION;
    char     		in_FieldName[40];
    char     		in_SubsystemId[15];
    char     		fieldValue[5];
    static short   	nullind;
   EXEC SQL       END DECLARE SECTION;



   strcpy(fieldValue,'\0');

   strcpy(in_FieldName,FieldName);
   strcpy(in_SubsystemId,'\0');
   sprintf(in_SubsystemId,"%.0f",SubsystemId);  

   EXEC SQL

            SELECT      :in_FieldName
            INTO        :fieldValue :nullind
            FROM        LND
            WHERE       LND.SubsystemId = :in_SubsystemId;
Received on Wed Feb 19 2003 - 14:49:21 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US