Hi
I want to write a user defined function which does the following.
1. Take a string value as input parameter
2. Should execute a sql statement: select col1, col2, col3, col4 from
table_name where name = value
3. Do some arithmetic operations on the values returned by the above
sql statement.
4. Return the above arithmetic operation as a float value
I am currently stuck in step 2. I dont know how to obtain the values
from the sql statement executed in step 2.
Any pointers will be very helpful.
Here is the template UDF code:
CREATE FUNCTION HEALTHCAREDB.FUNCTION1( patient_id VARCHAR(36) )
RETURNS INTEGER
F1: BEGIN ATOMIC
/*how do i read the results from within the UDF for the below sql
statement*/
SELECT col1, col2, col3, col4 FROM HEALTHCAREDB.PATIENT_VISIT_INFO_VIEW
AS WHERE PATIENT_VISIT_INFO_VIEW.PATIENT_ID = FUNCTION1.patient_id;
RETURN xxxxx;
END
Really appreciate your help.
Thanks
Mahesh