How to create a unique ID for one process?

I am using one table to store all logs.

the table is inserted through procedure, and I am calling the procedure in all places.

So, this will give me the flow, and will be able to analyze when there is some error.

Now, I want to use one unique number for one process.

Like I am doing one operation from front end, so I should have one unique  number to identify all the records that are coming through that process. So that I can query using that key.

How is this possible?
sakthikumarAsked:
Who is Participating?
 
flow01Commented:
If it's on transaction level

define a global_temporary table  tmp_process_id with  on column process-id

In the procedure for inserting the log-records (or on a trigger on the log-records:
get the process_id from tmp_process_id
   (there is always 0 or 1 record)
   if no data found insert a record with a new-process-id  using the sequence
      and use the process_id for identification of the transaction
   when there is a record use the process_id in it

committing or rollback wil empty the global_temporary table
so on the next log writing you wil get a new process_id

beware :  
1) if you log within a discrete transactions procedure they will be also get a new process_id

2) it works on commit/rollback  in the database :  commit/rollback in a form will only result in a database action if there was a change in the block-data of  the form
0
 
flow01Commented:
Create a sequence  

CREATE SEQUENCE process_id;
and use the   next_val of it at the start of each process

create or replace
procedure xprocess
is
  v_process_id pls_integer;
begin
   select process_id.nextval
   into v_process_id
  from dual;
  -- rest of your process  as an example :
  dbms_output.put_line('process_id:' || v_process_id);
end;
/

excuting for example in sqlplus

SQL> set serveroutput on
SQL> begin
  2    xprocess;
  3    xprocess;
  4  end;
  5  /
process_id:1
process_id:2
0
 
ajexpertCommented:
In your log table, you can create one column, say CREATED_BY.

If you have limited and identifiable number of processes, I prefer to identify them with some some distinct numbers.

So
Process1      := 101
Process2      := 102

and so on...

I
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
slightwv (䄆 Netminder) Commented:
I don't think a sequence will work here.

If you can change all the apps that call the procedure, then the unique process id will work.

This may or may not work but to keep app changes to a minimum, see if you can use sys_context inside the procedure to grab the client's info like ip address.

If you use an app server/web server then it probably won't work since it will return the ip address of the client which would be the app server or web server.

In this case, you will need to change the apps themselves to pass in some identifier.
0
 
flow01Commented:
I don't agree :   the process-id can be set in the initial-procedure the apps calls,

wether the apps needs the process-id depends on the way the application is designed.
If the aim is to follow the flow of 1 single call from the app on it's way to different procedures it's enough, unless the app can call either procedure A or procedure B and procedure A wil call also procedure B in it's flow.
The id can be passed as arguments with the procedure or saved at session level as a context variable,  a global temporary table , a package variable .
0
 
sakthikumarAuthor Commented:
I want transaction level logging, there is no clear starting point / ending point for my process.

like atleast there should be one sequeunce for all records that is before a commit /rollback.
0
 
sakthikumarAuthor Commented:
For ex: the below procedure call may not always be the starting point for the process.

crt_nomination(pi_port         => pi_port,
                   pi_terminal     => pi_terminal,
                   pi_hn_gen_code  => pi_hn_gen_code,
                   pi_hn_gen_type  => pi_hn_gen_type,
                   pi_hn_by_code   => pi_hn_by_code,
                   pi_hn_by_type   => pi_hn_by_type,
                   pi_hn_to_code   => pi_hn_to_code,
                   pi_hn_to_type   => pi_hn_to_type,
                   pi_boe_no       => pi_boe_no,
                   pi_do_no        => pi_do_no,
                   pi_arn_no       => pi_arn_no,
                   pi_arn_dtl_no   => pi_arn_dtl_no,
                   pi_user_id      => pi_user_id,
                   pi_contr_no     => pi_contr_no,
                   pi_crt_date     => pi_crt_date,
                   pi_mt_contr_cnt => pi_mt_contr_cnt,
                   pi_move_type    => pi_move_type,
                   pi_desig        => pi_desig,
                   pi_txn_src      => pi_txn_src,
                   pio_hn_id       => pio_hn_id,
                   po_err_code     => po_err_code,
                   po_err_msg      => po_err_msg);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.