Google
 
Web unafbapune.blogspot.com

Monday, October 26, 2009

 

What comes next ?

3
1 3
1 1 1 3
3 1 1 3
1 3 2 1 1 3
1 1 1 3 1 2 2 1 1 3
3 1 1 3 1 1 2 2 2 1 1 3
1 3 2 1 1 3 2 1 3 2 2 1 1 3

Sunday, October 25, 2009

 

Experimenting with Oracle DBMS_LOCK

First, grant privilege to play with it. For example,
Login as user SYS with SYSDBA role, then

grant all on dbms_lock to public;
How to try it out in SQL Developer ?
set serveroutput on;

declare
v_result integer;
begin
v_result := DBMS_LOCK.REQUEST(123, 6, 0, true);

dbms_output.put_line(
case
when v_result=0 then 'Success'
when v_result=1 then 'Timeout'
when v_result=2 then 'Deadlock'
when v_result=3 then 'Parameter Error'
when v_result=4 then 'Already owned'
when v_result=5 then 'Illegal Lock Handle'
end);
end;
How to do it in JDBC ?
Connection conn = ...
CallableStatement stmt = conn.prepareCall("{call ? := DBMS_LOCK.REQUEST(?, 6, 0, true)}");
stmt.registerOutParameter(1, Types.INTEGER);
stmt.setBigDecimal(2, new BigDecimal(123));
stmt.execute();
int result = stmt.getInt(1);
System.out.println("result: " + result);

This page is powered by Blogger. Isn't yours?