Re: BUG #3590: Error while in Plpgsql : - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #3590: Error while in Plpgsql :
Date
Msg-id 23219.1188568817@sss.pgh.pa.us
Whole thread Raw
In response to BUG #3590: Error while in Plpgsql :  ("Abdus Samad Ansari" <abdus.samad.ansari@gmail.com>)
List pgsql-bugs
"Abdus Samad Ansari" <abdus.samad.ansari@gmail.com> writes:
> I am using a plpgsql function and in this I am issuing a insert as :
> Insert into pis.hrt_emp_leave_bin
> (emp_no,leave_cd,curr_dt,bin_sl_no,cal_yr,tran_typ,open_bal,ytd_availed,avai
> led) values (EmployeeNumber, LeaveCode, CurrentDate,
> Bin_Serial_No,to_number(to_char(CurrentDate,''YYYY''),''9999''),''CM'',
> OpenBal,YtdAvailed+LeaveVal,LeaveVal);

> This insert statement while run give an error message :
> ERROR:  syntax error at or near "$1" at character 35

This probably means that one of the field names in the statement (if I
counted characters right, probably "emp_no") is the same as the name of
one of the plpgsql variables in the function.  You need to change the
variables to not conflict with any of the table or field names you need
to reference in the queries of that function, because plpgsql is not
very bright about telling when it should substitute and when it should
not.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Josh Tolley"
Date:
Subject: Re: to_date gives odd results
Next
From: "Ben Kim"
Date:
Subject: BUG #3591: autovacuum crash