473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

question about dynamic SQL

I nees create a procedure that return a cursor for Crystal report. I
need use dynamic SQL.
what's wrong with the following procedure ? (that only part of the
sample)

CREATE PROCEDURE CARD.PROCEDURE1 (IN EMPLOYEE_ID VARCHAR(50) )
LANGUAGE SQL
SPECIFIC SP_TEST_DYN
DYNAMIC RESULT SETS 1
P1: BEGIN
DECLARE V_DYN_SQL VARCHAR(200);

DECLARE C_AMT CURSOR FOR V_CUR;

SET V_DYN_SQL = 'SELECT sum(coalesce(salary) as amt '
||'FROM HR.EMPLEE_SALARY'
||' WHERE EMPLOYEE_ID IN ('|| EMPLOYEE_ID ||')';

PREPARE V_CUR FROM V_DYN_SQL;

OPEN C_AMT;
END P1
Thanks a lot for any help!

Nov 12 '05 #1
2 1181
li******@yahoo.ca wrote:
I nees create a procedure that return a cursor for Crystal report. I
need use dynamic SQL.
what's wrong with the following procedure ? (that only part of the
sample)

CREATE PROCEDURE CARD.PROCEDURE1 (IN EMPLOYEE_ID VARCHAR(50) )
LANGUAGE SQL
SPECIFIC SP_TEST_DYN
DYNAMIC RESULT SETS 1
P1: BEGIN
DECLARE V_DYN_SQL VARCHAR(200); DECLARE V_CUR STATEMENT; -- not really needed but good style. DECLARE C_AMT CURSOR FOR V_CUR WITH RETURN TO CLIENT;
SET V_DYN_SQL = 'SELECT sum(coalesce(salary) as amt '
||'FROM HR.EMPLEE_SALARY'
||' WHERE EMPLOYEE_ID IN ('|| EMPLOYEE_ID ||')';

PREPARE V_CUR FROM V_DYN_SQL;

OPEN C_AMT;
END P1


Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
EMPLOYEE_ID is VARCHAR(50).

||' WHERE EMPLOYEE_ID IN ('''|| EMPLOYEE_ID ||''')';

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Adonis | last post by:
What I do not understand, or not clear to me I should say, is how can some people regard Python as a scripting language? In particular the JAVA crowd. Unless my understanding is off, and from what...
6
by: Martin Feuersteiner | last post by:
Dear Group I have found that table A had SELECT permissions for 'Public' but not table B. Giving 'Public' SELECT permissions on table B did the trick. HOWEVER, I don't want anyone to be able...
16
by: cppaddict | last post by:
Hi, I am deleting some objects created by new in my class destructor, and it is causing my application to error at runtime. The code below compiles ok, and also runs fine if I remove the body...
14
by: Flzw | last post by:
Well I have a map like this : std::map <string, CObject> ObjectList; I have a function like this : CObject* NewObject( char* Name, CArg* Arg) { std::string key = Name; ObjectList =...
6
by: Ramachandran Subramanian | last post by:
I have a question regarding the db2 reset monitor. When I issue the command and do a get snapshot I see most of the counters are reset . How ever the Dynamic SQL snapshot section doesnt seem...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
28
by: Alan Isaac | last post by:
I have a class whose instances should only receive attribute assignments for attributes that were created at inititialization. If slots are not appropriate, what is the Pythonic design for this? ...
5
by: =?Utf-8?B?SmVzc2ljYQ==?= | last post by:
Hello, I have a pInvoke question. This is the C function that is exported from one of the C dll, extern __declspec(dllexport) IM_RET_CODE ST_import (IM_MODE mode, char *filename,...
3
by: =?Utf-8?B?R3JlZw==?= | last post by:
i'm not really sure how to word my question because I'm new to CSHarp and Web-Developemnt, so I'm not quite sure how to word my question. But, I'll give it a try anyways. I have inherited a...
9
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.