1
CREATE OR REPLACE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text) RETURNS integer AS
$BODY$
  DECLARE
    ptodoitemid ALIAS FOR  $1;
    pusername   ALIAS FOR  $2;
    pname       ALIAS FOR  $3;
    pdesc       ALIAS FOR  $4;
    pincdtid    ALIAS FOR  $5;
    pcrmacctid  ALIAS FOR  $6;
    pOpheadid   ALIAS FOR  $7;
    pstarted    ALIAS FOR  $8;
    pdue        ALIAS FOR  $9;
    pstatus     ALIAS FOR $10;
    passigned   ALIAS FOR $11;
    pcompleted  ALIAS FOR $12;
    ppriority   ALIAS FOR $13;
    pnotes      ALIAS FOR $14;
    pactive     ALIAS FOR $15;
    powner  ALIAS FOR $16;
    plock   ALIAS FOR $17;

    _priority   INTEGER         := ppriority;
    _status     CHARACTER(1)    := pstatus;
    _incdtid    INTEGER         := pincdtid;
    _crmacctid  INTEGER         := pcrmacctid;
    _opheadid   INTEGER         := pOpheadid;
    _assigned   DATE            := passigned;
    _active     BOOL            := pactive;
    _result     INTEGER;
    _lock       BOOL            := plock;

  BEGIN
    IF (pusername IS NULL OR pusername = '') THEN
      RETURN -1;
    END IF;

    IF (pname IS NULL OR pname = '') THEN
      RETURN -2;
    END IF;

    IF (pdue IS NULL) THEN
      RETURN -3;
    END IF;

    IF (ptodoitemid IS NULL OR ptodoitemid <= 0) THEN
      RETURN -10;
    END IF;

    IF (pcompleted IS NOT NULL) THEN
      _status := 'C';
    ELSIF (pstatus IS NULL AND pstarted IS NOT NULL) THEN
      _status := 'I';
    ELSIF (pstatus IS NULL) THEN
      _status := 'N';
    END IF;

    IF (_incdtid <= 0) THEN
      _incdtid := NULL;
    END IF;

    IF (_crmacctid <= 0) THEN
      _crmacctid := NULL;
    END IF;

    IF (_opheadid <= 0) THEN
      _opheadid := NULL;
    END IF;

    IF (_priority <= 0) THEN
      _priority := NULL;
    END IF;

    IF (_assigned IS NULL) THEN
      _assigned := CURRENT_DATE;
    END IF;

    IF (_active IS NULL) THEN
      _active := TRUE;
    END IF;

    UPDATE todoitem SET
        todoitem_username=pusername, todoitem_name=pname, todoitem_description=pdesc,
        todoitem_incdt_id=_incdtid, todoitem_status=_status,
        todoitem_active=_active, todoitem_lock=lock, todoitem_start_date=pstarted,
        todoitem_due_date=pdue, todoitem_assigned_date=_assigned,
        todoitem_completed_date=pcompleted, todoitem_priority_id=_priority,
        todoitem_notes=pnotes, todoitem_crmacct_id=_crmacctid,
        todoitem_ophead_id=_opheadid, todoitem_owner_username=powner 
    WHERE (todoitem_id=ptodoitemid);

    RETURN ptodoitemid;
  END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

我需要在我的函数 updatetodoitem 中添加一个锁定参数。现在它需要 16 个参数,我需要以某种方式更改它,以便它需要第 17 个参数。现在它说“错误函数没有参数$ 17”

4

1 回答 1

1

您还需要更改此部分:

CREATE OR REPLACE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text)

并且大概添加一个布尔值:

CREATE OR REPLACE FUNCTION updatetodoitem(integer, text, text, text, integer, integer, integer, date, date, character, date, date, integer, text, boolean, text, boolean)
于 2013-06-12T21:04:31.963 回答