Generating report dynamically
Hi Sir,
I got a big problem. Sending you a procedure first and elaborating the problem.
CREATE OR REPLACE FUNCTION getRepData( pvReportName Varchar2, rcList OUT XS.RC ) return varchar2 is
lvString Varchar2(1000);
iPointer Integer;
Begin
If pvReportName = 'TITLE' Then
Open rcList FOR
SELECT Key Col1,
nt.Name Col2,
'' Col3,
'' Col4,
'' Col5,
'' Col6,
'' Col7,
'' Col8,
'' Col9,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM t_title a, Table(a.NAME) nt;
Elsif pvReportName = 'SALUTATION' Then
Open rcList FOR
SELECT ID Col1,
Key Col2,
nt.Name Col3,
'' Col4,
'' Col5,
'' Col6,
'' Col7,
'' Col8,
'' Col9,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM T_SALUTATION a, Table(a.NAME) nt;
Elsif pvReportName = 'ENTPTYPE' Then
Open rcList FOR
SELECT ID Col1,
Key Col2,
nt.Name Col3,
Inactive Col4,
'' Col5,
'' Col6,
'' Col7,
'' Col8,
'' Col9,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM t_entptype a, Table(a.NAME) nt;
Elsif pvReportName = 'USER' Then
Open rcList FOR
SELECT ID Col1,
Login_Name Col2,
First_Name Col3,
Last_Name Col4,
Position Col5,
Dept Col6,
Room Col7,
Empl_no Col8,
Email Col8,
Phone Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM T_USER;
Elsif pvReportName = 'CLIENT' Then
Open rcList FOR
SELECT Key Col1,
Name Col2,
Nuts_Code Col3,
Reg_Code Col4,
Email Col5,
URL col6,
'' Col7,
'' Col8,
'' Col8,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM T_CLIENT;
Else
Open rcList FOR
SELECT '' Col1,
'' Col2,
'' Col3,
'' Col4,
'' Col5,
'' Col6,
'' Col7,
'' Col8,
'' Col9,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM DUAL;
End If;
Exception
When Others Then
return Null;
End;
Now the scenario is that I have to take only one table with 20 columns.
I wants to display the report as per the parameter value.
In the procedure/function one of the parameter is pvreportname. So if the pvreportname = 'TITLE' then the specific query of it is to be fire as shown in function.
i.e if Pvreportname = 'TITLE' the report to be generated for the query--
SELECT Key Col1,
nt.Name Col2,
'' Col3,
'' Col4,
'' Col5,
'' Col6,
'' Col7,
'' Col8,
'' Col9,
'' Col10,
'' Col11,
'' Col12,
'' Col13,
'' Col14,
'' Col15,
'' Col16,
'' Col17,
'' Col18,
'' Col19,
'' Col20
FROM t_title a, Table(a.NAME) nt;
Similarly for others like salutation and so on.
I don't know how to do
Help me in this. I am using version 3.7.
Thanks