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. |