home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / oracle / 2182 < prev    next >
Encoding:
Text File  |  1992-11-11  |  1.5 KB  |  43 lines

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!ukma!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!tssmith
  3. From: tssmith@netcom.com (Tim Smith)
  4. Subject: Re: Dynamic SQL - PREPARE
  5. Message-ID: <1992Nov12.034541.22098@netcom.com>
  6. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  7. References: <1992Nov11.191651.1@vax1.tcd.ie>
  8. Date: Thu, 12 Nov 1992 03:45:41 GMT
  9. Lines: 32
  10.  
  11. In article <1992Nov11.191651.1@vax1.tcd.ie> nafallon@vax1.tcd.ie writes:
  12. >Hi, anybody like to help a struggling Oracler?.
  13. >One of our tables has a column listing the other tables to be accessed. 
  14. >I want to read a table name into a variable and then query that table for some
  15. > more data, therefore I have to use Dynamic SQL, but I cannot seem to get past
  16. > the PREPARE stage.
  17. >
  18. >The statement: EXEC SQL PREPARE subcat_stmt FROM :select_stmt;
  19. >
  20. >gives the error: ORA-00911: invalid character
  21. >
  22. >select_stmt is created as follows..
  23. >
  24. >EXEC SQL BEGIN DECLARE SECTION;
  25. >        VARCHAR select_stmt[200];
  26. >EXEC SQL END DECLARE SECTION;
  27. >
  28. >sprintf(select_stmt.arr,"SELECT song FROM rush WHERE album = 'Presto'");
  29. >
  30. >I have tried all sorts of combinations of VARCHARs and char's as well as using
  31. > variables for column names but the same error always results.
  32. >Any pointers as to why this is happening would be greatly appreciated.
  33. >
  34. >Niall Fallon
  35.  
  36. Looks like you're not setting the length component of the VARCHAR.  Your
  37. sprintf should be:
  38.  
  39. select_stmt.len = sprintf(select_stmt.arr, "SELECT ....
  40.  
  41. --Tim (tssmith@netcom.com)
  42.  
  43.