× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I did this:

CREATE TABLE ROB/ADAM (MYKEY CHAR (1 ) NOT NULL WITH DEFAULT,
MYDATA CHAR (2 ) NOT NULL WITH DEFAULT) 

INSERT INTO ROB/ADAM VALUES('A', 'B') 

CREATE TABLE ROB/ADAM2 (MYKEY CHAR (1 ) NOT NULL WITH DEFAULT,
MYFIDL CHAR (33 ) NOT NULL WITH DEFAULT) 

INSERT INTO ROB/ADAM2 VALUES('A', 'DUH')

CREATE FUNCTION QGPL/GETADAM (INFLD CHAR (1))
RETURNS CHAR (1) 
LANGUAGE SQL 
READS SQL DATA 
DETERMINISTIC 
RETURNS NULL ON NULL INPUT 
BEGIN 
DECLARE OUTFLD CHAR(1); 
SET PATH = *LIBL; 
SELECT MYDATA INTO OUTFLD 
FROM ADAM 
WHERE MYKEY=INFLD; 
RETURN OUTFLD; 
END -- GETADAM; 

SELECT MYKEY, GETADAM(MYKEY)
FROM ROB/ADAM2 

....+....1....+....2....
MYKEY  GETADAM ( MYKEY )
  A            B 
********  End of data  *


Rob Berendt
-- 
"They that can give up essential liberty to obtain a little temporary 
safety deserve neither liberty nor safety." 
Benjamin Franklin 





"Smith, Dave" <DSmith@xxxxxxxxx>
Sent by: midrange-l-bounces@xxxxxxxxxxxx
09/02/2003 11:49 AM
Please respond to Midrange Systems Technical Discussion
 
        To:     <midrange-l@xxxxxxxxxxxx>
        cc: 
        Fax to: 
        Subject:        SQL UDF and *LIBL


I've created some SQL user defined functions (UDF) that I am using in my 
embedded SQLRPGLE programs.  I am having a problem that the UDF will not 
use my *LIBL.  In my regular embedded SQL I do not need to specify the 
library that contains the file; It uses my LIBL.  The function however is 
forcing me to HARDCODE the library in order to work correctly.   Anybody 
know what I'm doing wrong?

Below is the code fro the function and the SQLRPGLE program at V5R2:

CREATE FUNCTION GETCEN  (pYear Decimal (2,0)) 
Returns Decimal(2,0) 
Language SQL 
Reads SQL Data 
Deterministic 
Returns Null On Null Input 

Begin 
 Declare wCenturyBaseYear Decimal(2,0); 
 Declare wLowCentury Decimal(2,0); 
 Declare wHighCentury Decimal(2,0); 
 Declare pCentury Decimal(2,0); 

Set Path = *LIBL;

Select SYBSYR, SYLCEN, SYHCEN 
 Into wCenturyBaseYear, wLowCentury, wHighCentury 
 From MYFILE 
 Where SYCO = 01 and SYID = '  '; 

If wCenturyBaseYear IS NULL Then 
  Set wCenturyBaseYear = 85; 
  Set wLowCentury = 19; 
  Set wHighCentury = 20; 
End If; 

If pYear > wCenturyBaseYear Then 
 Set  pCentury = wLowCentury; 
Else 
 Set pCentury = wHighCentury; 
End If; 

Return pCentury; 

End -- GETCEN;


Below gives me an error at runtime that "MYFILE in MYLIB(which is my 
CURLIB) type *FILE not found" even though MYFILE is in my LIBL.
 * 
C/EXEC SQL 
C+ SET :@CENT = GETCEN(:@YEAR) 
C/END-EXEC 
 *  

David Smith
IT Consultant
dsmith@xxxxxxxxx
517.546.5400
 

_______________________________________________
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing 
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.