| From: | Gabriel Dovalo Carril <dovalo(at)terra(dot)es> | 
|---|---|
| To: | Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> | 
| Cc: | Lista SQL de postgres <pgsql-sql(at)postgresql(dot)org> | 
| Subject: | Re: Functions with dynamic queries | 
| Date: | 2002-05-23 23:37:13 | 
| Message-ID: | 3CED7D29.7E55D278@terra.es | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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_stocks
 From stocks, prendas
 Where 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gabriel Dovalo Carril | 2002-05-24 08:24:10 | Re: Functions with dynamic queries | 
| Previous Message | Jeff Eckermann | 2002-05-23 22:43:20 | Re: Functions with dynamic queries |