How to verify if a value exists in an Oracle Process input parameter and make a decision?

Asked

Viewed 40 times

0

I have a trial that has a type VARCHAR2 of entrance parameter:

PROCEDURE PRC_MINHA_PROCEDURE (
    PI_ID           IN TB_1.ID%TYPE
    PI_ID_ATRIBUIDO IN VARCHAR2 DEFAULT NULL,
    PO_TP_RESULT    OUT t_cursor
)
AS

where`PI_ID_ATRIBUIDO = '-1,456,54'` (may vary n values)
**DOUBT:** how do I check to see if there is a **-1** value within this parameter so I make a decision in **IF** as per the script below ?
Note: My query is large and difficult to read, I have no control over Oracle, so to simplify I will put a similar query here,for example:
SELECT     
    TB_1.ID,
    TB_1.NOME,
    TB_2.CODIGO
FROM TB_1 LEFT JOIN TB_2 ON TB_1.ID = TB_2.ID
WHERE
    TB_1.STATUS IN (2,3)

      IF (PI_ID_ATRIBUIDO == -1) THEN

        AND TB_1.ID IN (-1,4470,4486);
      ELSE
        AND TB_1.ID IN (4470,4486);
      END IF;

  • I would do so: AND ((TB_1.ID = -1 AND PI_ID_ATRIBUIDO = -1) OR (TB_1.ID IN (4470,4486)))

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.