× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I prefer coding dynamic sql statements in the following way:

stmt = '+
select field1, field2 +
from table +
where code = ''1'' +
and field1 >= 9 + 1 +
order by fields';

This can be a problem some times as you can exceed the RPG string literal length limits, and there are readability issues for quotes and those extra plus signs at the end of each line. When I run into literal length limits I will take that string and break it up into smaller pieces like this:

dcl-s stmt Varchar(2048) Inz('');

stmt = 'select field1, field2';
stmt += ' from table';
stmt += ' where code = ''1''';
stmt += ' and field1 >= 9 + 1';
stmt += ' order by field';

The problem I have with this is it can be even less readable with all the additional cruft around the actual sql statement, and it still has the quote escaping issues of the previous method. I have submitted an RFE to allow me to use a syntax called heredoc in some other programming languages. This would allow me to code something like the following:

stmt = >>>DOC
select field1, field2
from table
where code = '1'
and field1 >= 9 + 1
order by fields
DOC;

The RFE is here:
http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=88357

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx


-----"Graves, Chuck" <cgraves@xxxxxxxxxxxxxx> wrote: -----
To: "rpg400-l@xxxxxxxxxxxx" <rpg400-l@xxxxxxxxxxxx>
From: "Graves, Chuck" <cgraves@xxxxxxxxxxxxxx>
Date: 05/12/2016 04:03PM
Subject: SQL Statement length


Is there a "trick" to programming a long complex (6000 character) SQL statement in RPG?

We keep getting a "variable truncated" error message.



[Rodda Paint Company]
Chuck Graves
Director of Information Systems
Rodda Paint Co.<http://www.roddapaint.com>
6107 N. Marine Drive
Portland, Oregon 97203
(503) 737-6042


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.