Re: help: pro*c & creating tables

From: The Surf Report <surfin_at_ozemail.com.au>
Date: 1995/06/07
Message-ID: <3r3424$1e7_at_oznet06.ozemail.com.au>#1/1


Seb Adams (sa103_at_york.ac.uk) wrote:
: hi,
: i'm using pro*c and oracle v6 on a vax.

me too

: EXEC SQL BEGIN DECLARE SECTION;
: VARCHAR tab_name[30];
: EXEC SQL END DECLARE SECTION;
 
: in main I copy the argument into a string :
: strcpy(tab_name.arr,argv[3]);
 

: and then create a table with the variable :
: EXEC SQL CREATE TABLE :tab_name
: ( etc etc );

: Pro*c comes up with an error that bind variables cannot be used in a
: create statement. Does anyone know how to get round this ?

You need to create your statement using dynamic SQL. This is detailed in the Pro*c guide. Basically it amounts to creating your whole statement as one string (using strcat or the like). Then issue a prepare statement, to tell oracle to parse the statement and an execute statement (I think it is, don't have the manual handy) to run it.

This is the only way pro*c can reference variables in anything other than select lists, into lists, where clauses, order bys and group bys.

: Another question :) I'm trying to do the same thing for column

Same thing, Seb. Received on Wed Jun 07 1995 - 00:00:00 CEST

Original text of this message