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 > Error when dynamically creating a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-17-12, 04:21
RebeccaMopailo RebeccaMopailo is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
Red face Error when dynamically creating a table

Hi, I am trying to create a table in db2 , but i get this error: SQLCODE: -601, SQLSTATE: 42710 - The name of the object to be created is identical to the existing name "Clients.Systems" , and that table doesnt exist at all, here is the code: Any help will be highly appreciated.
CODE:

OPEN TableCursor;
WHILE (Done = 0) DO
FETCH TableCursor INTO TableName;
SET dyn_stmt = 'CREATE TABLE ' CONCAT '"' CONCAT SchemaName CONCAT '"' CONCAT '.'
CONCAT '"' CONCAT TableName CONCAT '" ('
CONCAT '"systemID" INTEGER WITH DEFAULT NULL, '
CONCAT '"sytemname" VARCHAR(200) WITH DEFAULT NULL, '
CONCAT '"SystemCreatedDate" TimeStamp '
CONCAT ')';
EXECUTE IMMEDIATE dyn_stmt;

END WHILE;
CLOSE TableCursor;

Any help will be highly appreciated.

Reply With Quote
  #2 (permalink)  
Old 01-17-12, 05:10
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
is done initialized with another value somewhere - otherwise done is equal to 0 and the loop is always true...
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 01-17-12, 05:15
RebeccaMopailo RebeccaMopailo is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
Yes done is initialized with 0.
Reply With Quote
  #4 (permalink)  
Old 01-17-12, 05:21
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
For debugging purpose, comment out EXECUTE IMMEDIATE statement and show dyn_stmt of each iteration.
Reply With Quote
  #5 (permalink)  
Old 01-17-12, 05:30
RebeccaMopailo RebeccaMopailo is offline
Registered User
 
Join Date: Jan 2012
Posts: 3
Thanks for the reply, Tonkuma, please tell me how to do that? does db2 have the SHOW function? how can I do the show??
Reply With Quote
  #6 (permalink)  
Old 01-17-12, 05:38
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Anyway by which you can know the values of dyn_stmt is OK.
For example, DBMS_OUTPUT.PUT routine.
Reply With Quote
  #7 (permalink)  
Old 01-17-12, 09:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by RebeccaMopailo View Post
i get this error: SQLCODE: -601, SQLSTATE: 42710 - The name of the object to be created is identical to the existing name "Clients.Systems" , and that table doesnt exist at all
How did you verify that the table does not exist? DB2 clearly thinks otherwise.
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