473,326 Members | 2,081 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,326 software developers and data experts.

SQL Procedure Question

I am new to creating DB2 SQL Procedures and I need a little help.

This works perfectly when I am just using it through my SQL Editor:
SELECT * FROM SALESTABLE
WHERE VENDOR LIKE 'ELK' || '%' AND CUSTOMER LIKE 'HOO' || '%'

It will not work for my procedure. Here it is:

CREATE PROCEDURE SALES_HISTORY (
IN I_VENDOR CHAR(6) ,
IN I_CUST CHAR(6))
DYNAMIC RESULT SETS 1
LANGUAGE SQL

BEGIN

DECLARE CURSOR1 CURSOR FOR SELECT * FROM SALESTABLE
WHERE VENDOR LIKE I_VENDOR || '%' AND CUSTOMER LIKE I_CUST || '%' ;

OPEN CURSOR1 ;
END ;

If I call the procedure as CALL SALES_HISTORY('ELK','HOO') it returns
nothing.
Interesting enough, if I pass in the full vendor and customer numbers
it works. CALL SALES_HISTORY('ELK050','HOO050')

Can anybody help me create this procedure so I can pass only part of
the vendor and customer numbers and still retrieve results?

My DB2 database resides on an ISeries server running V5R4.

Nov 16 '06 #1
2 1638
use VARCHAR. Yo are looking for 'ELK %' but you want 'ELK%'

IN I_VENDOR VARCHAR(6) ,
IN I_CUST VARCHAR(6))

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Nov 16 '06 #2
I knew it had to be something simple I was overlooking. Thank you
Serge!!

Serge Rielau wrote:
use VARCHAR. Yo are looking for 'ELK %' but you want 'ELK%'

IN I_VENDOR VARCHAR(6) ,
IN I_CUST VARCHAR(6))

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Nov 16 '06 #3

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

Similar topics

5
by: Lauren Quantrell | last post by:
Just wondering if this is good form: Alter Procedure "mySPName" @UniqueID int AS set nocount on set xact_abort off DELETE FROM tblNameOne
1
by: Raquel | last post by:
Have a question on the Stored procedure method code generated by DB2 development center for Java stored procedures. Suppose I have a requirement to return the resultset consisting of FIRSTNME,...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
3
by: Joseph Lu | last post by:
Hi, all I have a stored procedure created in SQL Server like the following lines. // stored proceudre code starts here CREATE PROCEDURE sp_insertdata @strdata varchar(250) , @rsult BIT...
5
by: ric_deez | last post by:
Hi there, I would like to create a simple search form to allow users to search for a job number based on a number of parameters. I think I understand how to use parameteres associated with Stored...
4
by: Henrik Juul | last post by:
How do I call my Stored Procedure recursively: CREATE PROCEDURE dbo.GetParentIONode ( @IONodeID int, @FullNodeAddress char(100) OUTPUT ) AS BEGIN
5
by: william.david.anderson | last post by:
Hi there, I have a newbie question regarding stored procedures and locking. I'm trying to use a stored procedure to perform a 'select for update' and return a cursor. Below is a stripped down...
11
by: peter | last post by:
I am trying to get a SQL stored procedure to use user maintained MQT implicitly which raises questions on when they are used or not used. In theory you would expect the stored procedure to pick up...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.