%indnzpm;
%let indconn = server=netezbase user=user1 password=open1 database=mydb;
%indnz_publish_model(dir=C:\SASIN\baseball1, modelname=baseball1);
This sequence
of macros generates a separate .c file for each output parameter of
interest. Each output stub calls into a shared scoring main which
is compiled first. The %INDNZ_PUBLISH_MODEL macro also produces a
text file of Netezza CREATE FUNCTION commands as shown in the following
example.
Note: This example
file is shown for illustrative purposes. The text file that is created
by the %INDNZ_PUBLISH_MODEL macro cannot be viewed and is deleted
after the macro is complete.
CREATE FUNCTION baseball1_EM_eventprobablility
(
"CR_ATBAT" float,
"CR_BB" float,
"CR_HITS" float,
"CR_HOME" float,
"CR_RBI" float,
"CR_RUNS" float,
"DIVISION" varchar(31),
"LEAGUE" varchar(31),
"NO_ASSTS" float,
"NO_ATBAT" float,
"NO_BB" float,
"NO_ERROR" float,
"NO_HITS" float,
"NO_HOME" float,
"NO_OUTS" float,
"NO_RBI" float,
"NO_RUNS" float,
"YR_MAJOR" float
)
RETURNS float
LANGUAGE CPP
PARAMETER STYLE npsgeneric
CALLED ON NULL INPUT
EXTERNAL CLASS NAME 'Cbaseball1_em_eventprobability'
EXTERNAL HOST OBJECT '/tmp/tempdir_20090506T113450_316550/baseball1.o_x86'
EXTERNAL NSPU OBJECT '/tmp/tempdir_20090506T113450_316550/baseball1.o_diab_ppc';
DEPENDENCIES dbjazlib..sas_jazlib /* if TwinFin system */
After
the scoring functions are installed, they can be invoked in Netezza
using SQL, as illustrated in the following example. Each output value
is created as a separate function call in the select list.
select baseball1_EM_eventprobability
(
"CR_ATBAT",
"CR_BB",
"CR_HITS",
"CR_HOME",
"CR_RBI",
"CR_RUNS",
"DIVISION",
"LEAGUE",
"NO_ASSTS",
"NO_ATBAT",
"NO_BB",
"NO_ERROR",
"NO_HITS",
"NO_HOME",
"NO_OUTS"
) as homeRunProb from MLBNetz;