| From: | Anibal David Acosta <anibal(dot)acosta(at)edge(dot)com(dot)py> | 
|---|---|
| To: | "'Julius Tuskenis'" <julius(at)nsoft(dot)lt>, <pgsql-admin(at)postgresql(dot)org> | 
| Subject: | Re: insert in function writen in pgplsql | 
| Date: | 2010-03-19 15:00:34 | 
| Message-ID: | 000f01cac774$f2d17ef0$d8747cd0$@net.py | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-admin | 
Try
function add_user(_user varchar(20), _password varchar(20))
INSERT INTO my_users(user, password) VALUES (_user, _password);
-----Mensaje original-----
De: pgsql-admin-owner(at)postgresql(dot)org [mailto:pgsql-admin-owner(at)postgresql(dot)org] En nombre de Julius Tuskenis
Enviado el: viernes, 19 de marzo de 2010 09:45 a.m.
Para: pgsql-admin(at)postgresql(dot)org
Asunto: [ADMIN] insert in function writen in pgplsql
Hello
lets say I have a function add_user(user varchar(20), password 
varchar(20)). In its body I want to have statement INSERT INTO 
my_users(user, password) VALUES (user, password); The problem is I cant 
- then I try to create such function I get "ERROR:  syntax error at or 
near "$1"
LINE 1: INSERT INTO my_users(  $1 .... " This tells me the parameter is 
used instead of column name. That is of course not what I wanted. What 
would you recommend to fix this? Is there any way to tell the postgres 
that user is column name? I tried "user" with same error. Must I change 
the names of parameters?
using PG 8.3
-- 
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Szymon Guz | 2010-03-19 17:27:16 | Re: insert in function writen in pgplsql | 
| Previous Message | Guillaume Lelarge | 2010-03-19 14:48:51 | Re: insert in function writen in pgplsql |