AS400 User
AS400 User

Reputation: 187

Getting a SQL error code when doing a SELECT INTO

I am doing a select into inside my RPGLE. It was working all good in development but it started giving me a SQL error when deployed to production. SQL Error is:

-579 (object-type object-name ATTEMPTED TO READ DATA WHEN THE DEFINITION OF THE FUNCTION OR PROCEDURE DID NOT SPECIFY THIS ACTION).

Note that TABLE1 (which was also changed, added a field, for this Request and moved to production along with the Program) is only used in the below statement and not declared in F-spec.

Tried to recreate this in Development Environment but without Luck. This program is called from multiple programs but they do not create a job log for those. The call stack always has a Stored Procedure at the beginning (the Program is always called from an SP)

I think it has to do with some settings in the calling programs may be.

Exec Sql Select WHS                            
           into :WHS1                         
           from Table1
           Where Company = :COMP
             and WHS = :WHSE;                     

Upvotes: 0

Views: 837

Answers (1)

AS400 User
AS400 User

Reputation: 187

This program is called from Multiple Stored Procs. Some of them have a Contains SQL in it.

CONTAINS SQL means that the function may contain some SQL, but it does not read or write any data stored in a database via SQL. Examples include SET. With CONTAINS SQL in a stored procedure, if the procedure or one it calls tries to read a DB using SQL, then it fails. If it does not have CONTAINS SQL, then the stored procedure would take MODIFIES SQL DATA by default and it would not fail.

Upvotes: 2

Related Questions