Link to home
Start Free TrialLog in
Avatar of Theo Kouwenhoven
Theo KouwenhovenFlag for Netherlands

asked on

SQL400 max size

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 ?
ASKER CERTIFIED SOLUTION
Avatar of daveslater
daveslater
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Theo Kouwenhoven

ASKER

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.
Avatar of Member_2_276102
Member_2_276102

SQLRPGLE members can compile with SQL statement sizes up to 32766 bytes. Not sure why that specific number is the limit.
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). ;)
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.