Skip site navigation (1) Skip section navigation (2)

insert in function writen in pgplsql

From: Julius Tuskenis <julius(at)nsoft(dot)lt>
To: pgsql-admin(at)postgresql(dot)org
Subject: insert in function writen in pgplsql
Date: 2010-03-19 13:45:25
Message-ID: 4BA37FF5.8060001@nsoft.lt (view raw or flat)
Thread:
Lists: pgsql-admin
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


Responses

pgsql-admin by date

Next:From: Guillaume LelargeDate: 2010-03-19 14:20:35
Subject: Re: insert in function writen in pgplsql
Previous:From: Tom LaneDate: 2010-03-19 12:33:27
Subject: Re: operator does not exist

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group