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 > Pervasive.SQL > Return Table from User-Defined Function?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-22-09, 10:30
James Kane James Kane is offline
Registered User
 
Join Date: May 2009
Posts: 1
Question Return Table from User-Defined Function?

After some quick experimentation, I'm looking for some feedback from those more experience with the Pervasive SQL engine. Basically, I am attempting to implement a UDF that takes a CSV argument and returns the elements in a table. The intent is to call the UDF from a construct in a stored procedure similar to this:

WHERE id IN (SELECT id FROM udf_Split('''6'', ''7'', ''42'''))

The road block is that it appears you cannot return a table from a UDF in Pervasive as I am getting a syntax error shortly after the BEGIN statement. In looking at CREATE FUNCTION's help entry, it appears this would be because TABLE cannot be used with the RETURNS. Is this indeed not supported in Pervasive?

If not, does anyone have a good solution for this limitation? I'm thinking a temp table created from the main app is the only way to go otherwise.
Reply With Quote
  #2 (permalink)  
Old 05-22-09, 10:41
mirtheil mirtheil is online now
Registered User
 
Join Date: Dec 2001
Posts: 1,026
I haven't tried it but you might want to have the function return a string and then build the Select with the result and run the SQL using EXEC.
Something like:
Code:
declare :sSQL string;
set :sSQL = "select from test";
exec (:sSQL);
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On