Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    205

    Unanswered: anonymous blocks ?

    Hi,

    I like to write the below procedure as an anonymous block( as in SQL Server ). How to do the same ? Please explain how to compile and call that block, if return so.

    create procedure testproc
    begin
    if exists(select *from syscat.tables where tabschema = 'DB2' and tabname = 'TESTVIEW' and type ='V') then
    drop view testview;
    end if;
    create view testview as select * from test;
    end
    @

    Thanks,
    Sam

  2. #2
    Join Date
    Aug 2004
    Posts
    15

    anonymus blocks

    you can write the commnads in a file. and from db2 command window:

    db2 -td@ -f file-name

    or u can use command center script tag. in tool settings set command terminating character as @.

  3. #3
    Join Date
    Mar 2004
    Posts
    205
    Thanks for your reply.

    Yes, you are right. This is ok with a 'create procedure'.
    But my requirement is an anonymous block, i.e without a 'CREATE PROCEDURE' statement. In this case I need to execute only these statement :

    if exists(select *from syscat.tables where tabschema = 'DB2' and tabname = 'TESTVIEW' and type ='V') then
    drop view testview;
    end if;
    create view testview as select * from test;

    But the above is not compiling, when I give the same in a file. how to compile this and even if it gets compiled, how to call this anonymous block for execution ?

    (as in SQL Server - anonymous block)

    Thanks,
    Sam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •