From: Constantin Teodorescu <teo@flex.ro>
To: PostgreSQL Interfaces <pgsql-interfaces@postgresql.org>
Subject: Re: What's wrong in this pltcl function?
Date: Mon, 14 Oct 2002 17:19:29 +0300
Message-ID: <3DAAD271.5070702@flex.ro> (raw)
Nigel J. Andrews wrote:
> 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.
>
>
>
>
I just imagined that but the question is why!
Because the spi_exec on the original query without preparing anything
works just fine!
I mean:
spi_exec "select cheie,denumire from conturi where id=\'$cont\'"
seems that there is some problem at specifying the parameter list (or
backsplashing the $ sign)
teo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: teo@flex.ro
Subject: Re: What's wrong in this pltcl function?
In-Reply-To: <3DAAD271.5070702@flex.ro>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox