这是我的表
CREATE TABLE pago
(
codigo serial NOT NULL,
codigocaja integer NOT NULL,
codigotarjeta integer,
codigocheque integer,
formapago character varying(1) NOT NULL,
tipocomp character varying(1) NOT NULL,
importetotal money NOT NULL,
fecha date NOT NULL,
codigoalumno integer NOT NULL,
codigodeposito integer,
vigencia boolean NOT NULL DEFAULT true,
descripcion character varying(200),
CONSTRAINT "PK_CodigoPago" PRIMARY KEY (codigo),
CONSTRAINT "FK_CodigoAlumno" FOREIGN KEY (codigoalumno)
REFERENCES alumno (codigoalumno) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_CodigoCaja" FOREIGN KEY (codigocaja)
REFERENCES caja (codigo) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_CodigoCheque" FOREIGN KEY (codigocheque)
REFERENCES cheque (codigo) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_CodigoDeposito" FOREIGN KEY (codigodeposito)
REFERENCES deposito (codigo) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "FK_CodigoTarjeta" FOREIGN KEY (codigotarjeta)
REFERENCES tarjeta (codigo) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "UN_CodigoPago" UNIQUE (codigo)
)
WITH (
OIDS=FALSE
);
ALTER TABLE pago
OWNER TO postgres;
这是我添加新行的功能
CREATE OR REPLACE FUNCTION fn_inspagar(vcodcaja integer, vcodtarjeta integer, vcodcheque integer, vformapago character varying, vtipocomp character varying,vimporte money ,vfecha date, vcodal integer, vcoddeposito integer,vdesc character varying)
RETURNS void AS
$BODY$
begin
INSERT INTO pago(codigocaja,codigotarjeta,codigocheque,formapago,tipocomp,importetotal,fecha,codigoalumno,codigodeposito,descripcion)
VALUES (vcodcaja,vcodtarjeta,vcodcheque,vformapago,vtipocomp,vimporte,vfecha,vcodal,vcoddeposito,vdesc);
end;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
当我执行这样的功能时
select * from fn_inspagar(1,2,null,'T','B',200,'2013-01-01',196,0,'matricula')
因此我有以下
错误:没有存在fn_inspagar(整数,整数,整数,未知,未知,整数,未知,整数,整数,未知)
答案 0 :(得分:2)
因为money类型不是'普通转换',所以在调用函数时需要将示例中的200值转换为money
(否则PostgreSQL优先考虑整数转换)。
工作示例:
select * from fn_inspagar(1,2, null, 'T', 'B',CAST ( 200 as money) , '2013-01-01' ,196,0, 'matricula')
看看这里获取有关PostgreSQL如何处理函数签名的更多信息: