Hi,
I want to use alias for commonly used scripts. How should i change my sqls for that purpose.
Let's say right now i am using the below query.
+++++++++++++++
undef p_begin_time
undef p_end_time
undef p_inst_num
undef p_dbid
define p_begin_time = '&1'
define p_end_time = '&2'
define p_inst_num = &3
set termout off
define name=""
col name new_value name
select name name from v$database;
set termout off
define dbid=""
col dbid new_value p_dbid
select dbid dbid from v$database;
define p_b_snid=""
define p_e_snid=""
col p_b_snid new_value p_b_snid
col p_e_snid new_value p_e_snid
select min(snap_id) p_b_snid ,max(snap_id) p_e_snid
from dba_hist_snapshot
where to_date(to_char(begin_interval_time,'DD-MON-RR HH24:MI:SS'),'DD-MON-RR HH24:MI:SS')
between to_date('&p_begin_time','DD-MON-RR HH24:MI:SS') and to_date('&p_end_time','DD-MON-RR HH24:MI:SS')
and dbid = &&p_dbid
and instance_number = &p_inst_num;
+++++++++++++++
and usage is like:
@getsnapid <begin_time> <end_time> <inst_id>
e.g.
@getsnapid "07-JUN-16 09:00" "07-JUN-16 10:00" 1
So how should i convert my sql. Basically it means.
1. Can there be multiple sqls called inside an alias . e.g. i used sqls on v$database & dba_hist_snapshot.
2. How does the alias work for bind variables. should use i keep & or should use ":" colon. If so how should i convert my above sql so that it works fine.
Regds,
Kunwar