dbTalk Databases Forums  

DDL calls from SQL PL

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss DDL calls from SQL PL in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Theakanath
 
Posts: n/a

Default DDL calls from SQL PL - 08-26-2003 , 06:35 PM






Hi,
When I try to run/compile the following SQL PL, I get errors for the
DDL statements used in them. For example, the GRANT and DROP
statements don't work from the commandline SQL PL. In a stored
procedure, the DROP statements work for most of the object types
except for aliases. However, when these statements are executed as
dynamic SQL statements using another stored procedure, it seems to
work. And that is my workaround right now.

Are these db2 limitations or am I doing something wrong?

In a command line SQL PL:

begin atomic
if exists (select 'y' from tab1) then
grant all on tab2 to user1;
grant select,update on tab2 to user2;
drop table tab3;
end if;
end@


In a stored procedure:
FOR Aliases AS
SELECT tabname FROM syscat.tables
WHERE tabname = TObjectName
AND tabschema = TObjectSchema
AND type = 'A'
DO
drop alias Aliases.tabname;
-- CALL drop_object('ALIAS',Aliases.tabname);
END FOR;


Please share your thoughts.

Thanks in advance
Thomas.

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.