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 > Informix > 64K limitation for the stored procedure (any solutions!!!?)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-11, 05:58
sikamedia sikamedia is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
64K limitation for the stored procedure (any solutions!!!?)

As facts show below:

1) Maximum size of an SQL statement is 64K
2) The maximum length of a DECLARE statement is 64 kilobytes.
3) Combined size of procedure code and its global variables are limited
to 64K per procedure

I have made a SP which takes a input parameter as the data type of "LIST". when I call this SP with the input parameter LIST containing over 3000 string (the string length is 10), I am not able to run this SP.

My guess is the problem of 64K limitation. Am I right?

Is there any possibilities and solutions to overcome the constrains? Appreciate if there is a way to do it!
Reply With Quote
  #2 (permalink)  
Old 11-19-11, 05:01
begooden-it begooden-it is offline
Registered User
 
Join Date: Sep 2011
Location: Pont l'Abbé, Brittany, France
Posts: 183
Hi,


An error number, when you run the procedure, would probably help to focus troubleshooting :-)

Eric
Reply With Quote
  #3 (permalink)  
Old 11-22-11, 07:03
sikamedia sikamedia is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Quote:
Originally Posted by begooden-it View Post
Hi,


An error number, when you run the procedure, would probably help to focus troubleshooting :-)

Eric

After running the procedure, I have got the error code:

460: Statement length exceeds maximum.


Example:

A) - To run the example

dbaccess utvdb1 64kInvestigation.sql

Database selected.

460: Statement length exceeds maximum.
Error in line 1
Near character position 1

Database closed.


B) - To find the meaning of error

finderr 460
-460 Statement length exceeds maximum.

The statement text in this PREPARE, DECLARE, or EXECUTE IMMEDIATE
statement is longer than the database server can handle. The actual
limit differs with different implementations, but it is always
generous, in most cases up to 32,000 characters. Review the program
logic to ensure that an error has not caused it to present a string
that is longer than intended (for example, by overlaying the null
string terminator byte in memory). If the text has the intended length,
revise the program to present fewer statements at a time.


How to overcome the limitation?
Reply With Quote
  #4 (permalink)  
Old 11-22-11, 07:34
begooden-it begooden-it is offline
Registered User
 
Join Date: Sep 2011
Location: Pont l'Abbé, Brittany, France
Posts: 183
Hi,

why don't you try to insert your parameters list into some (temp ) table
before calling the proc, then the proc reads those parameters from the (temp) table.

Passing 3000 arguments to a function or stored procedure is a bit extreme for me. Who can read and maintain this code ?

Cheers
Eric
Reply With Quote
  #5 (permalink)  
Old 11-22-11, 08:23
sikamedia sikamedia is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Quote:
Originally Posted by begooden-it View Post
Hi,

why don't you try to insert your parameters list into some (temp ) table
before calling the proc, then the proc reads those parameters from the (temp) table.

Passing 3000 arguments to a function or stored procedure is a bit extreme for me. Who can read and maintain this code ?

Cheers
Eric
Thanks for reply and help.

I can read and maintain this code. But I can not control the size of parameters list. The client side is written in C# of .Net, it calls this SP and return the values.

According to your suggestion, Do you mean that it is to take all the list parameters and save them into a temp table, and fetch 3000 arguments to the function for each call??
Reply With Quote
  #6 (permalink)  
Old 11-22-11, 08:36
begooden-it begooden-it is offline
Registered User
 
Join Date: Sep 2011
Location: Pont l'Abbé, Brittany, France
Posts: 183
Yes,

this is the idea!
1) insert one row per argument intot the temp table ( prepare your insert statement for faster response time )

2) in the stored proc, if you arguments are by chance part of the cursor where clause, you can use something like:

Code:
SELECT ... FROM yourtable
WHERE yourkey IN ( SELECT col FROM yourtemptable )
Or something similar

Don't forget to suppress the contents of the temp table after...

This will be a bit slower than passing the arguments, but here you have not much choice...


Hope this helps
Reply With Quote
  #7 (permalink)  
Old 11-22-11, 11:44
sikamedia sikamedia is offline
Registered User
 
Join Date: Nov 2011
Posts: 4
Thanks for your suggestion.

Here it is a problem by following your advise,

As the client would like to take a list of parameters with the length size 1000000 (the size of parameters is varied),

I wrote a SP for saving 1000000 parameters (LIST type) to a temp table.
it gives the same error: 460: Statement length exceeds maximum when I run "dbaccess utvdb1 64kInvestigationSaveTemp.sql" .

My question is:

How to provide a SP call to the client, which client can take no limit length of parameters LIST? Should I provide a SP for client to take 3000 parameters for saving them into a temp table??

Appreciate your help!
Reply With Quote
  #8 (permalink)  
Old 11-22-11, 12:16
begooden-it begooden-it is offline
Registered User
 
Join Date: Sep 2011
Location: Pont l'Abbé, Brittany, France
Posts: 183
Your custome's request goes in favour of my suggestion.

Before the SP, insert each value of the parameter into one row of the temp table, and consider having an additional INTEGER column in this table for sorting purpose if necessary.

In the stored procedure, read the parameters in a foreach loop, or execute an inner join with the other tables, as explained above.
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