dbTalk Databases Forums  

LIKE WITH HOST VARIABLE IN SQL UDF

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss LIKE WITH HOST VARIABLE IN SQL UDF in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default LIKE WITH HOST VARIABLE IN SQL UDF - 05-19-2006 , 05:02 AM






Hello.

UDB DB2 v8.2.1 for LUW.
Why this function can't be compiled?
---
CREATE FUNCTION MYLIKE(NM VARCHAR(128))
LANGUAGE SQL
RETURNS INTEGER
BEGIN ATOMIC
RETURN
(
SELECT COUNT(1)
FROM SYSCAT.TABLES
WHERE TABNAME LIKE MYLIKE.NM
);
END@
---
SP with like with host variable is compiled successfully.
I think it is a bug.

Sincerely,
Mark B.
Mark B.


Reply With Quote
  #2  
Old   
Rhino
 
Posts: n/a

Default Re: LIKE WITH HOST VARIABLE IN SQL UDF - 05-19-2006 , 07:51 AM







<4.spam (AT) mail (DOT) ru> wrote

Quote:
Hello.

UDB DB2 v8.2.1 for LUW.
Why this function can't be compiled?
---
CREATE FUNCTION MYLIKE(NM VARCHAR(128))
LANGUAGE SQL
RETURNS INTEGER
BEGIN ATOMIC
RETURN
(
SELECT COUNT(1)
FROM SYSCAT.TABLES
WHERE TABNAME LIKE MYLIKE.NM
);
END@
---
SP with like with host variable is compiled successfully.
I think it is a bug.

I think it would be easier to guess the problem if you told us the error
message from the compiler.

The only obvious problem I see is 'select count(1)' instead of 'select
count(*)' but 'count(1)' may be a valid expression, even if it doesn't do
what you want, so I'm not sure if it would cause the compile to fail.

--
Rhino




Reply With Quote
  #3  
Old   
Serge Rielau
 
Posts: n/a

Default Re: LIKE WITH HOST VARIABLE IN SQL UDF - 05-20-2006 , 10:10 AM



Rhino wrote:
Quote:
4.spam (AT) mail (DOT) ru> wrote in message
news:1148032926.171923.113140 (AT) i40g2000cwc (DOT) googlegroups.com...
Hello.

UDB DB2 v8.2.1 for LUW.
Why this function can't be compiled?
---
CREATE FUNCTION MYLIKE(NM VARCHAR(128))
LANGUAGE SQL
RETURNS INTEGER
BEGIN ATOMIC
RETURN
(
SELECT COUNT(1)
FROM SYSCAT.TABLES
WHERE TABNAME LIKE MYLIKE.NM
);
END@
---
SP with like with host variable is compiled successfully.
I think it is a bug.
It a known limitation.
Local variables and parameters cannot be used in LIKE patterns in
"inline" SQL PL (That is SQL functions and triggers).

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: LIKE WITH HOST VARIABLE IN SQL UDF - 05-22-2006 , 01:19 AM



Is it described somewhere in documentation?
I'd like to read about other SQL UDF limitations.

Quote:
It a known limitation.
Local variables and parameters cannot be used in LIKE patterns in
"inline" SQL PL (That is SQL functions and triggers).


Reply With Quote
  #5  
Old   
Serge Rielau
 
Posts: n/a

Default Re: LIKE WITH HOST VARIABLE IN SQL UDF - 05-22-2006 , 10:26 AM



4.spam (AT) mail (DOT) ru wrote:
Quote:
Is it described somewhere in documentation?
I'd like to read about other SQL UDF limitations.
Yes and no. The explanation for LIKE says that the pattern must be a
"constant expression". That expression includes host-variables.
Host-variables are equated with SQL Variables in SQL Procedures (but not
- in this case - functions).
This limitation is really special and teh only on eof its kind.
In general "inline" SQL PL is described in "compound statement (dynamic)".

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.