I've created this below procedure... But, struggling on writing the message field..

Code:
create table auditing (
	id number(5) not null,
	cdate date,
	ccode varchar2(10),
	cterm varchar2(255),
	pid number(20),
	mand varchar2(10),
	skey number(10),
	message varchar2(2000),
	source varchar2(255),
	source_YN varchar2(1)
	);

create table acfg (
	id number(10) not null,
	v_YN varchar2(1),
	mand varchar2(10),
	bcode varchar2(10),
	skey number(10),
	i_o varchar2(3),
	tname varchar2(255),
	cname varchar2(255),
	func varchar2(64),
	group_col1 varchar2(255),
	group_col2 varchar2(255),
	group_col3 varchar2(255),
	message_id number(10),
	wheresql varchar2(2000),
	message varchar2(2000)
	);
	
insert into acfg (id,mand,bcode,skey,i_o,tname,cname,func,group_col1,message)
values (1,'M1','P1',1,'o','table1','country','count','country','%1 entries found for %2');

insert into acfg (id,mand,bcode,skey,i_o,tname,cname,func,message)
values (2,'M1','P1',2,'o','table1','firstname','count','%1 total lines');

insert into acfg (id,mand,bcode,skey,i_o,tname,cname,func,message)
values (3,'M1','P2',1,'i','table1','firstname','count','%1 lines found');

insert into acfg (id,mand,bcode,skey,i_o,tname,cname,func,message)
values (4,'M1','P2',2,'o','table2','firstandlastname','count','%1 lines written');


CREATE SEQUENCE audseq
	 MinVALUE 1
		MAXVALUE 999999999999999999999999999
	   START WITH 1
		inCREMENT BY 1
		CACHE 20;

	  Create OR Replace Procedure auditingsp( pi_pid	IN Number
									  , pi_mand   IN Varchar2
									  , pi_bcode  IN Varchar2
									  , pi_opp	IN Number
									  , pi_I_O	IN Varchar2
									  , pi_Source IN Varchar2 )
 As
   Cursor aud_cur( pi_mand IN Varchar2
			   , pi_I_O  IN Varchar2
			   , pi_bcode  IN Number ) Is
	  SELECT v_yn
		   , message 
		FROM acfg
	   WHERE mand = pi_mand
		 AND (pi_I_O = 'I')
		  OR (pi_I_O = 'O' AND bcode=pi_bcode);
 
   Type acfg_tab Is Table Of aud_cur%Rowtype;
   acfg_array acfg_tab;
Begin
   Open aud_cur( pi_mand
			 , pi_I_O
			 , pi_bcode);
   Loop
	  Fetch aud_cur Bulk Collect
		 INTO acfg_array Limit 1000;
	  Exit When aud_cur%Notfound;
   
	  For i IN acfg_array.First .. acfg_array.Last Loop

		 If upper(acfg_array(i).v_yn) = 'Y' and pi_I_O = 'I' THEN		
			INSERT INTO auditing
			   ( ID
			   , cdate
			   , ccode
			   , pid
			   , mand
		   , skey
			   , Source
			   , message )
			VALUES
			   ( audseq.Nextval
			   , Sysdate
			   , pi_bcode
			   , pi_pid
			   , pi_mand
		   , ??????			 /* skey needs to be assigned based on the auditing.ccode */
			   , pi_Source
			   , ??????			 /* this should be step a) from my previous reply,Build a dynamic SQL like select 
func(cname) from tname where mand= pi_mand; /* sql should also include acfg.wheresql in the where clause, sql should also 
include acfg.group_col1,acfg.group_col2, acfg.group_col3 if there are any values. Execute the sql and using the 
acfg.message for that row, insert into auditing.message field */ 
 		   );

		 Elsif upper(acfg_array(i).v_yn) = 'Y' and pi_I_O = 'O' THEN
		 INSERT INTO auditing
			   ( ID
			   , cdate
			   , ccode
			   , pid
			   , mand
		   , skey
			   , Source
			   , message )
			VALUES
			   ( audseq.Nextval
			   , Sysdate
			   , pi_bcode
			   , pi_pid
			   , pi_mand
		   , ??????			 /* skey needs to be assigned based on the auditing.ccode */
			   , pi_Source
			   , ??????			 /* this should be step b) from my previous reply,build a dynamic SQL like select 
func(cname) from tname where mand= pi_mand and auditing.pid= pi_pid group by group_col1;  pi_pid is the argument passed in 
the SP. sql should also include acfg.wheresql in the where clause, sql should also include acfg.group_col2, acfg.group_col3
 if there are any values.Execute the sql and using the acfg.message for that row, insert into auditing.message field  */
		   );

		 Elsif upper(acfg_array(i).v_yn) = 'N' THEN
			 dbms_output.put_line('Data is ignored');
		 End If;
	  End Loop;
   End Loop;
   Close aud_cur;
   Commit;

Exception
   When Others Then
	  Rollback;
	  dbms_output.put_line(Sqlerrm(Sqlcode));
End auditingsp;
I would appreciate any kind of help.. Please give me your thoughts.

Thank you very much