Tuesday, June 25, 2013

Creating The Oracle Cursor For Update



create or replace procedure cursorforupdate as
  cursor crec is 
    select emp_code,emp_name from emp where emp_name='xyz' for update;
    vempcode emp.emp_code%type;
    vempname emp.emp_name%type;
begin
  open crec;
  loop
    fetch crec into vempcode, vempname;
    exit when crec%notfound;
    update emp set emp_number=vempcode where current of crec;
  end loop;
commit;
  close crec;
end; 

you cannot write commit inside the loop of for update cursor.

Tuesday, June 18, 2013

dynamically generate the list in oracle

FIRST CREATE A LIST_ITEM EMPLOYEE_CODE IN THE EMPLOYEE_MASTER BLOCK.TO FILL THE LIST WITH VALUES RUNTIME USE THE FOLLOWING CODE:-

declare
 
  r_dname varchar2(40) := 'divn_rec';
  status number;
  groupidd recordgroup;
begin

/*First dynamically create a query*/

groupidd := create_group_from_query(R_dname,
  'select employee_NAME,employee_code  from emp');

/* tHEN POPULATE THE FROUP*/
  status := populate_group(groupidd);
  clear_list('EMPLOYEE_MASTER.EMPLOYEE_CODE');
/** populates the list with values from record group*/
  populate_list('EMPLOYEE_MASTER.EMPLOYEE_CODE',groupidd);
END ;

Wednesday, June 5, 2013

suppress frm-40208 form running in query-only mode message

In the On-ERROR trigger write:-

  al_id     Alert;
al_button Number;

BEGIN
if errcode=40208 then
--do nothing;
else
     
      al_button := Show_Alert( 'Error_Alert' );
      RAISE FORM_TRIGGER_fAILURE;
   end if;  
end;