SQL Code Migration into DB2

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
dharmendra87
Member
Posts: 4
Joined: Mon Dec 30, 2013 7:04 pm

SQL Code Migration into DB2

Post by dharmendra87 » Sat Jan 04, 2014 12:08 pm

//Hi all please check the error i am getting problem to find out, actually i trying to convert this code into db2.

Code: Select all

CREATE function getPersonDesgId(PersonID Integer)
Returns Integer
Language SQL
Contains SQL
Begin Atomic
	Declare PDesgID Integer Default 0;
	Set  PDesgID = 0; 
	SELECT PDesgID, DesignId from Person Where PersonId =PersonID;
		Return PDesgID;
End

//Error

Running
ADMINISTRATOR.GETPERSONDESGID - Deploy started.
Create user-defined function returns SQLCODE: -579, SQLSTATE: 42985.
ADMINISTRATOR.GETPERSONDESGID: 10: Routine "ADMINISTRATOR.GETPERSONDESGID" (specific name "ADMINISTRATOR.GETPERSONDESGID") attempted to read data but was not defined as READS SQL DATA or MODIFIES SQL DATA.. SQLCODE=-579, SQLSTATE=42985, DRIVER=3.66.46
Routine "ADMINISTRATOR.GETPERSONDESGID" (specific name "ADMINISTRATOR.GETPERSONDESGID") attempted to read data but was not defined as READS SQL DATA or MODIFIES SQL DATA.. SQLCODE=-579, SQLSTATE=42985, DRIVER=3.66.46
ADMINISTRATOR.GETPERSONDESGID - Deploy failed.
ADMINISTRATOR.GETPERSONDESGID - Roll back completed successfully.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Jan 05, 2014 2:35 am

From the manual:
-579 object-type object-name ATTEMPTED TO READ DATA WHEN THE DEFINITION
OF THE FUNCTION OR PROCEDURE DID NOT SPECIFY THIS ACTION

Explanation: The current environment does not allow SQL statements that read data. One of the following situations had occurred:

• A user-defined function or stored procedure object-name was invoked and attempted to read data, but the function or procedure was defined without the READS SQL DATA or MODIFIES SQL DATA option.


• A function or procedure defined with CONTAINS SQL or NO SQL has attempted to invoke another function or procedure defined with READS SQL DATA.
Keep in mind that SQL specifics can vary from one vendor to another.

Suggest you consider what this function supports and determine how to change/replace this function.
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others