Re: Q:Pro*C host vars

From: Tim Smith <tssmith_at_netcom.com>
Date: Thu, 19 Aug 1993 03:30:38 GMT
Message-ID: <tssmithCBzLr3.9Mw_at_netcom.com>


In article <20177_at_pitt.UUCP> jdp_at_pittslug.sug.org (Jeffrey Pickett) writes:
>
>I have a question. I would like to concatenate an owner to the front of
>a table name, but I can't seem to find the answer. All I am trying to
>do is a simple embedded sql query like so:
>
>SELECT ITEM_ID into :item_id FROM OWNER.SOMETABLE
>WHERE ITEM_NBR = :number;
>
>My problem is my 'OWNER' is variable. I tried turning the table name
>into a host variable :table and concatenating the owner to the front,
>but to no avail. Is what I want to do possible? Any help would be
>greatly appreciated.

A host variable cannot be used for a database object name (table, column, etc.). What you need to do is construct the string at runtime, using strcpy and strcat (or, better, sprintf), and use dynamic SQL method 3 or 4. Read up about these in the precompiler guide, and in the Pro*C supplement. One of the example programs in the supplement (I think it's sample6.pc) shows how to do this for Method 1. Just extend the example to Method 3 or 4.

--Tim (tssmith_at_netcom.com) Received on Thu Aug 19 1993 - 05:30:38 CEST

Original text of this message