By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,557 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,557 IT Pros & Developers. It's quick & easy.

Anonymous Block in DB2

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.