Re: Functions with dynamic queries - Mailing list pgsql-sql

From Gabriel Dovalo Carril
Subject Re: Functions with dynamic queries
Date
Msg-id 3CED7D29.7E55D278@terra.es
Whole thread Raw
In response to Re: Functions with dynamic queries  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
Responses Re: Functions with dynamic queries
List pgsql-sql
Jeff Eckermann escribió:
>
> Reminder to self: cast to text _before_
> concatenating(!)
> I won't retype the code, but I hope you get the
> idea...

Yes, I have tried this:

Create Function calc_stocks(text) Returns text AS '
Declare codart ALIAS For $1; all_stocks record; stock text;
Begin
Select sum(stocks.stkreal) as stock1,  sum(stocks.stkpteser) as stock2  into all_stocksFrom stocks, prendasWhere
prendas.codprenda= stocks.codprenda and   prendas.codarticulo = codart; 
stock := (all_stocks.stock1::text ||   all_stocks.stock2::text); Return stock;
End;
' language 'plpgsql';
But now I have got neither error nor
result.

gesyweb=# select calc_stocks('020220064');calc_stocks
-------------
(1
row)
                                 

--
Gabriel D.


pgsql-sql by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: Functions with dynamic queries
Next
From: Gabriel Dovalo Carril
Date:
Subject: Re: Functions with dynamic queries