Thread: insert within pl/pgsql procedures: NOVICE question ?
Hi list, tedious experience: am I wrong or the optionnal syntax INSERT INTO foo(foo_col1) VALUES ('blahblah'); dosen't work within a PLPGSQL-written function ? I (quickly) checked the idocs and didn't found anything about that... so, amazing discovery or stupid question ? Regards, Jeff. ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.fr
You have not given us any information regarding table type or error message that you are getting from the running of the function. If you provide this information then we might be able to help Darren On Wed, 13 Feb 2002, [iso-8859-1] Jeff Anto wrote: > Hi list, > > tedious experience: > am I wrong or the optionnal syntax > INSERT INTO foo(foo_col1) VALUES ('blahblah'); > dosen't work within a PLPGSQL-written function ? > > I (quickly) checked the idocs and didn't found > anything about that... so, amazing discovery or stupid > question ? > > Regards, > Jeff. > > ___________________________________________________________ > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran�ais ! > Yahoo! Mail : http://fr.mail.yahoo.fr > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >
=?iso-8859-1?q?Jeff=20Anto?= <antojf2001@yahoo.fr> writes: > am I wrong or the optionnal syntax > INSERT INTO foo(foo_col1) VALUES ('blahblah'); > dosen't work within a PLPGSQL-written function ? Works for me: regression=# create table foo(foo_col1 text); CREATE regression=# INSERT INTO foo(foo_col1) VALUES ('blahblah'); INSERT 1918283 1 regression=# create function doit(text) returns int as ' regression'# begin regression'# INSERT INTO foo(foo_col1) VALUES ($1); regression'# return 1; regression'# end' language plpgsql; CREATE regression=# select doit('zzz'); doit ------ 1 (1 row) regression=# select * from foo; foo_col1 ---------- blahblah zzz (2 rows) regression=# What are you doing differently? regards, tom lane
On Wed, 13 Feb 2002, [iso-8859-1] Jeff Anto wrote: > Hi list, > > tedious experience: > am I wrong or the optionnal syntax > INSERT INTO foo(foo_col1) VALUES ('blahblah'); > dosen't work within a PLPGSQL-written function ? It should, barring that you need to escape ' characters inside plpgsql function declarations.
Well... First, it was a trigger procedure, Second, I used to get an ERROR: parser: parse error at or near "$1" when triggered BUT: I didn't succesfully create a simpler counter-example... So I guess there is something wrong I cannot see in my code "-{ and I apologize for that prematured question. Jeff. --- Darren Ferguson <darren@crystalballinc.com> a écrit : > You have not given us any information regarding > table type or error > message that you are getting from the running of the > function. > > If you provide this information then we might be > able to help > > Darren > > On Wed, 13 Feb 2002, [iso-8859-1] Jeff Anto wrote: > > > Hi list, > > > > tedious experience: > > am I wrong or the optionnal syntax > > INSERT INTO foo(foo_col1) VALUES ('blahblah'); > > dosen't work within a PLPGSQL-written function ? > > > > I (quickly) checked the idocs and didn't found > > anything about that... so, amazing discovery or > stupid > > question ? > > > > Regards, > > Jeff. > > > > > ___________________________________________________________ > > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite > et en français ! > > Yahoo! Mail : http://fr.mail.yahoo.fr > > > > ---------------------------(end of > broadcast)--------------------------- > > TIP 3: if posting/reading through Usenet, please > send an appropriate > > subscribe-nomail command to > majordomo@postgresql.org so that your > > message can get through to the mailing list > cleanly > > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.fr