Re: BUG #3590: Error while in Plpgsql :

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Abdus Samad Ansari" <abdus(dot)samad(dot)ansari(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3590: Error while in Plpgsql :
Date: 2007-08-31 14:00:17
Message-ID: 23219.1188568817@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Abdus Samad Ansari" <abdus(dot)samad(dot)ansari(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ben Kim 2007-08-31 20:13:01 BUG #3591: autovacuum crash
Previous Message Josh Tolley 2007-08-31 13:35:28 Re: to_date gives odd results