Some PL/SQL

Albatross

Platinum Member
Jul 17, 2001
2,344
8
81
DECLARE
x NUMBER(2);
BEGIN
x:=22;
FOR v IN 1..5 LOOP
IF v NOT IN (8,9) THEN
INSERT INTO lucru VALUES(v);
END IF;
END LOOP;
END;
/

Could somebody enlighten me how this sequence writes 2 in the table?
It`s from a multiple choice test it only says that the name of the table is lucru.
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
Based on what you've posted and assuming there's no table constraints or underlying triggers, this inserts a record for 1-5 in the 'lucru' table. So '2' is one of the records written.

it seems somewhat incorrect or missing a few parts as the variable x is not referenced at all within the loop.
 

Albatross

Platinum Member
Jul 17, 2001
2,344
8
81
Based on what you've posted and assuming there's no table constraints or underlying triggers, this inserts a record for 1-5 in the 'lucru' table. So '2' is one of the records written.

it seems somewhat incorrect or missing a few parts as the variable x is not referenced at all within the loop.

Yeah,probably something is missing.Thanks.