Solved

SQL400 max size

Posted on 2016-09-28
5
76 Views
Last Modified: 2016-09-30
Hi Experts,

While running SQL commands in some own (customer tool) SQLRPGLE, I have the problem that a execute immediate command, exceeds the length of 32700.
If I extend this variable, I get a precompiler error.

Is 32700 de maximum length for a prepared SQL command ?
0
Comment
Question by:theo kouwenhoven
5 Comments
 
LVL 14

Accepted Solution

by:
daveslater earned 500 total points
ID: 41821356
Yes 32000 is the max length.
I would like to know what the heck it is doing!!!
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 41821378
It contains a Create procedure commanr (more or less nice formatterd),
by removing all extra spaces and [CR][LF] commands, I'm now back to 30450, but it will give problems by next extention of the function :-S

Thanks for the confirmation Dave.
0
 
LVL 27

Expert Comment

by:tliotta
ID: 41821558
SQLRPGLE members can compile with SQL statement sizes up to 32766 bytes. Not sure why that specific number is the limit.
0
 
LVL 28

Expert Comment

by:pepr
ID: 41822584
To clarify the number, the 32766 is probably related to the implementation of the string that (wild guess) or may use the 32 KB blocks for single byte characters or it uses a 64 KB block for two bytes per character. The 64 KB is 2^16 which is 2 * 2^15 (that is 2 * 32767). But the implementation of the string may need 2 bytes to store the length of the string. This way, it is likely that 64 KB block of two bytes per char string is used. Otherwise, the maximum length of the string would be 32765 (if I am not mistaken). ;)
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 41824372
Carryover from the old 32K character data type limit in RPG.  SQL precompiler is separate from RPG compiler, and isn't always updated when RPG is.

pepr is right:

Various char types were implemented in RPG in the past with a 32K/32,768 byte overall limit (an even 8 pages of memory).  So fixed length character had a 32768 byte limit, and variable length character data type was implemented as a 2 byte integer at the front for the length, plus a 32766 character area, hence the occasional 32766 length limitation.

Varchar and char in current ILE RPG have a 16MB (-4 bytes for varchar to hold the length) limit.
 
IBM i DB2 SQL at V7R2 supports SQL statements up to 2,097,152 bytes.  

Can you use a different interface, like Run SQL Scripts in Navigator, or RUNSQLSTM?

Another alternative is to break the proc into two or more procedures at a convenient point and call one from the other.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now