DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 11th, 2009, 05:31 AM
alokpise alokpise is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 2 alokpise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 55 sec
Reputation Power: 0
New DB2 Developer

Hi Guys,

I am new to DB2 Development, i am asked to write a stored procedure with 3 IN parameters which when entered by the user, the values should be replaced with the field values in the select statement and then the result of the same should be inserted in the temp table.

Please let me know some useful tricks to create the same. Hope you all get what i am trying to do.

Thanks in advance,
ALOK

Reply With Quote
  #2  
Old June 11th, 2009, 08:58 AM
alokpise alokpise is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 2 alokpise User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 55 sec
Reputation Power: 0
I have written the following code... but its giving me the error below. Please response quick.


CREATE PROCEDURE CARDIFF (
@STARTDATE DATE,
@ENDDATE DATE,
@CARDTYPEID INT,
OUT @ERRORDESCRIPTION VARCHAR(200),
OUT @a INT,
OUT @b INT,
OUT @c INT,
OUT @d INT,
OUT @e INT,
OUT @f INT,
OUT @g INT,
OUT @h INT,
OUT @i INT,
OUT @j INT)
LANGUAGE SQL
MODIFIES SQL DATA
DYNAMIC RESULT SETS 1




P1: BEGIN
DECLARE SQLCODE INT DEFAULT 0
DECLARE SQLSTATE CHAR(5) DEFAULT '00000'
DECLARE RETCODE INT DEFAULT 0
DECLARE RETSTATE CHAR(5) DEFAULT '00000'
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING
BEGIN
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION, SQLWARNING
GET DIAGNOSTICS EXCEPTION 1 @ERRORDESCRIPTION=MESSAGE_TEXT;
VALUES(SQLSTATE, SQLCODE) INTO RETSTATE, RETCODE
RESIGNAL;
END;


select count(1) INTO @a from escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and Date(entrydate) between @STARTDATE and @ENDDATE
and firstnamecp NOT in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @b from escrip.member where terminationdate is null
and length(phone) = 10
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and Date(entrydate) between STARTDATE' and @ENDDATE
and firstnamecp NOT in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @c from escrip.member where terminationdate is null
and length(email) > 5
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and Date(entrydate) between @STARTDATE and @ENDDATE
and firstnamecp NOT in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @d from escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and Date(entrydate) between @STARTDATE and @ENDDATE
and firstnamecp in ('UNKNOWNCARD');


select count(1) INTO @e from escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and Date(entrydate) between STARTDATE and @ENDDATE
and firstnamecp in ('UNKNOWNPHONE');


select count(1) INTO @ffrom escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and firstnamecp not in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @g from escrip.member where terminationdate is null
and length(phone) = 10
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and firstnamecp not in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @h from escrip.member where terminationdate is null
and length(email) > 5
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and firstnamecp not in ('UNKNOWNCARD','UNKNOWNPHONE');


select count(1) INTO @i from escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and firstnamecp in ('UNKNOWNCARD');


select count(1) INTO @j from escrip.member where terminationdate is null
and memberid in (select memberid from escrip.membercard where terminationdate is null and cardtypeid = @CARDTYPEID)
and firstnamecp in ('UNKNOWNPHONE');


RETURN RETCODE;
END P1
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0010N The string constant beginning with "'); RETURN RETCODE; END P1"
does not have an ending string delimiter. LINE NUMBER=46. SQLSTATE=42603

SQL0010N The string constant beginning with "');


RETURN RETCODE;
END P1 " does not have an ending string delimiter.

Explanation:

The statement contains a string constant, beginning with
"<string>", that is not terminated properly.

The statement cannot be processed.

User Response:

Examine the statement for missing apostrophes in the indicated
string constant.

sqlcode : -10

sqlstate : 42603

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > New DB2 Developer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
Stay green...Green IT