I second the SQL views....

Another option that's sometimes helpful, User Defined Table Functions (UDTF).

Think of them as a view you can pass parameters into...

Charles


On Thu, Jun 23, 2011 at 11:10 AM, Birgitta Hauser
<Hauser@xxxxxxxxxxxxxxx> wrote:
I find it helpful to develop SQL to be embedded using System i Nav
       Run SQL Scripts.  My habit is to create and save a .sql file
       named for the program or project.  I keep these files for
       use later for debugging or enhancements.

For complex SQL Statements I'd suggest to create SQL Views that can be
executed and tested in every SQL environment (and even with Query/400).
Because an SQL View has no key, you can have thousands of views on your
system without any performance decrease.
(Contrary to SQL indexes which must be updated as soon as any row in the
base table will be changed).

In this way my (embedded) SQL Source code is quite easy, 'SELECT Col1, Col2,
... ColN from MyView' where sometimes some WHERE conditions and/or Order By
clauses are added.
If something changes I only have to change my view and none of programs,
queries, downloads that use this view must be changed.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Gary Thompson
Gesendet: Thursday, 23. June 2011 15:21
An: RPG programming on the IBM i / System i
Betreff: Re: Fw: Embedded SQL error

Richard wrote:

Is there an easier or more intuitive way of debugging embedded SQL?

I find it helpful to develop SQL to be embedded using System i Nav
       Run SQL Scripts.  My habit is to create and save a .sql file
       named for the program or project.  I keep these files for
       use later for debugging or enhancements.

Having SQL commands separate from program code simplifies coding
       and allows me to focus.

Using FIND, I see six CAST and only five AS in your statement,
       so I would, as Michael Schutte suggested, start with
       that mis-match.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.