Reputation: 55
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?
Upvotes: 0
Views: 32
Reputation: 2496
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.
Upvotes: 1