From: | Jan Wieck <janwieck(at)Yahoo(dot)com> |
---|---|
To: | Jonathan Ellis <jellis(at)advocast(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how do you call one pltcl function from another? |
Date: | 2000-11-08 09:56:46 |
Message-ID: | 200011080956.EAA07041@jupiter.jw.home |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Jonathan Ellis wrote:
> I tried mailing this last week, but I think it didn't get sent:
>
> I defined a procedure
>
> CREATE FUNCTION meta_class (varchar) RETURNS varchar AS '
> ...
> ' LANGUAGE 'pltcl';
>
> This works fine. But when I want to call it from another tcl procedure I
> get errors:
> bf2=# CREATE FUNCTION foo (varchar) RETURNS varchar AS '
> return [meta_class $1]
> ' LANGUAGE 'pltcl';
>
> bf2'# bf2'# CREATE
>
> bf2=# bf2=# select foo(class) from weapon_Types;
> ERROR: pltcl: invalid command name "meta_class"
>
> This IS possible -- isn't it?
It is. The problem is that the internal name of the proc in
the Tcl interpreter doesn't have to do with the function
name. Due to possible function overloading (multiple
functions with same name but different arguments) this is
impossible.
You need to call it via SPI like
spi_exec "select meta_class($1) as retval"
return $retval
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
From | Date | Subject | |
---|---|---|---|
Next Message | Michaël Fiey | 2000-11-08 10:05:50 | Re: PGBUFFERS |
Previous Message | shawn everett | 2000-11-08 06:29:01 | Selecting Random Records |