在Postgres存储过程/函数中获取错误

时间:2019-03-15 13:41:27

标签: postgresql

CREATE OR REPLACE function spInsertReleaseSheet (
p_RedlineNo int,
p_RedlineDesc varchar(500),
p_ParentRedlineId int,
p_CategoryId int,
p_ChangeTypeId int,
p_ObjectName varchar(500),
p_DeployInfo int,
p_Notes varchar(500),
p_CodeReview int,
p_Env int,
p_TechId varchar(500),
p_CreatedBy varchar(50),
p_DeployStatus varchar(50),
p_ReleaseCodeStatus int) 

RETURNS VOID as $$

DECLARE v_redlineid int;
DECLARE v_objectid int;
Begin


if(COALESCE(p_CreatedBy,'')='')
then
    p_CreatedBy:='Suresh';
end if;

if(COALESCE(p_DeployStatus,'')='')
then
    p_DeployStatus:='TBD';
end if;
BEGIN
--LOOP
    START TRANSACTION;
    IF EXISTS (SELECT  "RedlineNumber" from public."Redline"  where RedlineNumber=p_RedlineNo LIMIT 1)
            Then
                select  "RedlineId" into v_redlineid from public."Redline" where RedlineNumber=p_RedlineNo LIMIT 1;
            else
                insert into Redline(RedlineNumber,ParentRedlineId,RedlineDesc,CreatedDate,CreatedBy)
                Select p_RedlineNo,p_ParentRedlineId,p_RedlineDesc,now(),p_CreatedBy

             RETURNING Redline into  v_redlineid;
            end if;

        insert into Objects(CategoryId,Name) 
        Select p_CategoryId,p_ObjectName
        RETURNING Redline into v_objectid;


        insert into ObjectImplementation(RedlineId,CodeReviewStatusId,ChangeTypeId,Instructions,ObjectId,Notes,DeploymentStatus,EnvironmentId,TechReqId)
        Select v_redlineid,p_CodeReview,p_ChangeTypeId,p_DeployInfo,v_objectid,p_Notes,p_DeployStatus,p_Env,p_TechId;

        insert into ObjectImplementationHistory(ReleaseCodeStatusTypeId,CreateDatetime,EnvironmentId,ObjectId,RedlineId)
        Select p_ReleaseCodeStatus,now(),p_Env,v_objectid,v_redlineid;

        COMMIT;
        --END LOOP
        EXCEPTION
         WHEN OTHERS THEN
              -- if error, roll back any chanegs done by any of the sql statements
           ROLLBACK;
END;
$$ LANGUAGE plpgsql;

================================================ =

我遇到错误

ERROR:  syntax error at end of input
LINE 64: $$ LANGUAGE plpgsql;
         ^
SQL state: 42601
Character: 1750

可以解决此问题的功能

运行该函数时,出现以下错误

=================================================
ERROR:  function public.spinsertreleasesheet(integer, unknown, unknown, integer, integer, unknown, integer, unknown, integer, integer, unknown, unknown, integer, integer) does not exist
LINE 1: SELECT public.spinsertreleasesheet(
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 8
=======================================
SELECT public.spinsertreleasesheet(
    177771, 
    '177771 : Tests', 
    NULL, 
    1, 
    1, 
    'Test', 
    1, 
    NULL, 
    1, 
    1, 
    NULL, 
    'Test', 
    1, 
    1
)

事件虽然数据库中有该函数,但给出了错误

1 个答案:

答案 0 :(得分:2)

您有2个<Hyperlink Command="{Binding DataContext.ColorChangerCommand, RelativeSource={RelativeSource AncestorType=Window}}" Foreground="{Binding Foreground}" TextDecorations="None"> ,只有1个BEGIN。您也无缘无故地有两个END部分。更改为:一个DECLARE,然后放置第二个DECLARE或仅使用一个END