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 -> Re: column name passed as a variable

Re: column name passed as a variable

From: Ron Reidy <rereidy_at_indra.com>
Date: Wed, 19 Feb 2003 13:58:29 -0700
Message-ID: <3E53EFF5.9080505@indra.com>


Look at Dynamic methods 3 & 4 in the Pro*C docs.

--
Ron Reidy
Oracle DBA

Sandy wrote:

> 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:58:29 CST

Original text of this message

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