If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Stored Procedure dynamic query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-09-09, 07:23
epcylla epcylla is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
Question Stored Procedure dynamic query

Hi,

When building a dynamic query and concatenating a string with an integer data type parameter it fails when deploying the SP.

CREATE PROCEDURE CLI_DATA_SQL
( IN P_ACCNUM INTEGER)

DECLARE V_SQL VARCHAR(2000);
SET V_SQL = ' WHERE CS.DOCSTATUS = 1 AND CS.ACCNUM > ' || P_ACCNUM

This statement with a string data type works fine.
SET V_SQL = ' WHERE CS.DOCSTATUS = 1 AND CS.TRADENAME LIKE '''|| P_CMPNAME ||'%''';

The issue is how to connect my statement with a integer data type parameter?

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 12-09-09, 07:41
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Take a look at the CAST operator.
Reply With Quote
  #3 (permalink)  
Old 12-09-09, 08:20
epcylla epcylla is offline
Registered User
 
Join Date: Jul 2009
Posts: 8
Hi Nick,

Works very well....

Thanks :-)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On