Re: What's wrong in this pltcl function ?

Поиск
Список
Период
Сортировка
От Nigel J. Andrews
Тема Re: What's wrong in this pltcl function ?
Дата
Msg-id Pine.LNX.4.21.0210141506580.584-100000@ponder.fairway2k.co.uk
обсуждение исходный текст
Ответ на What's wrong in this pltcl function ?  (Constantin Teodorescu <teo@flex.ro>)
Список pgsql-interfaces
On Mon, 14 Oct 2002, Constantin Teodorescu wrote:

> create function ruldeb(bpchar) returns bpchar as '
>     set cont $1
>     set rulaj 0.0
>     spi_exec -array rec "select valoare from valori where debitor LIKE 
> \'$cont%\'" {
>         set rulaj [expr {$rulaj + $rec(valoare)}]
>     }
>     if {![info exists GD(conturi_lookup)]} {
>         set GD(conturi_lookup) [spi_prepare "select cheie,denumire from 
> conturi where id=\'\\$1\'" [list bpchar]]
>     }
>     spi_execp -count 1 $GD(conturi_lookup) [list $cont]
>     return "{$cheie} {$denumire} $rulaj"
> ' LANGUAGE 'pltcl';
> 
> 
> is giving the following error:
> 
> ERROR:  pltcl: can't read "cheie": no such variable
> can't read "cheie": no such variable
>     while executing
> "return "{$cheie} {$denumire} $rulaj""
>     (procedure "__PLTcl_proc_1759991" line 12)
>     invoked from within
> "__PLTcl_proc_1759991 4:0:1:1:2:"


Looks like your prepared query is not finding any matching tuples.

If a query returns 0 tuples then all column variables will be undefined.
Undefined because if you set them before then they will not be unset. This
differs from the case where a tuple has been returned by the query but a
column's value is NULL. In this case the TCL variable is unset.


-- 
Nigel J. Andrews



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Constantin Teodorescu
Дата:
Сообщение: What's wrong in this pltcl function ?
Следующее
От: Constantin Teodorescu
Дата:
Сообщение: Re: What's wrong in this pltcl function?