From: | "Johnny Jrgensen" <pgsql(at)halfahead(dot)dk> |
---|---|
To: | "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: error using pl/pgsql? [possibly off topic] |
Date: | 2001-11-26 12:03:20 |
Message-ID: | 200111261303200653.00E57773@mail.halfahead.dk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you,
you were right, transactions can't be inside functions (Docs paragraph 24.2.1. Structure of PL/pgSQL),
concerning the input/output, it's coming in from PHP (from forms) , and for safety's sake, all form input is quoted, so text would be better.
I could return whatever, PHP will typecast anyway, but text in -- text out seemed consistent :)
Anyways, i'm not entirely sure how my input is handled, but when i remove all typecasting, as well as the transactions, it all makes sense :)
- regards,
*********** REPLY SEPARATOR ***********
On 23-11-2001 at 10:58 Stephan Szabo wrote:
>On Fri, 23 Nov 2001, [ISO-8859-1] "Johnny Jrgensen" 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';
Johnny Jrgensen
johnny(at)halfahead(dot)dk
+45 6315 7328
From | Date | Subject | |
---|---|---|---|
Next Message | Mourad EL HADJ MIMOUNE | 2001-11-26 12:05:10 | Use of cursor in PLPGSQL function |
Previous Message | Tommi Mäkitalo | 2001-11-26 10:04:21 | Re: anyone knows about pam_pgsql ? |