× 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.



Dave,

Have you tried SET OPTION NAMING = *SYS

Cheers
Colin.W

-----Original Message-----
From: Smith, Dave [mailto:DSmith@xxxxxxxxx] 
Sent: 02 September 2003 17:49
To: midrange-l@xxxxxxxxxxxx
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.

For the latest on Bertram Books products and services and for up-to-the-minute 
book news visit www.bertrams.com


This e-mail and any attachments may contain information that is confidential 
and privileged and is solely for the use of the intended recipient. If you are 
not the intended recipient please notify the sender and delete this e-mail and 
any attachments immediately







As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.