I've got this procedure working in TOAD/PLSQL but, would like the alias for the first column to be set to the field_name argument passed to the procedure. I think I need to build the query as a string like,
query := 'Select 1 as ' || field_name || ' From Dual';
But am not getting it right. Is what I have in mind possible?
Thanks and the working code I'm trying to modify is below.
Create or Replace Procedure Delete_Me(field_name NVarChar2)
as
result_set sys_refcursor;
BEGIN
open result_set for
Select
Elapsed_Time((Select Start_Time From Temp_Time1)) as field_name
,To_Char(SysDate, 'HH12:MI:SS AM') as Time_Completed
,Elapsed_Time((Select Start_Time From Temp_Time0)) as Process_So_Far
From
Dual;
DBMS_SQL.RETURN_RESULT(result_set);
End;
After comment:
I pass the procedure a string and its valued is placed in, "field_name." I would like the alias of the first column to adopt the value of field_name. So if I call the procedure thusly:
BEGIN
DeleteMe('Random_Column_Name');
END;
The first column name would be called, "Random_Column Name." If I called the procedure this way:
BEGIN
DeleteMe('Different_Column_Name');
END;
The first column would be names, "Different_Column_Name."
After Dmitry's second comment: It doesn't mean anything. It's an example of what I've tried and failed to get to work.
query := 'Select 1 as ' || field_name || ' From Dual';
- what does it mean? Where did you use it?