Re: Using Embedded SQL in RPGLE or Creating SQL Functions

Justin Taylor <[email protected]> Mon, 23 Mar 2026 07:31:28 -0500
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <CAJu8Sp8zntHTqs82Uc4cATquEvUs-32_GXAxvp7fUhCcn-icYg@mail.gmail.com>
By default, in the RPG code itself.  If it gets really crazy, or it needs
to be shared among different modules, move it to a function or stored proc
at that time.

Inline SQL is my go-to.



On Sat, Mar 21, 2026 at 9:47 AM Richard Schoen <[email protected]>
wrote:

> Another interesting philosophy question.
>
> When embedding SQL calls in RPG I have seen two schools of thought.
>
> -Embed your SQL processing into your RPG code.
>
> -Embed you SQL processing into the DB itself: Stored Process/SQL
> Functions, etc…. and call those from RPG.
>
> Personally I like putting my SQL logic into my RPG code as it’s much more
> debuggable whereas I don’t think it’s simple to debug SQL stored procedures
> and functions.
>
> In other words I try to keep the actual access logic as simple as possible
> and put business logic in re-usable code. I generally call the the business
> layer.
>
> I do this similarly in other languages.  And generally I haven’t replied a
> lot on stored procedures in any language or database. I put all my DB and
> business logic in separate modules.
>
> I’m just curious what other here favor when writing their RPG logic.
> Embedded SQL in RPG or using Sprocs/Functions and keep your RPG dumb as a
> stump/simplified :-)
>
> Regards,
> Richard Schoen
> Web: http://www.richardschoen.net
> Email: [email protected]
>
>
>
-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.