If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Parameterizing schema name

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-17-08, 08:13
usDB2 usDB2 is offline
Registered User
 
Join Date: May 2008
Posts: 39
Parameterizing schema name

Hi
I am trying to parameterize shema name:

CREATE PROCEDURE Test1"
(IN "SCH_NM" VARCHAR(20)
)

BEGIN
insert into SCH_NM."test" (x)
values(234555,)
END;

But I get an error:
[IBM][CLI Driver][DB2/LINUXX8664] SQL0204N "SCH_NM.test" is an undefined name. LINE NUMBER=... SQLSTATE=42704

Please help

Last edited by usDB2; 07-17-08 at 08:18.
Reply With Quote
  #2 (permalink)  
Old 07-17-08, 11:15
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You will have to do it as dynamic SQL not static.

Andy
Reply With Quote
  #3 (permalink)  
Old 07-18-08, 00:10
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
the problem in this case is not only you'll have to create the schema but you'll have to create the table inside that schema as well. Absence of any one of those will always result in an error.

IBM Information Center states
Code:
CREATE SCHEMA statement
Invocation
This statement can be embedded in an application program or issued through the use of dynamic SQL statements.
So dynamic SQL is the way out for you.

for further reference
http://publib.boulder.ibm.com/infoce...n/r0000925.htm
Reply With Quote
  #4 (permalink)  
Old 07-18-08, 03:49
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Schema creation doesn't have anything to do with the problem.

Schemas are created implicitly when you create a table and have the necessary privileges (e.g. IMPLICIT_SCHEMA if I'm not mistaken).
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 07-18-08, 03:53
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
point noted and thanks for updating me on the same.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On