On Fri, 23 Nov 2001, [ISO-8859-1] "Johnny J�rgensen" wrote:
A few notes **ed below.
> CREATE FUNCTION new_order(text,text)
> RETURNS text
> AS '
> DECLARE
> p_id ALIAS FOR $1;
> p_date ALIAS FOR $2;
> ret_val text;
> BEGIN
> BEGIN WORK;
** can't put transaction statements in I think to start.
** Take out the begin work and commit work.
> INSERT INTO ordre (person_id,placement_date,status) VALUES (p_id::int4,p_date::decimal,1);
** I don't think there's a text->decimal conversion defined. Why is the
** parameter defined as text anyway?
> SELECT currval(ordre_id_seq::text) INTO ret_val;
** I think you really want ''ordre_id_eq'' since otherwise
** its looking for a parameter or column name,
** and do you really want this back as text rather than
** the integer type currval normally returns?
> COMMIT WORK;
> RETURN ret_val;
> END;
> '
> LANGUAGE 'plpgsql';