Re: Functions with dynamic queries
От | Gabriel Dovalo Carril |
---|---|
Тема | Re: Functions with dynamic queries |
Дата | |
Msg-id | 3CED7D29.7E55D278@terra.es обсуждение исходный текст |
Ответ на | Re: Functions with dynamic queries (Jeff Eckermann <jeff_eckermann@yahoo.com>) |
Ответы |
Re: Functions with dynamic queries
|
Список | 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 по дате отправления: