home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.oracle
- Path: sparky!uunet!ukma!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!tssmith
- From: tssmith@netcom.com (Tim Smith)
- Subject: Re: Dynamic SQL - PREPARE
- Message-ID: <1992Nov12.034541.22098@netcom.com>
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- References: <1992Nov11.191651.1@vax1.tcd.ie>
- Date: Thu, 12 Nov 1992 03:45:41 GMT
- Lines: 32
-
- In article <1992Nov11.191651.1@vax1.tcd.ie> nafallon@vax1.tcd.ie writes:
- >Hi, anybody like to help a struggling Oracler?.
- >One of our tables has a column listing the other tables to be accessed.
- >I want to read a table name into a variable and then query that table for some
- > more data, therefore I have to use Dynamic SQL, but I cannot seem to get past
- > the PREPARE stage.
- >
- >The statement: EXEC SQL PREPARE subcat_stmt FROM :select_stmt;
- >
- >gives the error: ORA-00911: invalid character
- >
- >select_stmt is created as follows..
- >
- >EXEC SQL BEGIN DECLARE SECTION;
- > VARCHAR select_stmt[200];
- >EXEC SQL END DECLARE SECTION;
- >
- >sprintf(select_stmt.arr,"SELECT song FROM rush WHERE album = 'Presto'");
- >
- >I have tried all sorts of combinations of VARCHARs and char's as well as using
- > variables for column names but the same error always results.
- >Any pointers as to why this is happening would be greatly appreciated.
- >
- >Niall Fallon
-
- Looks like you're not setting the length component of the VARCHAR. Your
- sprintf should be:
-
- select_stmt.len = sprintf(select_stmt.arr, "SELECT ....
-
- --Tim (tssmith@netcom.com)
-
-