Hi everybody,
altough I know that the way over a Trigger is preferred, I can't see what is wrong in my
function. It must be an escaping error:
CREATE OR REPLACE FUNCTION
user_insert_vector_data(text,text,text,numeric,numeric,numeric,text)
RETURNS void AS
$$
DECLARE
art_nr ALIAS for $1;
bezeichnung ALIAS FOR $2;
beschreibung ALIAS FOR $3;
preis ALIAS FOR $4;
steuersatz ALIAS FOR $5;
aktionspreis ALIAS FOR $6;
stichworte ALIAS for $7;
vect tsvector;
BEGIN
vect := setweight(to_tsvector('german',coalesce(stichworte,'')),'A') ||
setweight(to_tsvector('german',coalesce(beschreibung,'')),'B');
EXECUTE 'INSERT INTO produkte
(art_nr,bezeichnung,beschreibung,preis,steuersatz,aktionspreis,stichworte,vector)
VALUES
('''||art_nr||''','''||bezeichnung||''','''||beschreibung||''','||preis||',
'||steuersatz||','||aktionspreis||','''||stichworte||''','||vect||')';
END;
$$ LANGUAGE plpgsql;
Firering this statement:
select user_insert_vector_data('adfvb','adfvb','adfvb',15.5,25.50,2,'alpha,beta,cesar');
results in this error:
FEHLER: Syntaxfehler bei »:«
LINE 3: ... 25.50,2,'alpha,beta,cesar','beta':2A 'adfvb...
^
QUERY: INSERT INTO produkte
(art_nr,bezeichnung,beschreibung,preis,steuersatz,aktionspreis,stichworte,vector)
VALUES ('adfvb','adfvb','adfvb',15.5,
25.50,2,'alpha,beta,cesar','beta':2A 'adfvb':4B 'alpha':1A 'cesar':3A)
CONTEXT: PL/pgSQL function "user_insert_vector_data" line 14 at EXECUTE statement
vector is of datatype tsvector. So I don't understand why pg is complaining ...
Thank's for any hints and sorry for annoying if I am too blind ...
Cheers
Andy
----------------------------------
Netzmeister St.Pauli
St.Pauli - Hamburg - Germany
Andreas Wenk
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general