How to make a "Case When" when the condition is called a Package with the function and Passed the Parameters?

Asked

Viewed 56 times

0

I am trying to make a modification in the Query without destroying a logic already made.

Original Query:

IF Pcoluman = 'aceito' THEN
            if  (v_respon_alg = 'Y')
             OR (v_respon_las = 'Y')
             OR (v_respon_nye = 'Y')
             OR (v_respon_vav = 'Y') THEN
                 package_thea.validador('Nova York', 433);
                 package_thea.validador('Boston', 574);
                 package_thea.validador('Nova Jersey', 397);
        ELSE

                 package_thea.validador('Sem Registro Cidade', 000);
        END IF;

What I need to do is put a case when in the first validator where when v_res_pn_vav = 'Y' it replaces for "Seattle".

Since you’re making a mistake, would that work? He says that ";" dps is missing the END, then falls in the ELSE with error, I’m not getting it right.

Follows QUERY with modification:

IF Pcoluman = 'aceito' THEN
            if  (v_respon_alg = 'Y')
             OR (v_respon_las = 'Y')
             OR (v_respon_nye = 'Y')
             OR (v_respon_vav = 'Y') THEN
                 CASE WHEN (v_respon_vav = 'Y') THEN package_thea.validador('Seattle', 8974) ELSE package_thea.validador('Nova York', 433); END
                 package_thea.validador('Boston', 574);
                 package_thea.validador('Nova Jersey', 397);
        ELSE

                 package_thea.validador('Sem Registro Cidade', 000);
        END IF;

What am I missing?

1 answer

1


PROBLEM SOLVING:

Eventually I found out, I did the following:

IF Pcoluman = 'aceito' THEN
        if  (v_respon_alg = 'Y')
         OR (v_respon_las = 'Y')
         OR (v_respon_nye = 'Y')
         OR (v_respon_vav = 'Y') THEN
             package_thea.validador(CASE WHEN (v_respon_vav = 'Y') THEN 'Seatle' ELSE 'Nova York', END, 
                CASE WHEN (v_respon_vav = 'Y') THEN 8974 ELSE 433 END); 
             package_thea.validador('Boston', 574);
             package_thea.validador('Nova Jersey', 397);
    ELSE

             package_thea.validador('Sem Registro Cidade', 000);
    END IF;

I put the Case When inside my validator and put the condition, and in this making the simple substitution inside.

I’ll leave it here in case anyone ever has that same difficulty.

But that solved my problem

  • If anyone can validate that answer I’d be grateful

Browser other questions tagged

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