Re: error using pl/pgsql? [possibly off topic] - Mailing list pgsql-general

From Johnny J\xF8rgensen
Subject Re: error using pl/pgsql? [possibly off topic]
Date
Msg-id 200111261303200653.00E57773@mail.halfahead.dk
Whole thread Raw
In response to Re: error using pl/pgsql? [possibly off topic]  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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
textwould 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,
itall makes sense :) 

- regards,

*********** REPLY SEPARATOR  ***********

On 23-11-2001 at 10:58 Stephan Szabo wrote:

>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';


Johnny J�rgensen

johnny@halfahead.dk
+45 6315 7328


pgsql-general by date:

Previous
From: "Mourad EL HADJ MIMOUNE"
Date:
Subject: Use of cursor in PLPGSQL function
Next
From: "Campano, Troy"
Date:
Subject: DDL Exports w/ quotes?