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 > Alternate ways to concatenating a string in stored procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-12, 05:38
SoftwareEngineer3 SoftwareEngineer3 is offline
Registered User
 
Join Date: Aug 2012
Posts: 24
Alternate ways to concatenating a string in stored procedures

Hi,

Using DB2 9.7 fixpack 4 on Windows 7.

I have a situation where I am creating a huge SQL inline query into a 32k VARCHAR. The SQL query string I am generating is so large that apparently the string is cut-off before it has been fully constructed I then execute the SQL query string using:

PREPARE S1 FROM V_SQL;
EXECUTE S1;

Are there alternative ways to create a query string? A 32k VARCHAR does not seem to be enough for me. The query has to be executed in one go though...
Reply With Quote
  #2 (permalink)  
Old 08-13-12, 06:54
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,766
How about to use CLOB?

PREPARE - IBM DB2 9.7 for Linux, UNIX, and Windows
Quote:
FROM

Introduces the statement string. The statement string is the value of the specified host variable.

host-variable
Specifies a host variable that is described in the program in accordance with the rules for declaring character string variables. It must be a fixed-length or varying-length character-string variable that is less than the maximum statement size of 2 097 152 bytes. Note that a CLOB(2097152) can contain a maximum size statement, but a VARCHAR cannot.

expression
An expression specifying the statement string. The expression must return a fixed-length or varying-length character-string type that is less than the maximum statement size of 2 097 152 bytes.
Reply With Quote
  #3 (permalink)  
Old 08-13-12, 07:27
SoftwareEngineer3 SoftwareEngineer3 is offline
Registered User
 
Join Date: Aug 2012
Posts: 24
Quote:
Originally Posted by tonkuma View Post
Thanks, that solved it
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