Tuesday, October 12, 2004

PL/SQL For Loops

Even when we use reverse option in for loop the intial counter should always be less than the last counter.

For example the following code will never execute

for x in reverse 12..1
loop
dbms_output.put_line('You can never read me');
end loop;


We can manipulate the range in the loops but they do not effect the execution of the loop in any way because the range scheema is executed only the time the loop begins. Any changes made to the range variables will not effect the range ounter. Its considered bad programming practice though.

FOR a_counter IN lo_val .. hi_val

LOOP
IF a_counter > lo_val * 2
THEN
hi_val := lo_val;
END IF;
END LOOP;
END LOOP;

Tuesday, September 28, 2004

Oracle Wrap and Excluding an Index

Wrap:
To convert PL/SQL code into binary format we can use the wrap option. wrap is availbale in oracle/ora92/bin directory
wrap will produce a file which is a binary version of the input file. The binary file can be compiled by oracle. But there is no decode option available using which you can convert back the original file from the binary version of the code. Hence it always better to store the original file as well.

How to exclude an Index:
The following are the ways in which we can make the query not to include the index on the column

1.Adding an expression to the indexed column
Eg : Select count(*) from employees where (emp_id)+0 = 1000;
2.Specifying the FULL hint to force full table scan
Eg : Select /*+ FULL(employees)*/ * from employees where emp_id = 1000;
3.Specifying NO_INDEX hint
Eg : Select /*+ NO_INDEX*/ * from employees where emp_id = 1000;
4.Using a function over the indexed column
Eg : Select * from employees where to_number(emp_id) = 1000;

Gmail Invitation

I have got 2 gmail invitations let me know if anyone wants them

Monday, September 27, 2004

Hello World

This is my first blog entry. Will try to post regulary as i play with java and oracle.