Product Documentation

FairCom Java & .NET Stored Procedures

Previous Topic

Next Topic

Calling Scalar Functions from a User Defined Scalar Function

FairCom DB SQL does not have a mechanism for calling a scalar function directly from a user-defined function. To use scalar functions, it is necessary to call the function from within a FairCom DB SQL statement. FairCom DB SQL defines the special table SYSCALCTABLE which has only one row for use in situations where all the data is in the inputs.

Example


CREATE FUNCTION myuser.TO_NATIVE_DATE(IN UNIX_TYPE_DATE INT)

RETURNS TIMESTAMP

IMPORT

import java.sql.*;

BEGIN

StringBuffer query_str = new StringBuffer(“SELECT TIMESTAMPADD(SQL_TSI_SECOND,”);

query_str.append(UNIX_TYPE_DATE).append(“, TO_TIMESTAMP('01/01/1970 00:00:00')) FROM SYSCACLTABLE”);

SQLCursor SelCursor = new SQLCursor(query_str.toString());

SelCursor.open();

SelCursor.fetch();

return(Timestamp)SelCursor.getValue(1, TIMESTAMP);

END

TOCIndex