/******************************************************************************* ** ** Source File Name = udfsrv.c ** ** Licensed Materials - Property of IBM ** ** (C) COPYRIGHT International Business Machines Corp. 1995, 2000 ** All Rights Reserved. ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp. ** ** ** PURPOSE : ** User defined functions called from udfcli.c. ** ** For more information about these samples see the README file. ** ** For more information on programming in CLI see the: ** - "Building CLI Applications" section of the Application Building Guide, and the ** - CLI Guide and Reference. ** ** For more information on the SQL language see the SQL Reference. ** *******************************************************************************/ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sqludf.h> /************************************************************************* * function ScalarUDF **************************************************************************/ #ifdef __cplusplus extern "C" #endif void SQL_API_FN ScalarUDF ( SQLUDF_CHAR *inJob, SQLUDF_DOUBLE *inSalary, SQLUDF_DOUBLE *outNewSalary, SQLUDF_SMALLINT *jobNullInd, SQLUDF_SMALLINT *salaryNullInd, SQLUDF_SMALLINT *newSalaryNullInd, SQLUDF_TRAIL_ARGS) { if (*jobNullInd == -1 || *salaryNullInd == -1) { *newSalaryNullInd = -1; } else { if( strcmp( inJob, "Mgr ") == 0) { *outNewSalary = *inSalary * 1.20; } else if( strcmp( inJob, "Sales") == 0) { *outNewSalary = *inSalary * 1.10; } else /* it is clerk */ { *outNewSalary = *inSalary * 1.05; } *newSalaryNullInd = 0; } } /* end of ScalarUDF */