Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Tom Lane, 08.04.2010 10:59: Thomas Kellerer writes: CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) RETURNS TABLE(id integer, full_name text) AS $$ BEGIN RETURN QUERY SELECT id, first_name||' '||last_name FROM employee WHERE last_name LIKE name_pattern ||

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Pavel Stehule
2010/4/8 Thomas Kellerer : > Hi, > > I'm playing around with functions returning result sets, and I have a > problem with the following function: > > -- Create sample data > CREATE TABLE employee (id integer, first_name varchar(50), last_name > varchar(50)); > INSERT INTO employee values (1, 'Arthu

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Tom Lane
Thomas Kellerer writes: > CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) > RETURNS TABLE(id integer, full_name text) > AS > $$ > BEGIN >RETURN QUERY > SELECT id, first_name||' '||last_name > FROM employee > WHERE last_name LIKE name_pattern ||'%'; > END > $$ > L

[SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Hi, I'm playing around with functions returning result sets, and I have a problem with the following function: -- Create sample data CREATE TABLE employee (id integer, first_name varchar(50), last_name varchar(50)); INSERT INTO employee values (1, 'Arthur', 'Dent'); INSERT INTO employee values

Re: [SQL] Problem with function and trigger...

2005-09-28 Thread Ian Meyer
On 9/28/05, Tom Lane <[EMAIL PROTECTED]> wrote: > Ian Meyer <[EMAIL PROTECTED]> writes: > > IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN > > > ERROR: record "old" is not assigned yet > > DETAIL: The tuple structure of a not-yet-assigned record is indeterminate. > > CONTEXT: PL/pgSQL functi

Re: [SQL] Problem with function and trigger...

2005-09-28 Thread Tom Lane
Ian Meyer <[EMAIL PROTECTED]> writes: > IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN > ERROR: record "old" is not assigned yet > DETAIL: The tuple structure of a not-yet-assigned record is indeterminate. > CONTEXT: PL/pgSQL function "thread_sync" line 2 at if > What am I failing to under

[SQL] Problem with function and trigger...

2005-09-28 Thread Ian Meyer
I have a function declared as such: CREATE OR REPLACE FUNCTION thread_sync() RETURNS trigger AS $$ BEGIN IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN UPDATE member SET total_threads=total_threads-1 WHERE id=OLD.member_id; RETURN OLD; ELSEIF TG_OP = 'INSERT' THEN UPDATE member S

[SQL] problem with function trigger

2004-01-18 Thread jclaudio
Hi I'm trying to update a table column with a pl/pgsql function and a trigger. But I didn't managed to make it work so far. Here's my  function code : CREATE FUNCTION public.calcul_impact() RETURNS opaque AS ' DECLARE id_line integer; quantity integer; single_price real; total_cost real; am

Re: [SQL] problem with function trigger

2004-01-16 Thread Christoph Haller
> > Hi I'm trying to update a table column with a pl/pgsql function and a > trigger. > But I didn't managed to make it work so far. > > Here's my function code : > > CREATE FUNCTION public.calcul_impact() RETURNS opaque AS ' > > DECLARE > id_line integer; > quantity integer; > single_price

[SQL] problem with function trigger

2004-01-13 Thread jclaudio
Hi I'm trying to update a table column with a pl/pgsql function and a trigger. But I didn't managed to make it work so far. Here's my  function code : CREATE FUNCTION public.calcul_impact() RETURNS opaque AS ' DECLARE id_line integer; quantity integer; single_price real; total_cost real; a

Re: [SQL] Problem with function & trigger

2001-07-09 Thread Carlo Vitolo
Tom Lane wrote: > Carlo Vitolo <[EMAIL PROTECTED]> writes: > > This does not work. The error is ERROR: pg_atoi: error in "12.00": can't > > parse ".00" > > What PG version are you running? It seems to work fine for me in > current sources: > > Ver. 7.1.2 > > BTW, the way you are writing the fu

Re: [SQL] Problem with function & trigger

2001-07-07 Thread Tom Lane
Carlo Vitolo <[EMAIL PROTECTED]> writes: > This does not work. The error is ERROR: pg_atoi: error in "12.00": can't > parse ".00" What PG version are you running? It seems to work fine for me in current sources: regression=# create table magazzino (quantita numeric(10,2), regression(# descrizio

[SQL] Problem with function & trigger

2001-07-07 Thread Carlo Vitolo
This does not work. The error is ERROR: pg_atoi: error in "12.00": can't parse ".00" CREATE FUNCTION "togliscar" () RETURNS opaque AS 'BEGIN UPDATE magazzino SET quantita = (SELECT quantita FROM magazzino WHERE descrizione = NEW.descrizione ) - NEW.quantita WHERE descrizione = NEW.descrizione; RE

Re: [SQL] Problem with function...

2000-12-18 Thread Jie Liang
Hi, there, modify the code as following. Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.ipinc.com On Mon, 18 Dec 2000 [EMAIL PROTECTED] wrote: > Hi, > > I hope my question is appropriate for this list.

Re: [SQL] Problem with function...

2000-12-18 Thread Michael Fork
I don't think you return should have '' around them, i.e. RETURN distance; Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Mon, 18 Dec 2000 [EMAIL PROTECTED] wrote: > Hi, > > I hope my question is appropriate for this list. I'm trying to create > a fu

[SQL] Problem with function...

2000-12-18 Thread jkakar
Hi, I hope my question is appropriate for this list. I'm trying to create a function that calculates the distance between a pair of latitude/longitude points. This is what I have: /* latlon_distance.pgsql * by Jamu Kakar <[EMAIL PROTECTED]>, Dec 18, 2000. * * Calculates the distance between