im working on creating a table function that can accept variable inputs and return variable outputs. If anyone could refer me to a simple such program with the relevant grammar... it would be great to get me started. Im not sure how to access variable input parameters and how to return em. im new to Teradata and have only worked on UDFs till date. I understand a basic table function.. but m not sure about this variant. Do we need to use va_list in C to implement it?.. can it be written in java too? wud b great i cud get a code/code fragment to demonstrate it.
You can find examples (for both C and Java) in Appendix A of "SQL External Routine Programming" in the documentation library for 13.0. The number of formal parameters is fixed by the function definition; only their values are variable. You can use function name overloading to get an equivalent effect, or you can have the the caller concatenate the parameters into a string that the function parses.
The output of a table function is always a single table, but the number and types of columns in the result table can be determined dynamically. The function must use the provided library functions (or Java classes) to get the output row definition and generate the row values.
thanks a lot Jim, i figured out how to do it, ur reply helped a lot. thanks!
My requirement is to decompose every single record into multiple records. But , when I run a for loop for each record in the TBL_BUILD phase, only the last o/p in the for loop is written out. So, instead of returning 4 rows for a single row, it returns the last computed record for that row. I want to know if I need to store the multiple records in a buffer or something and how to o/p it. Any kind of help on this, will be appreciated. Thanks.