If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > External UDF C assistance - Newbie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-27-07, 10:40
kfwolf kfwolf is offline
Registered User
 
Join Date: Mar 2007
Posts: 5
External UDF C assistance - Newbie

In an existing SQL UDF, we have developed a sql statement. The statement is dynamic as tables can change based on the parameters that are passed in.



Question: Is there a way to return a table with the result set of the sql statement? The issue is that the sql statement is generated - so it exists as part of a string (which can be very complex). I am open to look at an external UDF in C.

Create Function GetPeerGroup
(IN_ID Integer,
IN_Period date)
Returns table (
OUT_ID Integer)
...

set squery = 'select col1 from table1 where col1 in (select x from y where a = b) and col1 in (select x1 from y1 where a1 = b1)';

-- squery can become very complex

-- the goal is to execute the query and return the result set. I am looking into calling a C UDF that has an in parameter of varchar for the squery and returns a table.
Reply With Quote
  #2 (permalink)  
Old 03-27-07, 12:16
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
As I already told you in the DB2 newsgroup: your tables do not change dynamically. Instead, you are querying a fixed set of tables depending on the parameters. So you could simply stick to static SQL (and SQL-bodied functions) and apply some logic to exclude/include the data from certain tables.

As you should have noticed, I would be willing to help you. But I asked you several times for a verbal description of the semantics of your table function. Nothing relevant was forthcoming so far, which prevents any real help.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 03-27-07, 12:36
kfwolf kfwolf is offline
Registered User
 
Join Date: Mar 2007
Posts: 5
New issue

Knut,

This can be considered a different issue.
I am looking at learning external UDF functions for C. In the db2 group, you requested sample data which takes authority with others.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On