Here is RTVSQLSRC on Github.
https://github.com/BrianGarland/RTVSQLSRC/tree/master/QSOURCE
It's odd that the source member has to exist before calling GENERATE_SQL
Regards,
Richard Schoen
Web:
http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx
----------------------------------------------------------------------
message: 1
date: Sun, 25 Jan 2026 11:26:28 +0100
from: "Birgitta Hauser" <Hauser@xxxxxxxxxxxxxxx>
subject: RE: GENERATE_SQL problem
Does the source member exist?
Try to generate the output member before running the GENERATE_SQL Stored Procedure
Mit freundlichen Gr??en / Best regards
Birgitta Hauser
Modernization ? Education ? Consulting on IBM i Database and Software Architect IBM Champion since 2020
"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!"
"Train people well enough so they can leave, treat them well enough so they don't want to. " (Richard Branson) "Learning is experience ? everything else is only information!" (Albert
Einstein)
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of David Gibbs via MIDRANGE-L
Sent: Friday, 23 January 2026 20:37
To: midrange-l@xxxxxxxxxxxxxxxxxx
Cc: David Gibbs <david@xxxxxxxxxxxx>
Subject: GENERATE_SQL problem
Folks:
I'm trying to use the GENERATE_SQL procedure to retrieve the DDL for SQL objects within an RPG service program.
The object definitely exists, as I'm querying SYSFILES to find the object type.
When I invoke the GENERATE_SQL procedure, the following shows up in the joblog (I'm debugging the program)...
Cursor GENSQL opened.
Row not found for GENSQL.
ODP not deleted.
Cursor GENSQL was closed.
Procedure or user-defined function GENERATE_SQL in *N returned a warning SQLSTATE.
The details of the error are:
SQL0462
Message . . . . : Procedure or user-defined function GENERATE_SQL in *N
returned a warning SQLSTATE.
Cause . . . . . : An SQLSTATE of the form 01xxx was returned by the
procedure or user-defined function GENERATE_SQL in *N (with specific name *N), along with message text NO OBJECTS FOUND.
The service program has authority to the table I'm trying to generate DDL for.
Here's how the procedure is being invoked from the RPG...
CALL GENERATE_SQL(
DATABASE_OBJECT_NAME => :object,
DATABASE_OBJECT_LIBRARY_NAME => :library,
DATABASE_OBJECT_TYPE => :objectType,
DATABASE_SOURCE_FILE_NAME => :sourceFile,
DATABASE_SOURCE_FILE_LIBRARY_NAME => :sourceLib,
DATABASE_SOURCE_FILE_MEMBER => :sourceMbr,
REPLACE_OPTION => 1,
STATEMENT_FORMATTING_OPTION => 0,
HEADER_OPTION => 0,
PRIVILEGES_OPTION => 0,
CCSID_OPTION => 0;
The source PF & member is being created using a sql qcmdexc procedure call, and the joblog shows it is either created or already exists.
Any ideas what might be causing the "NO OBJECTS FOUND" error?
Thanks!
david
--
------------------------------
message: 2
date: Sun, 25 Jan 2026 15:34:23 +0200
from: Gad Miron <gadmiron@xxxxxxxxx>
subject: Re: GENERATE_SQL
I have an old utility called RTVSQLSRC (a CMD plus RPG PGM) that creates a source MBR with the appropriate Create table statement I do not remember who I got it from, it was on this forum I think.
I can send it .
Gad
As an Amazon Associate we earn from qualifying purchases.