Re: Table substitution with PRO*C Dynamic SQL

From: Dave Mausner <dlm_at_dlogics.dlogics.com>
Date: Tue, 08 Jun 1993 18:13:25
Message-ID: <930608181325_at_dlpc030.dlogics.com>


joefw_at_eosdev1.gsfc.nasa.gov (Joe Fulson-Woytek) writes:

> main()
> {
> sqlstmt.len = sprintf
> ( sqlstmt.arr, "SELECT USERNAME FROM :v1 WHERE PERSON_ID = 430");
> EXEC SQL PREPARE S FROM :sqlstmt;
> :
> I get the error: ORA-00903: invalid table name
> which seems to indicate the substitution is not working.

Good guess :) ! You can NOT substitute a bind variable for a table name. However, you are creating a dynamic SQL string, so why not let the C runtimes do the job for you:

        x.len = sprintf(x.arr, "select y from %s where z=430", tablename);

--
Dave Mausner / Sr Consultant / Datalogics division of Frame Technology Inc
441 W Huron / Chicago IL 60610 / +1-312-266-4450 / "Just show me the code" 
Received on Tue Jun 08 1993 - 18:13:25 CEST

Original text of this message