Home
The Toolkit for Online Communities
15887 Community Members, 0 members online, 2071 visitors today
Log In Register

Forum OpenACS Q&A: Response to how do you call one pltcl function from another?

OpenACS Home : Forums : OpenACS Q&A : Response to how do you call one pltcl function from another? : One Message

The point is that with CREATE FUNCTION you're creating a function in SQL context, and not in Tcl's.

To use your newly created function written in pltcl (or written in any other PG scripting language) from within pltcl you'll have to resort to query execution procs, like spi_exec and friends:

CREATE FUNCTION foo (varchar) RETURNS varchar AS '
   spi_exec "select meta_class(''[quote $1]'') as ret_value"
   return $ret_value
' LANGUAGE 'pltcl';
Note that since meta_class expects varchar you'll need to enclose its argument in single quotes and escape any single quote contained within its argument appropriately.