467,154 Members | 989 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,154 developers. It's quick & easy.

Anonymous Block in DB2

Hi there, I am writing a query in DB2 which needs to return a result
set, i want to be able to use a couple of variables in query to speed
things up.

Please can anyone tell me how i may do this? Is it possible to do this
as part of some sort of anonymous block.

The query will actually be submitted by Crsytal reports, I have no
access to create procedures or functions within the database so
whatever i do it must be in the form of a suubmitable query.

Hope somone can help, many thanks,

Toby

Oct 24 '07 #1
  • viewed: 6502
Share:
2 Replies
On Oct 24, 2:37 am, sybot_uk <sybot...@yahoo.co.ukwrote:
Hi there, I am writing a query in DB2 which needs to return a result
set, i want to be able to use a couple of variables in query to speed
things up.

Please can anyone tell me how i may do this? Is it possible to do this
as part of some sort of anonymous block.

The query will actually be submitted by Crsytal reports, I have no
access to create procedures or functions within the database so
whatever i do it must be in the form of a suubmitable query.

Hope somone can help, many thanks,

Toby
>From your use of the phrase "anonymous block," I take it you've got
experience with Oracle. The closest thing in in DB2 is the use of
BEGIN ATOMIC. The only problem is that "[i]f you enclose SELECT
statements inside compound SQL statements, the results of the SELECT
statement are not be displayed to the screen. This is because the
SELECT statement "never happens" as far as the shell is concerned (DB2
only returns the success or failure of the compound atomic statement
as a whole)."

I've taken the above quote from the following link, which I hope will
help you:

http://www-128.ibm.com/developerwork...p/0203yip.html

--Jeff

Oct 24 '07 #2
jefftyzzer wrote:
On Oct 24, 2:37 am, sybot_uk <sybot...@yahoo.co.ukwrote:
>Hi there, I am writing a query in DB2 which needs to return a result
set, i want to be able to use a couple of variables in query to speed
things up.

Please can anyone tell me how i may do this? Is it possible to do this
as part of some sort of anonymous block.

The query will actually be submitted by Crsytal reports, I have no
access to create procedures or functions within the database so
whatever i do it must be in the form of a suubmitable query.

Hope somone can help, many thanks,

Toby
>>From your use of the phrase "anonymous block," I take it you've got
experience with Oracle. The closest thing in in DB2 is the use of
BEGIN ATOMIC. The only problem is that "[i]f you enclose SELECT
statements inside compound SQL statements, the results of the SELECT
statement are not be displayed to the screen. This is because the
SELECT statement "never happens" as far as the shell is concerned (DB2
only returns the success or failure of the compound atomic statement
as a whole)."

I've taken the above quote from the following link, which I hope will
help you:

http://www-128.ibm.com/developerwork...p/0203yip.html
Toby,

If you post your PL/SQL we can help you translate it to DB2.
From what you write it may be all you need is a WITH clause (common
table expression).

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Oct 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

76 posts views Thread by Nick Coghlan | last post: by
11 posts views Thread by G Fernandes | last post: by
2 posts views Thread by Marcos Stefanakopolus | last post: by
60 posts views Thread by jacob navia | last post: by
12 posts views Thread by =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= | last post: by
2 posts views Thread by Gabe Moothart | last post: by
2 posts views Thread by Tony | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.