From: | "Ian Harding" <ianh(at)co(dot)pierce(dot)wa(dot)us> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | pltcl question |
Date: | 2001-05-08 18:48:00 |
Message-ID: | saf7dd2a.028@emgateways.co.pierce.wa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Can someone who is familiar with pltcl take a look at the following and suggest why it gives me the oh-so-familiar
Error: ERROR: pltcl: wrong # args: should be "set varName ?newValue?"
I am calling it with
select vsp_insertplanitem(0, char(10) 'iah', 0, 0, varchar(150) 'my cool planitem', varchar(250) 'my cool description', date '01/01/01', date '12/31/01', char(10) '12345', 0, varchar(250) '', 0, varchar(50) '', varchar(50) '', 2001) as result
Here is the function.
CREATE function vsp_insertplanitem(int, char(10), int, int, varchar(150), varchar(250), date, date, char(10), int, varchar(250), int, varchar(50), varchar(50), int) returns int as '
set ISBM "$1"
set CREATEDBYID "$2"
set PLANLEVEL "$3"
set PARENTID "$4"
set PLANITEMNAME "$5"
set PLANITEMDESC "$6"
set EST_START_DATE "$7"
set EST_COMPL_DATE "$8"
set CHAMPIONID "$9"
set PRECURSORID "$10"
set DESIRED_OUTCOME "$11"
set MEASURABLE_RESULT "$12"
set MEASURABLE_RESULT_UNITS "$13"
set NEW_MEASURABLE_RESULT_UNITS "$14"
set PLANYEAR "$15"
set ERROR 0
set PLANITEMID 0
/* Check for overlap with the current plan year */
set sqlString "select overlaps(cast(''$EST_START_DATE'' as date), ";
append sqlString "cast(''$EST_COMPL_DATE'' as date), ";
append sqlString "cast(''01/01/$PLANYEAR'' as date), ";
append sqlString "cast(''12/31/$PLANYEAR'' as date)) as inYear";
elog NOTICE $sqlString;
spi_exec "$sqlString";
if {[string match False $inYear]} {
set errorMsg "This item does not have any effectivity in "
append errorMsg "the current plan year. Check the dates and "
append errorMsg "ensure they fall at least partly in the plan year."
elog "ERROR" $errorMsg
return 0
}
/* Do the PlanItem insert */
spi_exec "INSERT INTO PlanItems (CREATEDBYID,\
PLANLEVEL, PARENTID, PLANITEMNAME, PLANITEMDESC, EST_START_DATE,\
EST_COMPL_DATE, CHAMPIONID, PRECURSORID) VALUES (''$CREATEDBYID'',\
$PLANLEVEL, $PARENTID, ''$PLANITEMNAME'', ''$PLANITEMDESC'', ''$EST_START_DATE'',\
''$EST_COMPL_DATE'', ''$CHAMPIONID'', $PRECURSORID)"
/* If this is a benchmark, find out the plan item id we just created */
if {[string match 1 $ISBM]} {
spi_exec "select currval(planitems_planitemid_seq) as PLANITEMID"
/* If there is a new OutcomeCode let''s insert it first so we don''t
* violate data integrity */
if {[string length $NEW_MEASURABLE_RESULT_UNITS]!=0} {
set sqlString "insert into outcomeunits (UNITSCODE, CREATEDBYID) values "
append sqlString "(''$NEW_MEASURABLE_RESULT_UNITS'', ''$CREATEDBYID'')"
spi_exec "$sqlString"
set MEASURABLE_RESULT_UNITS "$NEW_MEASURABLE_RESULT_UNITS"
}
/* Do the Outcomes insert */
set sqlString "INSERT INTO Outcomes (PLANITEMID, DESIRED_OUTCOME, MEASURABLE_RESULT, "
append sqlString "MEASURABLE_RESULT_UNITS) VALUES ($PLANITEMID, ''$DESIRED_OUTCOME'', "
append sqlString "''$MEASURABLE_RESULT'', ''$MEASURABLE_RESULT_UNITS'')"
spi_exec "$sqlString"
}
return 1
' language 'pltcl';
Thank you in advance...
Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: ianh(at)tpchd(dot)org
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-05-08 18:54:01 | Re: DBD::Pg errstr method doesn't return full error messages |
Previous Message | Roger Wernersson | 2001-05-08 18:33:47 | Re: pg_restore problems? |