Re: error using pl/pgsql? [possibly off topic]

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Johnny Jørgensen" <pgsql(at)halfahead(dot)dk>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: error using pl/pgsql? [possibly off topic]
Date: 2001-11-23 18:58:37
Message-ID: 20011123105130.F84165-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-11-23 19:00:14 Re: Classes (Object Oriented) in PostgreSQL question
Previous Message Chris McCormick 2001-11-23 18:02:54 [HOSTING QUESTION] - Advice on a decent PostgreSQL host?