Search code examples
oraclevariablesprocedures

Declaring variables inside an Oracle procedure


There is some problem with the declaration of mystrtID. I am trying to implement pagination and need to select a range from a starting ID

    create or replace procedure GET_WORKFLOW_Range(p_Dataset OUT 
                                                   Sys_Refcursor,
                                                   strtID IN integer,
                                                   quantity IN integer)

    as

    BEGIN
      mystrtID:= strtID;

      IF mystrtID = 0 Then
        mystrtID := 2147483647;
      end IF;

      Open p_Dataset For
      Select WKF_ID,
        WKF_WORKFLOW_ID,
        WKF_WORKFLOW_NAME,
        WKF_WORKFLOW_VERSION,
        WKF_WORKFLOW_SCHEMA
      FROM CTS.WKF_WORKFLOW_MASTER
      WHERE WKF_WORKFLOW_ACTIVE = '1' AND 
            WKF_ID < mystrtID AND 
            ROWNUM <= quantity
      ORDER BY WKF_ID DESC;
    END GET_WORKFLOW_Range;

Solution

  • Just define mystrtID with a proper type like integer, number before BEGIN after as:

    mystrtID integer;