Re: How to select column name in Pro C at run-time

From: Tim Smith <tssmith_at_netcom.com>
Date: 17 Mar 93 18:57:12 GMT
Message-ID: <1993Mar17.185712.9375_at_netcom.com>


In article <1993Mar16.204157.1790_at_umr.edu> jybarnes_at_cs.umr.edu (Jym Barnes) writes:
> I have a need to do something I have never done before in
> Pro C. I want to specify at runtime what column name I
> want to use in a SELECT statement. Usually the column names
> in a Pro C statement are hard-coded well I want to make the
> the column name selectable at runtime. Is it possible? If
> it is possible if someone could send me an example I would
> appreciate it. Please send replies to jybarnes_at_next5.cs.umr.edu.

You will have to use dynamic SQL. See Chapter 9 in the _Programmer's Guide to the ORACLE Precompilers_, and sample program #8 in the _Pro*C Supplement to the ORACLE Precompilers Guide_, Chapter 4 (it's Chapter 2 or 3 in earlier editions of the supplement).

You can cut the column name(s) into the SQL statement using strcpy and strcat, or you can get the whole statement at runtime from the user, whichever is best for your app.

--Tim (tssmith_at_oracle.com) Received on Wed Mar 17 1993 - 19:57:12 CET

Original text of this message