0

I am writing a procedure in oracle, when I am getting a variable as rowtype.

I am trying to achieve a test condition based on for loop

FOR idx in 1..10 LOOP
   IF POST.SI_AMOUNT||idex <> 0 THEN
   NULL;
   END IF; 
END LOOP;

I have columns in table like this

 SI_AMOUNT1,

 SI_AMOUNT2,

 SI_AMOUNT3,

 SI_AMOUNT4,

 SI_AMOUNT5,

 SI_AMOUNT6,

 SI_AMOUNT7,

 SI_AMOUNT8,

 SI_AMOUNT9,

 SI_AMOUNT10

I want to check all columns value by using for loop. is this possible in oracle?

1
  • may be some usage of EXECUTE IMMEDIATE .. RETURNING INTO .. Commented Feb 16, 2018 at 9:02

1 Answer 1

1

First of all, it looks like your table design violates the First normal form. If you fix this error, I guess, you'll lose a need to iterate throw a columns in such manner.

Next, statement POST.SI_AMOUNT||idex <> 0 you had wrote, means Take the value of POST.SI_AMOUNT variable, concatenate it with the value of idex variable and compare concatenation result with zero using implicit datatype conversion.

At last, PL/SQL, as other non-script languages, have no ability to iterate throw variables list. There are no any ability to do this simplier than direct use of ten IF conditions, but the best way, as I said, is to redesign the table and to eliminate this need at all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.