Linux 上的 PostgreSQL 8.4。我有一个功能:
CREATE OR REPLACE FUNCTION production.add_customer (
name varchar(100),
email_address varchar(300),
street_address text,
city varchar(50),
state varchar(2),
zip varchar(10),
secret1 bytea,
secret2 bytea,
secret3 bytea,
secret4 bytea,
referrer text)
RETURNS integer as $$
BEGIN
INSERT INTO customers (name, email_address, street_address, city, state, zip, secret1, secret2, secret3, secret4, create_date, referrer) VALUES
(name, email_address, street_address, city, state, zip, create_date, referrer
pgp_sym_encrypt(secret1, 'reallylongrandomstring'),
pgp_sym_encrypt(secret2, 'reallylongrandomstring'),
pgp_sym_encrypt(secret3, 'reallylongrandomstring'),
pgp_sym_encrypt(secret4, 'reallylongrandomstring'),
current_timestamp, referrer);
RETURNING customer_id;
END;
$$ LANGUAGE plpgsql;
当我尝试创建它时返回此错误:
ERROR: syntax error at or near "$1"
LINE 1: INSERT INTO customers ( $1 , $2 , $3 , $4 , $5 , $6 , ...
^
QUERY: INSERT INTO customers ( $1 , $2 , $3 , $4 , $5 , $6 , $7 , $8 , $9 , $10 , create_date, $11 ) VALUES ( $1 , $2 , $3 , $4 , $5 , $6 , create_date, $11 pgp_sym_encrypt( $7 , 'reallylongrandomstring'), pgp_sym_encrypt( $8 , 'reallylongrandomstring'), pgp_sym_encrypt( $9 , 'reallylongrandomstring'), pgp_sym_encrypt( $10 , 'reallylongrandomstring'), current_timestamp, $11 )
CONTEXT: SQL statement in PL/PgSQL function "add_customer" near line 8
myserver=#
我试过了ALIAS FOR
,没有运气。想法?