我正在将存储过程从SQL Server迁移到PostgreSQL。我已将存储过程转换为Postgres函数。
SQL Server存储过程:
$(document).ready(function(){
var purpleBackgroundCss = {"background-color": "purple"};
$(".classname").closest('div').css(purpleBackgroundCss).children('div').css(purpleBackgroundCss);
});
Postgres功能:
CREATE PROCEDURE AddFullSig @CandID int, @FullSig binary(16)
AS
if not exists (select pub_id
from local_lib
where cand_id = @CandID and Full_sig = @FullSig)
insert into local_lib
values(@CandID, 1, @FullSig)
else
update local_lib
set dup_count = dup_count + 1
where cand_id = @CandID
and Full_sig = @FullSig
select pub_id
from local_lib
where cand_id = @CandID and Full_sig = @FullSig
RETURN
当我尝试使用:
在pgadmin中测试时create type addfullsig_return_type as(
pub_id int
);
create or replace function addfullsig( p_candid int, p_fullsig bytea)
returns addfullsig_return_type as $$
begin
if not exists(select pub_id from local_lib where cand_id = p_candid and full_sig = p_fullsig) then
insert into local_lib values(default, p_candid, 1, p_fullsig);
else
update local_lib set dup_count = dup_count + 1 where cand_id = p_candid and full_sig = p_fullsig;
end if;
select pub_id from local_lib where
cand_id = p_candid and full_sig = p_fullsig;
end;
$$ language plpgsql;
我收到错误:
错误:函数addfullsig(整数,bigint)不存在
我不确定我对postgresql的转换是否正确,特别是在使用bytea for binary(16)而不是bit(16)时。任何帮助或见解将不胜感激。
答案 0 :(得分:2)