Re: Problem with return type of function ???

From: Denis BUCHER <dbucherml(at)hsolutions(dot)ch>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with return type of function ???
Date: 2009-10-22 13:59:56
Message-ID: 4AE0655C.80400@hsolutions.ch
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello Richard,

Richard Huxton a écrit :
>> I saw somwhere it could be the order of the fields ?
>
> Not if you are doing "SELECT * FROM".
>
> Create an empty test database and a short script to create the table and
> function, insert a couple of rows then call the function. If you wrap
> the whole thing in BEGIN ... ROLLBACK we can change things until we see
> the problem.
>
> The other thing you could try is printing out row before returning it:
> RAISE NOTICE 'row = %', row;
> RETURN NEXT ROW;
> It might be you've not got what you were expecting.

Thanks a lot, good idea...

But it looks good :

> SELECT * FROM rma.test ('19G256259');
> NOTICE: row = (12066602,19G256259,170224,PN6405B,2009-09-22,"FORERUNNER 405 NOIR",2009-09-22,15090,14748)
> ERREUR: wrong record type supplied in RETURN NEXT
> CONTEXTE : PL/pgSQL function "test" line 12 at return next
>
> \d rma.serial_number
> Table « rma.serial_number »
> Colonne | Type | Modificateurs
> -------------+-----------------------+-------------------------------------------------------------------
> sn_id | bigint | not null default nextval('rma.serial_number_sn_id_seq'::regclass)
> sn | character varying(30) |
> no_client | integer |
> no_art_bw | character varying(11) |
> sn_fc_date | date |
> desc_fr | character varying(40) |
> sn_cm_date | date |
> no_facture | integer |
> no_commande | integer |

Denis

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2009-10-22 14:21:41 Re: Problem with return type of function ???
Previous Message Richard Huxton 2009-10-22 13:46:09 Re: Problem with return type of function ???