Difference between revisions of "Plsql variables"
From John Freier
| Line 9: | Line 9: | ||
attId:= seq_attr.nextval; | attId:= seq_attr.nextval; | ||
dbms_output.put_line (attId); | dbms_output.put_line (attId); | ||
| + | END; | ||
| + | |||
| + | |||
| + | |||
| + | == Collections == | ||
| + | |||
| + | DECLARE | ||
| + | TYPE MyListType IS TABLE OF VARCHAR(21); | ||
| + | |||
| + | myList MyListType := MyListType('option1', 'option2', 'option2'); | ||
| + | |||
| + | BEGIN | ||
| + | |||
| + | FOR x IN codes.FIRST .. codes.LAST | ||
| + | LOOP | ||
| + | |||
| + | dbms_output.put_line('COURSE:' || codes(x)); | ||
| + | |||
| + | END LOOP; | ||
| + | |||
END; | END; | ||
Revision as of 11:06, 19 April 2013
When declaring variables you must also specify the block where the variables are going to be used.
- attrId = Variable name
- ':=' = Sets the variable to a value
DECLARE
attrId number;
BEGIN
attId:= seq_attr.nextval;
dbms_output.put_line (attId);
END;
Collections
DECLARE
TYPE MyListType IS TABLE OF VARCHAR(21);
myList MyListType := MyListType('option1', 'option2', 'option2');
BEGIN
FOR x IN codes.FIRST .. codes.LAST
LOOP
dbms_output.put_line('COURSE:' || codes(x));
END LOOP;
END;