CREATE FUNCTION out(integer) RETURNS varchar AS 'select no from testcode where id =$1' LANGUAGE 'sql';用PL/psql 过程语言吧!功能很强的 CREATE FUNCTION out(integer) RETURNS varchar AS 'select no from testcode where id =$1' LANGUAGE 'plsql';
我没有用过 plsql,而且postgresql只支持c,internal,sql不直接支持plsql(好像需要导入才能够用);关于: CREATE FUNCTION out(integer) RETURNS varchar AS 'select no from testcode where id =$1' LANGUAGE 'sql'; 报了一个:Unable to idenfity an operator '=$' for types 'integer' and 'integer' you will have to retype this query using an explicit cast 错误,说我类型转换有问题,但是我的id 和 no的确都是int型的
看看postgresql得文档,给你的数据库安装plsql的语言,就可以使用了 createlang plpgsql databaseName, 好像这样就没有问题了,当然了,别忘了最后的语言一定是要选择 LANGUAGE 'plpgsql';
CREATE FUNCTION out(integer) RETURNS varchar AS 'select no from testcode where id =$1' LANGUAGE 'sql';
报了一个:Unable to idenfity an operator '=$' for types 'integer' and 'integer' you will have to retype this query using an explicit cast
错误,说我类型转换有问题,但是我的id 和 no的确都是int型的
createlang plpgsql databaseName, 好像这样就没有问题了,当然了,别忘了最后的语言一定是要选择 LANGUAGE 'plpgsql';