Can a function return Temp-table?

hungnx

New Member
Hi all,
I try to create a function that return a temp-table but it gets error when trying to compile the program.
Exp: include "ttTemp-table.i"
function aFunction return ttTemp-table (input ..., ouput ...):
end function.

Is it possible to have a function returning temp-table data type? How can i do it?

Thanks,
 

bulklodd

Member
sorry for citing the manual but it says quite clearly:

  • Indicates the function returns a value, and specifies the data type of that return value. Progress provides the following return value data types: CHARACTER, CLASS, COM-HANDLE, DATE, DATETIME, DATETIME-TZ, DECIMAL, HANDLE, INTEGER, LOGICAL, LONGCHAR, MEMPTR, RAW, RECID, ROWID, and WIDGET-HANDLE.
    You specify a class or interface as a return value for a user-defined function using the following syntax:

    [ CLASS ] { type-name }​


    Progress passes the object reference associated with the class or interface (by value), not the class or interface itself.

so you see you can't return temp-table from function
 

bulklodd

Member
anyway you can return a temp-table from a function like that:

Code:
FUNCTION xxx RETURNS LOGICAL (OUTPUT TABLE FOR ttTemp-table ):
 
END FUNCTION.
 
FUNCTION xxx RETURNS HANDLE ():
   RETURN TEMP-TABLE ttTemp-table:HANDLE.
END FUNCTION.

hth
 

lord_icon

Member
A temp table is a data buffer that is local to that block. Data can be retrieved and passed / returned as appropraite. A method maybe to create a temp file to store data that can be accessed. This is how M$ & Windows works. Output to a text file, pass the handle to the file (name...) when you have finnished make sure that you delete the temp file on-the-fly.
 

tamhas

ProgressTalk.com Sponsor
FWIW, a Function can RETURN a Class, so if you wrap the temp-table in a Class, that is another way you could accomplish the need.
 
Top