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



On 25 Apr 2013 12:14, Needles,Stephen J wrote:
<<SNIP>>

CREATE FUNCTION library.MaxSEQupv
<<SNIP>>
BEGIN
RETURN(
select ...
from library.table
...
);
END

In order to get it to work, I needed to qualify the table. I would
prefer to make this schema independent.

Unqualified, the identifier should have been the authorization ID, the user profile name, when using NAMING(*SQL).

I tested using:

select
library.MAXSEQUPV(cast('3434343434' as char(10))
, cast(20120301 as decimal(8,0)))
from sysibm.sysdummy1

again...in order to get it to work, I had to change over to *SQL
rather than *SYS for naming conventions and had to qualify the UDF.
Again, I would prefer to make the UDF schema independent.

What have I done wrong?


Whatever interface was being used to issue the CREATE FUNCTION was not noted. But if the UDF is created using NAMING *SYS, then the default PATH will be *LIBL and the Library List will be utilized to locate unqualified identifiers which are table-references... as long as there is no CURRENT SCHEMA set.

After the UDF is created, use PRTSQLINF to see the PATH and SCHEMA settings that were in effect.

The following issued with NAMING(*SYS) active in the SQL environment being used to issue the CREATE, and no /current schema/ being set [via whatever is the parameter specification on the feature being utilized to issue the SQL CREATE FUNCTION, that equate with that special register] should offer what is desired; i.e. allow unqualified table reference, and unqualified function reference, when using System Naming and the default Path:

CREATE FUNCTION library/MaxSEQupv
( parm1 char(10)
, parm2 dec(8, 0)
) RETURNS dec(3, 0)
LANGUAGE SQL
RETURN(
select
cast(max(field3) as decimal(3, 0))
from /* no qualifier */ table
where field1 = parm1
and field2<= parm2
)

FWiW the above request drops the BEGIN and END because there is only one statement, the RETURN. That source is now compatible also when the decimal separator is a comma.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.