CREATE OR REPLACE FUNCTION f_deposit_cvsinfo_update(
 IN kubun           integer,    -- 区分
 IN _orderno        integer,    -- 受注No
 IN _cvsinfo        varchar,    -- コンビニ決済情報

 IN upduser         varchar,
 IN pc              varchar,

 OUT errcd          integer,
 OUT errmsg         varchar,
 OUT code           integer) AS
$BODY$
DECLARE
    cntcheck integer;
BEGIN
    --
    -- パラメータチェック
    --

    -- 処理区分
    IF kubun IS NULL OR kubun NOT IN (2) THEN
        RAISE EXCEPTION '処理区分が不正です';
    END IF;

    IF kubun = 2 THEN
        -- 受注明細変更
        UPDATE t_deposit SET
            cvsinfo = _cvsinfo,

            updusrnm = upduser,
            updpcnm = pc
            WHERE orderno = _orderno;
        errcd := 1;
        code := _orderno;
        errmsg := '完了';
        RETURN;
    END IF;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

ALTER FUNCTION f_deposit_cvsinfo_update(IN kubun integer, IN _orderno integer, IN _cvsinfo varchar, IN upduser varchar, IN pc varchar, OUT errcd integer, OUT errmsg varchar, OUT code integer) OWNER TO :ADMINUSER;

GRANT ALL ON FUNCTION f_deposit_cvsinfo_update(IN kubun integer, IN _orderno integer, IN _cvsinfo varchar, IN upduser varchar, IN pc varchar, OUT errcd integer, OUT errmsg varchar, OUT code integer) TO :ONEDEPOUSER;
