is it possible to use more than one user-defined aggregate function in
a single SELECT?

I have defined a function uid2int in pltcl to convert a string to an
integer representation.  


CREATE FUNCTION uid2int4 (bpchar) RETURNS int4 AS '
regexp {([A-Z]*)0*([0-9]+)([A-Z]*)} $1 match pre num pst
if {"$pre" == "CE"} {return -$num}
scan $pre "%c" preint
set a [expr $preint - 64]
if {"$pst" != ""} {
  scan $pst "%c" pstint
  set z [expr $pstint - 64]
  set a [expr 100 * $a]
  return [expr $num + ($a+$z) * 10000000]
}
return [expr $num + $a * 10000000]
' LANGUAGE 'pltcl';


The function works fine in the statement 

=> SELECT uid2int(uid),ipd from rhd;

but fails in 

=> SELECT uid2int(uid),uid2int(ipd) from rhd;
ERROR:  pltcl: can't read "pre": no such variable

where both uid and ipd are char(8).

Is there a simple and general way to avoid this problem?

-- 
Karl DeBisschop <[EMAIL PROTECTED]>
617.832.0332 (Fax: 617.956.2696)

Information Please - your source for FREE online reference
http://www.infoplease.com  - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper

Reply via email to