895 pts.
I have a SQLRPGLe program. Certain files are not available at client terminal depending upon the applications purchased by client. I have a common program called from all applications and hence i user open the files based on the application types. my confusion is if i refer a file directly in SQL statement in this program. i dont declare it in F-spec as usropn.........Will this throw any error during compile time at client terminal when those files are not present. I'm sure that during run time those files will not be referred. Thanks, Nutan.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t think you will be able to compile a program with externally defined F-specs regardless of the USROPN clause. The compiler still has to check the record name, field names and types, etc, so it still needs the files.

I would expect the same problem with SQL.

I think you will have to install a set of empty files to be able to compile the programs then you might want to delete them, although then a recomile at any time would be impossible. Alternatively you could provide the compiled object to your clients – you can sometimes compile to an earlier version.


It depends on what type of SQL coding you are using. Are you using Static or Dynamic SQL within your RPG program? If you use Static, then the SQL precompiler will check the file and make sure the sytnax of the SQL is corrrect (file exists, fields referenced in file exist, etc.). However you can get around the precompiler by using dynamic SQL. With dynamic SQL you create a text string that contains the SQL statement you wish to run and then use the Prepare statement . I have a program where I pass a file and field name into the program and then create a SQL query to return a list of values from the file/field combination. It will work for any file. And I don’t have to define the file in the F specs. One thing to be aware of using dynamic SQL is that any errors in syntax will cause errors at run time and can not be caught beforehand because the precompiler does not evaluate your SQL statements.


Joy is absolutely correct.
Dynamic SQL would work for your application, but as she pointed out, there is no error checking of the command at compile time.

Thanks all…
i made sure i won compile anything at client side….
this means i can very well run static sql depending upon the conditions met for an application..


Discuss This Question:  

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: