Re: plpgsql function errors

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Juan Casero (FL FLC)" <Juan(dot)Casero(at)wholefoods(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql function errors
Date: 2005-02-04 18:06:18
Message-ID: 20050204180617.GD14840@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Feb 04, 2005 at 11:40:50AM -0600, Juan Casero (FL FLC) wrote:
> Hi Everyone -
>
> I am new to this list and although I have been using postgresql on and
> off for about a year now. I am trying to develop a webapp using perl
> and cgi with postgresql 7.4.6 as a backend database. One of the things
> I need is to create a transactions table that will record a row of data
> and then return the transaction id to the caller. I have decided to
> implement this piece of the webapp as a stored procedure in pl/pgsql.
> The following is the source code...

Firstly, I think you should look up the documentation for nextval(),
currval(). There is no possiblity of returning the wrong value even if
another transaction is running concurrently. And you don't need to lock
the table, which is good for performance.

<snip>

> # select
> trx_id(JUANCASERO3055128218,CREDIT,02/02/05,1,1,Aventura,02/01/05,Tom);
>
> I get the following error message
>
> ERROR: column "juancasero3055128218" does not exist

You need to put those values into strings. Unless you do that it thinks
you're referring to a column named that. Try:

select trx_id('JUANCASERO3055128218','CREDIT','02/02/05',1,1,'Aventura','02/01/05','Tom');

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-02-04 18:15:03 Re: Binding of "AS" vis "JOIN"
Previous Message Michael Fuhr 2005-02-04 18:05:41 Re: Questions about functionality