Subject | SQL in UDF |
---|---|
Author | Aleš Kahánek |
Post date | 2002-03-14T16:49:43Z |
Hi All,
I would like to ask you the following question:
is possible to call SQL query within UDF?
I have the idea, that there is for example table
CREATE TABLE MYTABLE (
MYKEY INTEGER,
CONTACT_NAME VARCHAR(30),
CONTACT_TYPE CHAR(2)
)
Suppose, that the CONTACT_TYPE contains values FR, FA, OT and the
description field contains this:
Friend=FR
Family=FA
Other=OT
I would like to create UDF LOOKUP(FIELDNAME, FIELDVALUE) which should look
for the description field and find appropriate text (for example
LOOKUP(MYTABLE.CONTACT_TYPE, 'FR') should return string 'Friend'). Inside
the UDF I need to call SQL to receive the description for the desired field
and that is the question -> can I make such a call?
I know, that it could be done by another table and join, but this UDF could
be very handy when you can only define the texts in description field and
only call the UDF to receive the text. One should not have to define lots of
lookup tables in such case.
What do you think about it?
Ales Kahanek
ales.kahanek@...
I would like to ask you the following question:
is possible to call SQL query within UDF?
I have the idea, that there is for example table
CREATE TABLE MYTABLE (
MYKEY INTEGER,
CONTACT_NAME VARCHAR(30),
CONTACT_TYPE CHAR(2)
)
Suppose, that the CONTACT_TYPE contains values FR, FA, OT and the
description field contains this:
Friend=FR
Family=FA
Other=OT
I would like to create UDF LOOKUP(FIELDNAME, FIELDVALUE) which should look
for the description field and find appropriate text (for example
LOOKUP(MYTABLE.CONTACT_TYPE, 'FR') should return string 'Friend'). Inside
the UDF I need to call SQL to receive the description for the desired field
and that is the question -> can I make such a call?
I know, that it could be done by another table and join, but this UDF could
be very handy when you can only define the texts in description field and
only call the UDF to receive the text. One should not have to define lots of
lookup tables in such case.
What do you think about it?
Ales Kahanek
ales.kahanek@...