Friday, July 5, 2013

Customized Sequence

We need to create a sequence to fill the primary key of a payment orders table.
The sequence number composed of :  
(the first two digits of the current year - dept id - serial )
Ex : 
      129010001
      139010001
      139010002
      135500001 
      135500002
 
Steps to accomplish the task :
  1. Create a PL/SQL function that deals with creating sequences
  2. Inside payment EO , Call PL/SQL function from doDml method 
  3. Pass the arguments .
  4. Get the result and assign it to the primary key or the target attribute
CallableStatement cs=
         getDBTransaction().createCallableStatement ("begin ? := PAY_ORDER_SEQ(?,?) ; end;", 0);

 PL/SQL function




No comments:

Post a Comment