Func dyn statement_set.c

660 views

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
660
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Func dyn statement_set.c

  1. 1. func_dyn_statement_set.c#include <stdio.h>#include <stdlib.h>#include <string.h>#include "constant_definition.h"#include "case_constant_definition.h"#include "case_constant_sql_stmt_def.h"#include "constant_oracle_versions.h"extern vaciar_cadena();extern pasar_amayus ();char *func_dyn_statement_set (int version, int sentencia, char *opcion_uno, char *opcion_dos, char*opcion_tres , char *opcion_cuatro) { static char dyn_sts[MAX_STMT_SIZE]; vaciar_cadena (dyn_sts,MAX_STMT_SIZE); switch (sentencia) { case CASE_ORACLE_VERSION: strcpy (dyn_sts,"select ltrim(lpad(banner,70)) Versionfrom v$version "); strcat (dyn_sts,"where banner like %Oracle% "); break; case CASE_ACTIVE_PARAMETERS: strcpy (dyn_sts,"select name,value,description fromv$parameter order by 1 "); break; case CASE_USERS_CONNECTED: strcpy (dyn_sts,"select saddr ADDRESS,sid SES,usernameNOMBRE,command CMD, n"); strcat (dyn_sts,"status ESTADO,process PID,terminalTERMINAL,LOCKWAIT, n"); strcat (dyn_sts,"to_char(logon_time,DD/MM/YYYY -HH24:MI:SS) INICIADO from v$session n "); strcat (dyn_sts,"order by INICIADO n"); break; case CASE_WAIT_STATISTICS: strcpy (dyn_sts,"select count CANTIDAD,time TIEMPO,classCLASE from v$waitstat order by 1 "); break; case CASE_DATAFILE_I_0: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_sts,"select f.phyrds,f.phyblkrd, f.phywrts, "); strcat (dyn_sts,"f.phyblkwrt,f.lstiotim*10 , d.namen"); strcat (dyn_sts,"from v$filestat f,v$datafile d "); strcat (dyn_sts,"where f.file# = d.file#and "); strcat (dyn_sts,"f.lstiotim > 0 order by2 n"); break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: strcpy (dyn_sts,"select f.phyrds,f.phyblkrd, f.phywrts, "); strcat (dyn_sts,"f.phyblkwrt, d.name "); strcat (dyn_sts,"from v$filestatf,v$datafile d "); Página 1
  2. 2. func_dyn_statement_set.c strcat (dyn_sts,"where f.file# = d.file#"); strcat (dyn_sts,"order by 2 n"); break; default: break; } break; case CASE_DATAFILE_BLOCKS_R_W: strcpy (dyn_sts,"select d.name DATAFILE, f.phyblkrdBLK_READ, f.phyblkwrt BLK_WRITE, n"); strcat (dyn_sts,"f.phyblkrd+f.phyblkwrt BLK_TOTAL fromv$filestat f, v$datafile d n"); strcat (dyn_sts,"where f.file# = d.file# order by 3 desc"); break; case CASE_WAIT_EVENTS: strcpy (dyn_sts,"select se.sid, se.usernameUSUARIO,count(*) CANTIDAD,sw.event EVENTO n"); strcat (dyn_sts,"from v$session se, v$session_wait swwhere sw.sid=se.sid and n"); strcat (dyn_sts,"se.username > A and sw.event not likeSQL*Net% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Table QNormal% and n"); strcat (dyn_sts,"sw.event not like PX Deq: ExecutionMsg% and n"); strcat (dyn_sts,"sw.event not like pipe get% n"); strcat (dyn_sts,"group by se.sid, se.username, sw.event"); break; case CASE_INSTANCE_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"selecta.instance_number, a.instance_name, a.host_name, a.version, n"); strcat(dyn_sts,"to_char(a.startup_time,DD/MM/YYYY - HH24:MI:SS),a.status,a.parallel, n"); strcat (dyn_sts,"a.database_status,a.instance_role ,b.log n"); strcat (dyn_sts,"from v$instance a,n"); strcat (dyn_sts," (select log_mode logfrom v$database ) b n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select a.name,a.created, a.log_mode, a.checkpoint_change#, n"); strcat (dyn_sts,"a.archive_change#,b.val1 ,c.val2, d.val3, e.value, a.log_mode n"); strcat (dyn_sts,"from v$database a,n"); strcat (dyn_sts,"(select decode(value,0,OPEN) val1 n"); strcat (dyn_sts,"from v$instance wherekey=RESTRICTED MODE) b, n"); strcat (dyn_sts,"(selectdecode(value,0,NO) val2 n"); strcat (dyn_sts,"from v$instance wherekey=SHUTDOWN PENDING) c, n"); strcat (dyn_sts,"(selectto_char(to_date(value, J),DD/MM/YYYY) val3 n"); strcat (dyn_sts,"from v$instance wherekey=STARTUP TIME - JULIAN ) d, n"); Página 2
  3. 3. func_dyn_statement_set.c strcat (dyn_sts,"(select value n"); strcat (dyn_sts,"from v$instance wherekey=STARTUP TIME - SECONDS ) e n"); break; default: break; } break; case CASE_TEMPORAL_SPACE_BY_USER: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select se.sid,se.serial#, se.username, so.extents, so.contents, n"); strcat (dyn_sts,"sum((so.blocks)*(selectvalue from v$parameter n"); strcat (dyn_sts,"where name in(db_block_size))/1000) size_kb n"); strcat (dyn_sts,"from v$session se,v$sort_usage so where se.saddr=so.session_addr n"); strcat (dyn_sts,"group byse.sid,se.serial#,se.username,so.extents,so.contents n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select tablespace_name,extent_size, current_users, total_extents, n"); strcat (dyn_sts,"total_blocks,used_extents, used_blocks, free_extents, free_blocks, n"); strcat (dyn_sts,"max_used_size,max_used_blocks, max_sort_size, max_sort_blocks n"); strcat (dyn_sts,"from v$sort_segmentn"); default: break; } break; case CASE_TOT_FREELIST_WAIT_PERCENT: strcpy (dyn_sts,"select (a.count/sum(b.value))*100PCT_FREELIST from v$waitstat a, n"); strcat (dyn_sts,"v$sysstat b where a.class=free listand n"); strcat (dyn_sts,"b.name in (db block gets,consistentgets) group by a.count "); break; case CASE_LAST_CHECKPOINT_TIME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select min(sysdate -CHECKPOINT_TIME)*24*60 MINUTO, n"); strcat(dyn_sts,"to_char(sysdate,DD/MM/YYYY - HH24:MI:SS) FECHA n"); strcat (dyn_sts,"fromv$datafile_header"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select count(sid)Cantidad from v$session n"); break; default: break; } break; case CASE_LIST_TABLESPACES: Página 3
  4. 4. func_dyn_statement_set.c switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"selecta.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB,n"); strcat (dyn_sts,"a.max_idMAX_ID,nvl(a.sum_bytes - c.sum_bytes,0)/1048576 USED_KB, n"); strcat(dyn_sts,"nvl(c.sum_bytes,0)/1048576 FREE_KB, n"); strcat (dyn_sts,"round(nvl((a.sum_bytes- c.sum_bytes),0.00)/a.sum_bytes*100.0,2) PCT_USED, d.status, n"); strcat(dyn_sts,"d.extent_management,d.allocation_type from (selecttablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id fromdba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(selecttablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group bytablespace_name) c, dba_tablespaces d n"); strcat (dyn_sts,"where a.tablespace_name= c.tablespace_name(+) and n"); strcat (dyn_sts,"a.tablespace_name =d.tablespace_name (+) order by 5,1 "); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"selecta.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB,n"); strcat (dyn_sts,"a.max_idMAX_ID,nvl(a.sum_bytes - c.sum_bytes,0)/1048576 USED_KB, n"); strcat(dyn_sts,"nvl(c.sum_bytes,0)/1048576 FREE_KB, n"); strcat (dyn_sts,"round(nvl((a.sum_bytes- c.sum_bytes),0.00)/a.sum_bytes*100.0,2) PCT_USED, d.status n"); strcat (dyn_sts,"from (selecttablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id fromdba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(selecttablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group bytablespace_name) c, dba_tablespaces d n"); strcat (dyn_sts,"where a.tablespace_name= c.tablespace_name(+) and n"); strcat (dyn_sts,"a.tablespace_name =d.tablespace_name (+) order by 5,1 "); break; } break; case CASE_ACTIVE_TRANSACTIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select tr.addr, n"); /* strcat(dyn_sts,"to_char(tr.start_time,DD/MM/YYYY - 24HH:MM:SS) TIME_START, n");*/ strcat (dyn_sts,"tr.start_time, n"); strcat (dyn_sts,"tr.statusESTADO,tr.used_ublk BLK_USED,tr.used_ublk*(select value n"); strcat (dyn_sts,"from v$parameter wherename in db_block_size)/1000 KB_USED,tr.used_urec, n"); Página 4
  5. 5. func_dyn_statement_set.c strcat (dyn_sts,"se.sid SES, se.serial#SERIAL,rn.name,se.username from v$transaction tr, n"); strcat (dyn_sts,"v$session se,v$rollname rn where tr.xidusn=rn.usn and n"); strcat (dyn_sts,"tr.ses_addr=se.saddrorder by 2,6"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select tr.addr, "); strcat (dyn_sts,"tr.start_time, "); /* strcat(dyn_sts,"to_char(tr.start_time,DD/MM/YYYY - 24HH:MM:SS) TIME_START, n"); */ strcat (dyn_sts,"tr.statusESTADO,tr.used_ublk BLK_USED,tr.used_ublk,n"); strcat (dyn_sts,"tr.used_urec, n"); strcat (dyn_sts,"se.sid SES, se.serial#SERIAL,rn.name,se.username from v$transaction tr, n"); strcat (dyn_sts,"v$session se,v$rollname rn where tr.xidusn=rn.usn and n"); strcat (dyn_sts,"tr.ses_addr=se.saddrorder by 2,6"); break; } break; case CASE_LATCH_DETAILS: strcpy (dyn_sts,"select gets GETS,missesMISS,round((gets-misses)*100/gets,2) HITRATIO, n"); strcat (dyn_sts,"immediate_getsIMM_GETS,immediate_misses IMM_MISS,sleeps SLEEP, n"); strcat (dyn_sts,"spin_gets GETSPIN,addr ADDR,latch#,nameNOMBRE from v$latch n"); strcat (dyn_sts,"where misses > 0 and gets > 0 n"); strcat (dyn_sts,"order by 2 desc,round(((gets-misses)/gets),2) desc"); break; case CASE_RESOURCE_LIMITS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select resource_nameNOMBRE,initial_allocation INIT_ALLOC, n"); strcat (dyn_sts,"current_utilizationCURR_UTILIZA,max_utilization MAX_UTILIZA, n"); strcat (dyn_sts,"limit_value LIMITE fromv$resource_limit order by 4"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select resource_name,limit n"); strcat (dyn_sts,"fromuser_resource_limits order by 2"); break; } break; case CASE_LIST_DATAFILES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select nameDATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select nameDATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n"); strcat (dyn_sts," order by MBYTES desc Página 5
  6. 6. func_dyn_statement_set.cn"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select nameDATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n");/* FALTARIA VER COMO HACEMOS PARA BUSCAR LA PARTE TEMPORAL EN VERSIONES7.3.4 strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select nameDATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n");*/ strcat (dyn_sts," order by MBYTES descn"); break; } break; case CASE_LIST_DATAFILES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select v.status ESTADO,d.file_name DATAFILE, d.tablespace_name TBLNAME, n"); strcat(dyn_sts,"to_char(nvl((d.bytes/1024),0),99999990.000) SIZE_KB, n"); strcat(dyn_sts,"to_char(nvl(((d.bytes-nvl(s.bytes,0))/1024),0),99999999.999) || /|| to_char(nvl((d.bytes/1024),0),99999999.999) || / || nvl(d.autoextensible,NO) USED_KB, n"); strcat (dyn_sts,"to_char(nvl(((d.bytes -nvl(s.bytes,0))/d.bytes)*100,0),990.00) USED_PCT n"); strcat (dyn_sts,"from sys.dba_data_filesd, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_spacegroup by file_id) s n"); strcat (dyn_sts,"wheres.file_id(+)=d.file_id and d.file_name=v.name n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select v.status ESTADO,d.file_name DATAFILE, d.tablespace_name TBLNAME, n"); strcat(dyn_sts,"to_char(nvl((d.bytes/1024),0),99999990.000) SIZE_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes_cached / 1024),0),9999999.999) || / ||to_char(nvl((d.bytes/1024),0),99999999.999) || / || nvl(d.autoextensible,NO) USED_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes_cached/d.bytes)*100,0),990.00) USED_PCT n"); strcat (dyn_sts,"from sys.dba_temp_filesd, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"wheret.file_id(+)=d.file_id and d.file_id=v.file# n"); strcat (dyn_sts,"order by SIZE_KB descn"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select v.status ESTADO,d.file_name DATAFILE, d.tablespace_name TBLNAME, n"); strcat(dyn_sts,"to_char(nvl((d.bytes/1024),0),99999990.000) SIZE_KB, n"); strcat(dyn_sts,"to_char(nvl(((d.bytes-nvl(s.bytes,0))/1024),0),99999999.999) || /|| to_char(nvl((d.bytes/1024),0),99999999.999) USED_KB, n"); strcat (dyn_sts,"to_char(nvl(((d.bytes -nvl(s.bytes,0))/d.bytes)*100,0),990.00) USED_PCT n"); Página 6
  7. 7. func_dyn_statement_set.c strcat (dyn_sts,"from sys.dba_data_filesd, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_spacegroup by file_id) s n"); strcat (dyn_sts,"wheres.file_id(+)=d.file_id and d.file_name=v.name n");/* strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select v.status ESTADO,d.file_name DATAFILE, d.tablespace_name TBLNAME, n"); strcat(dyn_sts,"to_char(nvl((d.bytes/1024),0),99999990.000) SIZE_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes_cached / 1024),0),9999999.999) || / ||to_char(nvl((d.bytes/1024),0),99999999.999) USED_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes_cached/d.bytes)*100,0),990.00) USED_PCT n"); strcat (dyn_sts,"from sys.dba_temp_filesd, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"wheret.file_id(+)=d.file_id and d.file_id=v.file# n");*/ strcat (dyn_sts,"order by SIZE_KB descn"); break; } break; case CASE_LIST_TABLESPACES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select d.status ESTADO,d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat (dyn_sts,"d.extent_managementEXTENT_MGM,to_char(nvl((a.bytes/1024),0),99999999.999) SIZE_KB, n"); strcat(dyn_sts,"to_char((nvl(a.bytes-nvl(f.bytes,0),0)/1024),99999999.999) || / ||to_char(nvl((a.bytes/1024),0),99999999.999) USED_KB, n"); strcat (dyn_sts,"to_char(nvl(((a.bytes -nvl(f.bytes,0))/a.bytes)*100,0),990.00) USED_PCT n"); strcat (dyn_sts,"fromsys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_filesgroup by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_spacegroup by tablespace_name ) f n"); strcat (dyn_sts,"whered.tablespace_name=a.tablespace_name(+) and n"); strcat (dyn_sts,"d.tablespace_name =f.tablespace_name(+) and n"); strcat (dyn_sts,"not(d.extent_management like LOCAL and d.contents LIKE TEMPORARY) n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select d.status ESTADO,d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat (dyn_sts,"d.extent_managementEXTENT_MGM,to_char(nvl((a.bytes/1024),0),99999999.999) SIZE_KB, n"); strcat(dyn_sts,"to_char((nvl(t.bytes,0)/1024),99999999.999) || / ||to_char(nvl((a.bytes/1024),0),99999999.999) USED_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes/a.bytes)*100,0),990.00) USED_PCT fromsys.dba_tablespaces d, n"); strcat (dyn_sts,"(selecttablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name)a, n"); Página 7
  8. 8. func_dyn_statement_set.c strcat (dyn_sts,"(selecttablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group bytablespace_name) t where d.tablespace_name=a.tablespace_name (+) and n"); strcat(dyn_sts,"d.tablespace_name=t.tablespace_name (+) and d.extent_management likeLOCAL and n"); strcat (dyn_sts,"d.contents likeTEMPORARY n"); strcat (dyn_sts,"order by SIZE_KB descn"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select d.status ESTADO,d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat(dyn_sts,"to_char(nvl((a.bytes/1024),0),99999999.999) SIZE_KB, n"); strcat(dyn_sts,"to_char((nvl(a.bytes-nvl(f.bytes,0),0)/1024),99999999.999) || / ||to_char(nvl((a.bytes/1024),0),99999999.999) USED_KB, n"); strcat (dyn_sts,"to_char(nvl(((a.bytes -nvl(f.bytes,0))/a.bytes)*100,0),990.00) USED_PCT n"); strcat (dyn_sts,"fromsys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_filesgroup by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_spacegroup by tablespace_name ) f n"); strcat (dyn_sts,"whered.tablespace_name=a.tablespace_name(+) and n"); strcat (dyn_sts,"d.tablespace_name =f.tablespace_name(+) and n"); strcat (dyn_sts,"not d.contents LIKETEMPORARY n"); /* strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select d.status ESTADO,d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat(dyn_sts,"to_char(nvl((a.bytes/1024),0),99999999.999) SIZE_KB, n"); strcat(dyn_sts,"to_char((nvl(t.bytes,0)/1024),99999999.999) || / ||to_char(nvl((a.bytes/1024),0),99999999.999) USED_KB, n"); strcat(dyn_sts,"to_char(nvl((t.bytes/a.bytes)*100,0),990.00) USED_PCT fromsys.dba_tablespaces d, n"); strcat (dyn_sts,"(selecttablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name)a, n"); strcat (dyn_sts,"(selecttablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group bytablespace_name) t where d.tablespace_name=a.tablespace_name (+) and n"); strcat(dyn_sts,"d.tablespace_name=t.tablespace_name (+) and n"); strcat (dyn_sts,"d.contents likeTEMPORARY "); */ strcat (dyn_sts,"order by SIZE_KB descn"); break; } break; case CASE_ACTIVE_SESSIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: Página 8
  9. 9. func_dyn_statement_set.c case VERSION_ORACLE_920: strcpy (dyn_sts,"select s.sid SES,s.serial# SERI, s.type TIPO, s.osuser OS_USER, n"); strcat(dyn_sts,"to_char(logon_time,DD/MM/YYYY - HH24:MI:SS) LOGON,s.status ESTADO,n"); strcat (dyn_sts,"s.process PROCESO,s.machine MAQUINA, s.username NOMBRE, n"); strcat (dyn_sts,"p.spid PID, s.programPROGRAMA n"); strcat (dyn_sts,"from v$session s,v$process p n"); strcat (dyn_sts,"where osuser is notnull and p.addr=s.paddr n"); strcat (dyn_sts,"order by LOGON, ESTADOn"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select s.sid SES,s.serial# SERI, s.type TIPO, s.osuser OS_USER, n"); strcat(dyn_sts,"to_char(logon_time,DD/MM/YYYY - HH24:MI:SS) LOGON,s.status ESTADO,n"); strcat (dyn_sts,"s.process PROCESO,s.machine MAQUINA, s.username NOMBRE, n"); strcat (dyn_sts,"p.spid PID, s.programPROGRAMA n"); strcat (dyn_sts,"from v$session s,v$process p n"); strcat (dyn_sts,"where osuser is notnull and p.addr=s.paddr n"); strcat (dyn_sts,"order by LOGON, ESTADOn"); break; } break; case CASE_SESSIONS_WAITS: strcpy (dyn_sts,"select sw.sid SES, sw.seq# SEQ,nvl(sw.wait_time,0) W_T, n"); strcat (dyn_sts,"nvl(sw.seconds_in_wait,0)S_W_T,nvl(se.username,.) USUA, n"); strcat (dyn_sts,"nvl(se.status,.) ESTA,sw.event EVENT,sw.state, sw.p1text, sw.p1, n"); strcat (dyn_sts,"sw.p1raw, sw.p2text, sw.p2, sw.p2raw,sw.p3text, sw.p3, sw.p3raw n"); strcat (dyn_sts,"from v$session_wait sw, v$session sen"); strcat (dyn_sts,"where sw.sid = se.sid order by 6,8n"); break; case CASE_DEFAULT_STORAGE_SETS_TABLESPACE: strcpy (dyn_sts,"select tablespace_name TBLNAME,initial_extent INI_EXT, next_extent NEX_EXT, n"); strcat (dyn_sts,"min_extents MIN_EXT, max_extentsMAX_EXT, pct_increase PCT_INC n"); strcat (dyn_sts,"from dba_tablespaces n"); strcat (dyn_sts,"order by tablespace_name n"); break; case CASE_ALL_TABLES_STORAGE_SETTINGS: strcpy (dyn_sts,"select owner OWNER_TABLE, segment_nameSEG_NAME, tablespace_name TBL_NAME, n"); strcat (dyn_sts,"blocks BLKS, blocks SIZE_KB, n"); strcat (dyn_sts,"extents EXTS, max_extents MAX_EXT n"); strcat (dyn_sts,"from dba_segments n"); strcat (dyn_sts,"where segment_type=TABLE order by 1,2n"); break; Página 9
  10. 10. func_dyn_statement_set.c case CASE_ALL_NON_SYS_TABLES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select owner OWNER,table_name TNAME, tablespace_name TBLNAME, n"); strcat (dyn_sts,"nvl(blocks,-1) BLOCK,nvl(num_rows,-1) NROWS, buffer_pool BUFF_POOL, n"); strcat(dyn_sts,"nvl(to_char(last_analyzed,DD/MM/YYYY - HH24:MI),-1) LAST_ANALIZE,n"); strcat (dyn_sts,"sum(blocks) n"); strcat (dyn_sts,"from dba_tables n"); strcat (dyn_sts,"group byowner,table_name,tablespace_name,nvl(blocks,-1),nvl(num_rows,-1), n"); strcat(dyn_sts,"buffer_pool,nvl(to_char(last_analyzed,DD/MM/YYYY - HH24:MI),-1)n"); strcat (dyn_sts,"order by 1,2 n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select owner OWNER,table_name TNAME, tablespace_name TBLNAME, n"); strcat (dyn_sts,"nvl(blocks,-1) BLOCK,nvl(num_rows,-1) NROWS, n"); strcat (dyn_sts,"sum(blocks) n"); strcat (dyn_sts,"from dba_tables n"); strcat (dyn_sts,"group byowner,table_name,tablespace_name,nvl(blocks,-1),nvl(num_rows,-1) n"); strcat (dyn_sts,"order by 1,2 n"); break; } break; case CASE_ALL_NON_SYS_INDEXES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"selectowner,index_name,tablespace_name, nvl(leaf_blocks,-1), nvl(num_rows,-1), n"); strcat (dyn_sts,"buffer_pool,nvl(to_char(last_analyzed,DD/MM/YYYY - HH24:MI),-1), n"); strcat (dyn_sts,"sum(leaf_blocks) n"); strcat (dyn_sts,"from dba_indexes n"); strcat (dyn_sts,"group by owner,index_name, tablespace_name, nvl(leaf_blocks,-1), n"); strcat (dyn_sts,"nvl(num_rows,-1),buffer_pool, nvl(to_char(last_analyzed,DD/MM/YYYY - HH24:MI),-1) n"); strcat (dyn_sts,"order by 1,2 n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"selectowner,index_name,tablespace_name, nvl(leaf_blocks,-1), n"); strcat (dyn_sts,"sum(leaf_blocks) n"); strcat (dyn_sts,"from dba_indexes n"); strcat (dyn_sts,"group by owner,index_name, tablespace_name, nvl(leaf_blocks,-1) n"); strcat (dyn_sts,"order by 1,2 n"); break; } break; case CASE_USER_DEFINED: Página 10
  11. 11. func_dyn_statement_set.c switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select * from (selectdistinct username, account_status, expiry_date, n"); strcat (dyn_sts,"default_tablespace,temporary_tablespace, profile, n"); strcat(dyn_sts,"to_char(created,DD/MM/YYYY - HH24:MI) from dba_users n"); strcat (dyn_sts,"union n"); strcat (dyn_sts,"select PUBLIC,OPEN,to_date(null), , , n"); strcat (dyn_sts,",to_char(to_date(null), n"); strcat (dyn_sts,"DD/MM/YYYY - HH24:MI)from dual) n"); strcat (dyn_sts,"order byinitcap(username) n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select distinctusername, n"); strcat (dyn_sts,"----------,to_date(null), n"); strcat (dyn_sts,"default_tablespace,n"); strcat (dyn_sts,"temporary_tablespace,profile, n"); strcat(dyn_sts,"to_char(created,DD/MM/YYYY - HH24:MI) from dba_users n"); strcat (dyn_sts,"union n"); strcat (dyn_sts,"select PUBLIC,OPEN,to_date(null), ----------, n"); strcat (dyn_sts,"----------,----------, to_char(to_date(null), n"); strcat (dyn_sts,"DD/MM/YYYY - HH24:MI)from dual n"); strcat (dyn_sts,"order by username n"); break; } break; case CASE_LIST_DATAFILE_REDO_CONTROL_FILES: strcpy (dyn_sts,"select file_name, tablespace_name,status from dba_data_files n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select member, LOG FILE, status fromv$logfile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name, CONTROL FILE, statusfrom v$controlfile n"); strcat (dyn_sts,"order by 1,2 n"); break; case CASE_LIST_DATAFILES_USED_BLOCKS: strcpy (dyn_sts,"select a.tablespace_name, a.file_name,a.bytes, n"); strcat (dyn_sts,"(b.maximum + c.blocks -1) *d.db_block_size highwater n"); strcat (dyn_sts,"from dba_data_files a, n"); strcat (dyn_sts,"(select file_id, max(block_id) maximumn"); strcat (dyn_sts,"from dba_extents n"); strcat (dyn_sts,"group by file_id ) b, n"); strcat (dyn_sts,"dba_extents c, n"); strcat (dyn_sts,"(select value db_block_size fromv$parameter where name=db_block_size) d n"); strcat (dyn_sts,"where a.file_id = b.file_id n"); Página 11
  12. 12. func_dyn_statement_set.c strcat (dyn_sts,"and c.file_id = b.file_id n"); strcat (dyn_sts,"and c.block_id = b.maximum n"); strcat (dyn_sts,"order by a.bytes, a.tablespace_name,a.file_name n"); break; case CASE_LIST_SORT_BY_USER: strcpy (dyn_sts,"select vss.value VALOR,substr(vsn.name,1,20) TYPE_SORT, n"); strcat (dyn_sts,"vs.sid SID, n"); strcat (dyn_sts,"substr(vs.osuser,1,20) OS_USER,substr(vs.username,1,20) DB_USER n"); strcat (dyn_sts,"from v$session vs, v$sesstat vss,v$statname vsn n"); strcat (dyn_sts,"where (vss.statistic# = vsn.statistic#)and n"); strcat (dyn_sts,"(vs.sid = vss.sid ) and n"); strcat (dyn_sts,"(vsn.name like %sort%) and n"); strcat (dyn_sts,"vss.value <> 0 n"); strcat (dyn_sts,"order by 1,2,3 n"); break; case CASE_LIST_LOCK_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select lo.addr,lo.kaddr, lo.sid SES, lo.type TIP, n"); strcat (dyn_sts,"lo.id1 OBJID, lo.id2,n"); strcat (dyn_sts,"lo.lmode, n"); strcat (dyn_sts,"lo.request REQT, n"); strcat (dyn_sts,"(selectltrim(object_type) n"); strcat (dyn_sts,"from all_objects whereobject_id=lo.id1) OBJ_TYP, n"); strcat (dyn_sts,"(selectltrim(owner)||.||ltrim(object_name) n"); strcat (dyn_sts,"from all_objects whereobject_id=lo.id1) OWN_OBJ, n"); strcat (dyn_sts,"(select sid SES n"); strcat (dyn_sts,"from v$session wherelockwait=lo.kaddr) LOC_SID, n"); strcat (dyn_sts,"ctime n"); strcat (dyn_sts,"from v$lock lo n"); strcat (dyn_sts,"order by lo.sid n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select lo.addr,lo.kaddr, lo.sid, n"); strcat (dyn_sts,"lo.type, lo.id1,lo.id2, n"); strcat (dyn_sts,"lo.lmode, n"); strcat (dyn_sts,"lo.request, n"); strcat (dyn_sts,"lo.id1, n"); strcat (dyn_sts,"lo.id1, n"); strcat (dyn_sts,"lo.kaddr, n"); strcat (dyn_sts,"lo.ctime n"); strcat (dyn_sts,"from v$lock lo n"); strcat (dyn_sts,"order by lo.sid n"); break; } break; case CASE_LIST_USER_BY_CPU_USAGE: strcpy (dyn_sts,"select vs.sid, vs.serial#, vs.type,vs.osuser, n"); strcat (dyn_sts,"to_char(logon_time,DD/MM/YYYY -HH24:MI:SS), n"); Página 12
  13. 13. func_dyn_statement_set.c/* strcat (dyn_sts,"sysdate - logon_time, n"); */ strcat (dyn_sts,"vs.process, vs.machine, vs.username,vss.value, n"); strcat (dyn_sts,"vs.program n"); strcat (dyn_sts,"from v$session vs, v$sesstat vss,v$statname vsn n"); strcat (dyn_sts,"where vss.statistic# = vsn.statistic#and n"); strcat (dyn_sts,"vs.sid = vss.sid and n"); strcat (dyn_sts,"vsn.name = CPU used by this sessionn"); strcat (dyn_sts,"and vss.value <> 0 n"); strcat (dyn_sts,"order by 10 n"); break; case CASE_SQL_STATEMENT_BY_THIS_USER: strcpy (dyn_sts,"select vsql.sql_text n"); strcat (dyn_sts,"from v$sqltext vsql n"); strcat (dyn_sts,"where vsql.address in ( selectvses.sql_address n"); strcat (dyn_sts,"from v$session vses n"); strcat (dyn_sts,"where vses.sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," )n"); strcat (dyn_sts,"order by vsql.piece n"); break; case CASE_REDO_LOGS_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select group#, thread#,sequence#, bytes, members, n"); strcat (dyn_sts,"archived, status,first_change#, n"); strcat(dyn_sts,"to_char(first_time,DD/MM/YYYY - HH24:MI) n"); strcat (dyn_sts,"from v$log n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select group#, thread#,sequence#, bytes, members, n"); strcat (dyn_sts,"archived, status,first_change#, n"); strcat (dyn_sts,"first_time n"); strcat (dyn_sts,"from v$log n"); break; } break; case CASE_ARCHIVED_LOGS_HISTORY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select thread#,sequence#, name, first_change#, n"); strcat (dyn_sts,"to_char(first_time,DD/MM/YYYY - HH24:MI:SS), n"); strcat (dyn_sts,"blocks, block_size,n"); strcat (dyn_sts,"to_char(completion_time,DD/MM/YYYY - HH24:MI:SS) n"); strcat (dyn_sts,"from v$archived_logorder by 6 n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select thread#, Página 13
  14. 14. func_dyn_statement_set.csequence#,time, n"); strcat (dyn_sts,"low_change#,high_change#, archive_name n"); strcat (dyn_sts,"from v$log_historyn"); break; } break; case CASE_REDO_LOG_RECOVERY_REPORT: strcpy (dyn_sts,"select a.group#, a.first_change#,b.member, a.sequence# n"); strcat (dyn_sts,"from v$log a, v$logfile b n"); strcat (dyn_sts,"where a.group# = b.group# n"); strcat (dyn_sts,"and a.status = CURRENT n"); break; case CASE_ARCHIVE_LOG_HISTROY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select thread#,sequence#, first_change#, n"); strcat (dyn_sts,"switch_change#, n"); strcat(dyn_sts,"to_char(first_time,DD/MM/YYYY - HH24:MI:SS) n"); strcat (dyn_sts,"from v$loghist n"); strcat (dyn_sts,"order by 5 n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select thread#,sequence#, first_change#, n"); strcat (dyn_sts,"switch_change#, n"); strcat (dyn_sts,"first_time n"); strcat (dyn_sts,"from v$loghist n"); strcat (dyn_sts,"order by 5 n"); break; } break; case CASE_SESSION_LATCH_WAITS_SQL: strcpy (dyn_sts,"select sw.sid , nvl(se.username,.) ,n"); strcat (dyn_sts,"nvl(se.status,.) , sq.sql_text n"); strcat (dyn_sts,"from v$session_wait sw, v$session se,v$sqltext sq n"); strcat (dyn_sts,"where sw.sid = se.sid and n"); strcat (dyn_sts,"se.sql_address = sq.address and n"); strcat (dyn_sts,"se.sql_hash_value = sq.hash_value andn"); strcat (dyn_sts,"sw.event = latch_free n"); strcat (dyn_sts,"order by 1 n"); break; case CASE_SESSION_PROGRAM_RUNNING_SQL: strcpy (dyn_sts,"select substr(v2.sid,1,5), n"); strcat (dyn_sts,"substr(v2.username,1,30), n"); strcat (dyn_sts,"program, sql_text n"); strcat (dyn_sts,"from sys.v_$sqlarea v1, n"); strcat (dyn_sts,"sys.v_$session v2 n"); strcat (dyn_sts,"where v1.address = v2.sql_address andn"); strcat (dyn_sts,"v1.hash_value = v2.sql_hash_value n"); break; case CASE_PRIVILEGES_BY_USER: strcpy (dyn_sts,"select decode (sa1.grantee#, 1,PUBLIC, u1.name), n"); strcat (dyn_sts,"substr (u2.name,1,25),substr(spm.name,1,40) n"); strcat (dyn_sts,"from sys.sysauth$ sa1, sys.sysauth$ Página 14
  15. 15. func_dyn_statement_set.csa2, sys.user$ u1, n"); strcat (dyn_sts,"sys.user$ u2, sys.system_privilege_mapspm n"); strcat (dyn_sts,"where sa1.grantee# = u1.user# and n"); strcat (dyn_sts,"sa1.privilege# = u2.user# and n"); strcat (dyn_sts,"u2.user# = sa2.grantee# and n"); strcat (dyn_sts,"sa2.privilege# = spm.privilege n"); strcat (dyn_sts,"union n"); strcat (dyn_sts,"select u.name, NULL,substr(spm.name,1,40) n"); strcat (dyn_sts,"from sys.system_privilege_map spm,sys.sysauth$ sa, n"); strcat (dyn_sts,"sys.user$ u n"); strcat (dyn_sts,"where sa.grantee#=u.user# and n"); strcat (dyn_sts,"sa.privilege# = spm.privilege n"); break; case CASE_DETAILED_LOCKING_CAUSES: strcpy (dyn_sts,"select nvl(S.USERNAME,Internal),L.SID, nvl(S.TERMINAL,None),n"); strcat (dyn_sts,"decode(command,0,None,decode(l.id2,0,U1.NAME||.||substr(T1.NAME,1,20),None)),n"); strcat (dyn_sts,"command,n"); strcat (dyn_sts,"L.LMODE,L.REQUEST,n"); strcat (dyn_sts,"l.id1||-||l.id2, n"); strcat (dyn_sts,"l.type || - || l.type n"); strcat (dyn_sts,"from v$lock l, v$session s, sys.user$u1, sys.obj$ t1 n"); strcat (dyn_sts,"where l.sid = s.sid and t1.obj# =decode (l.id2,0,l.id1,1) and n"); strcat (dyn_sts,"u1.user# = t1.owner# and s.type !=BACKGROUND n");/* strcat (dyn_sts,"order by 1,5"); */ break; case CASE_CURRENT_STATISTICS_VALUES: strcpy (dyn_sts,"select statistic#, name, value n"); strcat (dyn_sts,"from v$sysstat n"); strcat (dyn_sts,"order by name n"); break; case CASE_TABLE_DESCRIPTION_USER_TABLENAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"selecttablespace_name,owner, table_name, n"); strcat (dyn_sts,"nvl(to_char(num_rows),(Null)), n"); strcat (dyn_sts,"nvl(to_char(last_analyzed,YYYY/MM/DD-HH24:MI:SS),(Null)), n"); strcat(dyn_sts,"initial_extent,next_extent,n"); strcat(dyn_sts,"min_extents,max_extents,pct_increase,buffer_pool,n"); strcat (dyn_sts,"nvl(to_char(blocks),(Null)),n"); strcat(dyn_sts,"freelists,pct_free,ini_trans,max_trans,n"); strcat (dyn_sts,"freelist_groups n"); strcat (dyn_sts,"from dba_tables n"); if ( (strlen (opcion_uno) > 0) &&(strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } Página 15
  16. 16. func_dyn_statement_set.c else if ( (strlen(opcion_uno) == 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"wheretable_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and table_name= "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else strcat (dyn_sts,"n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"selecttablespace_name,owner, table_name, n"); strcat (dyn_sts,"nvl(to_char(num_rows),(Null)), n"); strcat (dyn_sts,"(Null), n"); strcat(dyn_sts,"initial_extent,next_extent,n"); strcat(dyn_sts,"min_extents,max_extents,pct_increase,(Null),n"); strcat (dyn_sts,"nvl(to_char(blocks),(Null)),n"); strcat(dyn_sts,"freelists,pct_free,ini_trans,max_trans,n"); strcat (dyn_sts,"freelist_groups n"); strcat (dyn_sts,"from dba_tables n"); if ( (strlen (opcion_uno) > 0) &&(strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"wheretable_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and table_name= "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else strcat (dyn_sts,"n"); break; Página 16
  17. 17. func_dyn_statement_set.c } break; case CASE_INDEX_DESCRIPTION_USER_INDEXNAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"selectowner,index_name,table_owner, n"); strcat(dyn_sts,"table_name,table_type,uniqueness,tablespace_name, n"); strcat(dyn_sts,"ini_trans,max_trans,initial_extent,next_extent, n"); strcat(dyn_sts,"min_extents,max_extents,pct_increase,freelists, n"); strcat(dyn_sts,"freelist_groups,pct_free,blevel,leaf_blocks n"); strcat (dyn_sts,"from dba_indexes n"); if ( (strlen (opcion_uno) > 0) &&(strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereindex_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and index_name= "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else strcat (dyn_sts,"n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"selectowner,index_name,table_owner, n"); strcat(dyn_sts,"table_name,table_type,uniqueness,tablespace_name, n"); strcat(dyn_sts,"ini_trans,max_trans,initial_extent,next_extent, n"); strcat(dyn_sts,"min_extents,max_extents,pct_increase,freelists, n"); strcat(dyn_sts,"freelist_groups,pct_free,blevel,leaf_blocks n"); strcat (dyn_sts,"from dba_indexes n"); if ( (strlen (opcion_uno) > 0) &&(strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"whereowner="); Página 17
  18. 18. func_dyn_statement_set.c strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereindex_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"whereowner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and index_name= "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else strcat (dyn_sts,"n"); } break; case CASE_CURRENT_ACTIVITY_REPORT: strcpy (dyn_sts,"SELECT address, buffer_gets,executions, "); strcat (dyn_sts,"round(buffer_gets/executions),SUBSTR(sql_text,1,150) "); strcat (dyn_sts,"FROM v$sqlarea WHERE executions > 0 AND"); strcat (dyn_sts,"buffer_gets > 10000 ORDER BY 3 desc, 3desc n"); break; case CASE_DICTIONARY_TABLE_COMMENTS: strcpy (dyn_sts,"SELECT TABLE_NAME, COMMENTS n"); strcat (dyn_sts,"FROM DICT ORDER BY 1 n"); break; case CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP: strcpy (dyn_sts,"SELECT /*+ RULE */ DC.TABLE_NAME,DC.COLUMN_NAME, DC.COMMENTS, "); strcat (dyn_sts,"TC.DATA_TYPE || DECODE( TC.DATA_TYPE, NUMBER, "); strcat (dyn_sts,"DECODE(TC.DATA_PRECISION,NULL,NULL, (|| TC.DATA_PRECISION || "); strcat (dyn_sts,"DECODE( TC.DATA_SCALE, NULL, NULL, ,|| TC.DATA_SCALE) || )), "); strcat (dyn_sts,"VARCHAR2, ( || TC.DATA_LENGTH ||), CHAR, ( || "); strcat (dyn_sts,"TC.DATA_LENGTH || ), NULL)SQL_TYPE, "); strcat (dyn_sts,"DECODE ( TC.DATA_TYPE, VARCHAR2, 0,CHAR, 0, NUMBER, 1, DATE, "); strcat (dyn_sts,"2 ,LONG, 3, RAW, 4, LONG ROW, 5,MLSLABEL, 6, -1) IMAGE_INDEX, "); strcat (dyn_sts,"TC.COLUMN_ID, TC.DATA_TYPE n"); strcat (dyn_sts,"FROM ALL_COL_COMMENTS DC, n"); strcat (dyn_sts,"( SELECT S.SYNONYM_NAME, S.TABLE_NAME,C.COLUMN_NAME, C.DATA_TYPE, "); strcat (dyn_sts,"C.DATA_PRECISION, C.DATA_SCALE,C.DATA_LENGTH, C.COLUMN_ID "); strcat (dyn_sts,"FROM SYS.ALL_TAB_COLUMNS C,SYS.ALL_SYNONYMS S "); strcat (dyn_sts,"WHERE C.OWNER = S.TABLE_OWNER ANDC.OWNER = SYS AND "); strcat (dyn_sts,"S.TABLE_OWNER = SYS AND C.TABLE_NAME Página 18
  19. 19. func_dyn_statement_set.c= S.TABLE_NAME AND "); /* -------------------------- hacer referencia a variable host--------------------- */ strcat (dyn_sts,"S.OWNER = PUBLIC "); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND S.SYNONYM_NAME ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } /*--------------------------------------------------------------------------------- */ strcat (dyn_sts,"UNION "); strcat (dyn_sts,"SELECT C.TABLE_NAME SYNONYM_NAME,C.TABLE_NAME, C.COLUMN_NAME, "); strcat (dyn_sts,"C.DATA_TYPE, C.DATA_PRECISION,C.DATA_SCALE, C.DATA_LENGTH, "); strcat (dyn_sts,"C.COLUMN_ID "); strcat (dyn_sts,"FROM SYS.ALL_TAB_COLUMNS C "); /* -------------------------- hacer referencia a variable host--------------------- */ /* strcat (dyn_sts,"WHERE C.OWNER = SYS ANDC.TABLE_NAME = :TABLE_NAME ) TC n"); */ strcat (dyn_sts,"WHERE C.OWNER = SYS "); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND C.TABLE_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," ) TC n"); } else { strcat (dyn_sts," ) TC n"); } /*--------------------------------------------------------------------------------- */ /* -------------------------- hacer referencia a variable host--------------------- */ strcat (dyn_sts,"WHERE DC.OWNER = SYS n"); /**** --AND DC.TABLE_NAME = ALL_OBJECTS n"); ****/ strcat (dyn_sts,"AND "); /*--------------------------------------------------------------------------------- */ /* -------------------------- hacer referencia a variable host--------------------- */ strcat (dyn_sts,"TC.TABLE_NAME = DC.TABLE_NAME AND "); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"TC.SYNONYM_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," AND n"); } /*--------------------------------------------------------------------------------- */ strcat (dyn_sts,"TC.COLUMN_NAME = DC.COLUMN_NAME n"); strcat (dyn_sts,"ORDER BY DC.TABLE_NAME, COLUMN_ID n"); break; case CASE_SGA_STATISTIC_GENERAL: strcpy (dyn_sts,"SELECT NUM, NAME, VALUE, ISDEFAULT,ISMODIFIED, ISADJUSTED, n"); strcat (dyn_sts,"DECODE( TYPE, 1, Boolean, 2,string, 3, integer, "); Página 19
  20. 20. func_dyn_statement_set.c strcat (dyn_sts,"4, file, 6, big integer,TO_CHAR(TYPE)) TYPE, "); strcat (dyn_sts,"DECODE(ISSES_MODIFIABLE, TRUE, yes,NULL) ISSES_MODIFIABLE, "); strcat (dyn_sts,"DECODE(ISSYS_MODIFIABLE, IMMEDIATE,immediate, DEFERRED, "); strcat (dyn_sts,"deferred, NULL) ISSYS_MODIFIABLE,DESCRIPTION n"); strcat (dyn_sts,"FROM sys.V_$PARAMETER n"); strcat (dyn_sts,"where (name = shared_pool_size orname = large_pool_size or "); strcat (dyn_sts,"name = create_bitmap_area_size orname = java_pool_size or "); strcat (dyn_sts,"name = sort_area_retained_size orname = sort_area_size or "); strcat (dyn_sts,"name = db_block_buffers or name =db_block_lru_latches or "); strcat (dyn_sts,"name = db_block_size or name =buffer_pool_keep or "); strcat (dyn_sts,"name = buffer_pool_recycle) "); strcat (dyn_sts,"ORDER BY NUM n"); break; case CASE_SGA_STATISTIC_MEMORY_USAGE: strcpy (dyn_sts,"SELECT shared pool, SS.NAME, SS.BYTES/1024, "); strcat (dyn_sts,"100 * SS.BYTES / S.VALUE ,S.VALUE "); strcat (dyn_sts,"FROM sys.V_$SGASTAT SS, sys.V_$SGA S"); strcat (dyn_sts,"WHERE S.NAME = Variable Size "); strcat (dyn_sts,"ORDER BY 1 desc, 3 DESC n"); break; case CASE_SGA_STATISTIC_INFORMATION: strcpy (dyn_sts,"SELECT NAME, VALUE/1024 VALUE "); strcat (dyn_sts,"FROM sys.V_$SGA n"); break; case CASE_ROW_CACHE_INFORMATION: strcpy (dyn_sts,"SELECT CACHE#, SUBORDINATE#, PARAMETER, GETS, "); strcat (dyn_sts,"GETMISSES, "); strcat (dyn_sts,"to_number(decode( GETS, 0, null, 100 *nvl(GETMISSES,0) / GETS)) "); strcat (dyn_sts,"SCANS, SCANMISSES, SCANCOMPLETES, n"); strcat (dyn_sts,"to_number(decode( SCANS, 0, NULL, 100 *nvl(SCANMISSES,0) / SCANS)) "); strcat (dyn_sts,"COUNT, USAGE, FIXED, FLUSHES, MODIFICATIONS "); strcat (dyn_sts,"FROM sys.V_$ROWCACHE "); strcat (dyn_sts,"ORDER BY GETMISSES,GETS n"); break; case CASE_PERFORMANCE_DISK_I_O: strcpy (dyn_sts,"SELECT SUBSTR(NAME,1,255) NAME, n"); strcat (dyn_sts,"DECODE(READTIM,0,PHYBLKRD, READTIM)READS, "); strcat (dyn_sts,"DECODE(WRITETIM,0,PHYBLKWRT, WRITETIM)WRITES, "); strcat(dyn_sts,"DECODE(READTIM+WRITETIM,0,PHYBLKRD+PHYBLKWRT, "); strcat (dyn_sts,"READTIM+WRITETIM) n"); strcat (dyn_sts,"FROM SYS.V_$DATAFILE DF,SYS.V_$FILESTAT FS "); strcat (dyn_sts,"WHERE DF.FILE# = FS.FILE# n"); strcat (dyn_sts,"ORDER BY 4 n"); break; case CASE_RECURSIVE_CALLS: strcpy (dyn_sts,"SELECT NAME, VALUE n"); strcat (dyn_sts,"FROM SYS.V_$SYSSTAT n"); strcat (dyn_sts,"WHERE NAME IN (execute count,recursive calls) n"); strcat (dyn_sts,"ORDER BY 1 n"); Página 20
  21. 21. func_dyn_statement_set.c break; case CASE_SYSTEM_EVENTS: strcpy (dyn_sts,"SELECT EVENT, TOTAL_WAITS,TOTAL_TIMEOUTS, n"); strcat (dyn_sts,"TIME_WAITED, AVERAGE_WAIT n"); strcat (dyn_sts,"FROM SYS.V_$SYSTEM_EVENT n"); strcat (dyn_sts,"ORDER BY TOTAL_WAITS, TIME_WAITED n"); break;/* -------------------------------------------------------------- */ /*#define CASE_SQL_AREA_ALL_ENTRIES 52 */ case CASE_SQL_AREA_ALL_ENTRIES: strcpy (dyn_sts,"SELECT TO_NUMBER(DECODE( A.EXECUTIONS,NULL,"); strcat (dyn_sts,"NULL, 0, NULL,A.BUFFER_GETS/A.EXECUTIONS)) AVG_GETS,"); strcat (dyn_sts,"A.SQL_TEXT, A.SHARABLE_MEM,A.PERSISTENT_MEM,"); strcat (dyn_sts,"A.RUNTIME_MEM, A.SORTS,A.VERSION_COUNT, A.LOADED_VERSIONS,"); strcat (dyn_sts,"A.OPEN_VERSIONS, A.USERS_OPENING,A.EXECUTIONS, "); strcat (dyn_sts,"A.USERS_EXECUTING, A.LOADS,A.FIRST_LOAD_TIME, "); strcat (dyn_sts,"A.INVALIDATIONS, A.PARSE_CALLS,A.DISK_READS, "); strcat (dyn_sts,"A.BUFFER_GETS, rawtohex(A.ADDRESS)SQL_ADDRESS, "); strcat (dyn_sts,"A.HASH_VALUE SQL_HASH_VALUE,A.ROWS_PROCESSED, "); strcat (dyn_sts,"A.COMMAND_TYPE, A.OPTIMIZER_MODE,PU.USERNAME PARSING_USER,"); strcat (dyn_sts,"PS.USERNAME PARSING_SCHEMA,A.KEPT_VERSIONS, A.MODULE,"); strcat (dyn_sts,"A.ACTION, A.SERIALIZABLE_ABORTS n"); strcat (dyn_sts,"FROM sys.V_$SQLAREA A, SYS.ALL_USERSPU, SYS.ALL_USERS PS n"); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_IDAND "); strcat (dyn_sts,"PS.USER_ID = A.PARSING_SCHEMA_ID n"); strcat (dyn_sts,"ORDER BYsharable_mem+persistent_mem+runtime_mem desc n"); break; /*#define CASE_SQL_AREA_CPU_USAGE 53 */ case CASE_SQL_AREA_CPU_USAGE: strcpy (dyn_sts,"SELECT TO_NUMBER(DECODE( A.EXECUTIONS,NULL, NULL,"); strcat (dyn_sts,"0, NULL, A.BUFFER_GETS/A.EXECUTIONS))AVG_GETS, "); strcat (dyn_sts,"A.SQL_TEXT, A.SHARABLE_MEM,A.PERSISTENT_MEM, "); strcat (dyn_sts,"A.RUNTIME_MEM, A.SORTS,A.VERSION_COUNT, "); strcat (dyn_sts,"A.LOADED_VERSIONS, A.OPEN_VERSIONS,A.USERS_OPENING,"); strcat (dyn_sts,"A.EXECUTIONS, A.USERS_EXECUTING,A.LOADS, "); strcat (dyn_sts,"A.FIRST_LOAD_TIME, A.INVALIDATIONS,A.PARSE_CALLS,"); strcat (dyn_sts,"A.DISK_READS, A.BUFFER_GETS,rawtohex(A.ADDRESS) SQL_ADDRESS,"); strcat (dyn_sts,"A.HASH_VALUE SQL_HASH_VALUE,A.ROWS_PROCESSED, "); strcat (dyn_sts,"A.COMMAND_TYPE, A.OPTIMIZER_MODE, Página 21
  22. 22. func_dyn_statement_set.cPU.USERNAME PARSING_USER,"); strcat (dyn_sts,"PS.USERNAME PARSING_SCHEMA,A.KEPT_VERSIONS, "); strcat (dyn_sts,"A.MODULE, A.ACTION,A.SERIALIZABLE_ABORTS n"); strcat (dyn_sts,"FROM sys.V_$SQLAREA A, SYS.ALL_USERSPU, "); strcat (dyn_sts,"SYS.ALL_USERS PS, v$session s n"); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_IDAND "); strcat (dyn_sts,"PS.USER_ID = A.PARSING_SCHEMA_ID and"); strcat (dyn_sts,"(s. sid in (SELECT sid FROM V$SESSTAT"); strcat (dyn_sts,"WHERE STATISTIC# = 12 and value > 0)and "); strcat (dyn_sts,"a.executions > 0 and s.sql_address =a.address) n"); strcat (dyn_sts,"ORDER BYsharable_mem+persistent_mem+runtime_mem desc n"); break; /*#define CASE_SQL_AREA_MEMORY_USAGE 54 */ case CASE_SQL_AREA_MEMORY_USAGE: strcpy (dyn_sts,"SELECT MAX(TO_NUMBER(DECODE(A.EXECUTIONS, NULL,"); strcat (dyn_sts,"NULL, 0, NULL,A.BUFFER_GETS/A.EXECUTIONS))) AVG_GETS,"); strcat (dyn_sts,"MAX(A.SHARABLE_MEM) SHARABLE_MEM, "); strcat (dyn_sts,"MAX(A.PERSISTENT_MEM) PERSISTENT_MEM,"); strcat (dyn_sts,"MAX(A.RUNTIME_MEM) RUNTIME_MEM,MAX(A.SORTS) SORTS, "); strcat (dyn_sts,"MAX(A.VERSION_COUNT) VERSION_COUNT, "); strcat (dyn_sts,"MAX(A.LOADED_VERSIONS) LOADED_VERSIONS,"); strcat (dyn_sts,"MAX(A.OPEN_VERSIONS) OPEN_VERSIONS, "); strcat (dyn_sts,"MAX(A.USERS_OPENING) USERS_OPENING, "); strcat (dyn_sts,"MAX(A.EXECUTIONS) EXECUTIONS, "); strcat (dyn_sts,"MAX(A.USERS_EXECUTING) USERS_EXECUTING,MAX(A.LOADS) LOADS,"); strcat (dyn_sts,"MAX(A.INVALIDATIONS)INVALIDATIONS,MAX(A.PARSE_CALLS) PARSE_CALLS, "); strcat (dyn_sts,"MAX(A.DISK_READS)DISK_READS,MAX(A.BUFFER_GETS) BUFFER_GETS, "); strcat (dyn_sts,"MAX(A.ROWS_PROCESSED) ROWS_PROCESSED,MAX(A.KEPT_VERSIONS) KEPT_VERSIONS, "); strcat (dyn_sts,"MAX(A.SERIALIZABLE_ABORTS)SERIALIZABLE_ABORTS n"); strcat (dyn_sts,"FROM sys.V_$SQLAREA A n"); break; /*#define CASE_SQL_AREA_BUFFER_GET_SUM 55 */ case CASE_SQL_AREA_BUFFER_GET_SUM: strcpy (dyn_sts,"SELECT TO_NUMBER(DECODE( A.EXECUTIONS,NULL, NULL, 0, "); strcat (dyn_sts,"NULL, A.BUFFER_GETS/A.EXECUTIONS))AVG_GETS, A.SQL_TEXT, "); strcat (dyn_sts,"A.SHARABLE_MEM, A.PERSISTENT_MEM,A.RUNTIME_MEM, A.SORTS, "); strcat (dyn_sts,"A.VERSION_COUNT, A.LOADED_VERSIONS,A.OPEN_VERSIONS, "); strcat (dyn_sts,"A.USERS_OPENING, A.EXECUTIONS,A.USERS_EXECUTING, "); strcat (dyn_sts,"A.LOADS, A.FIRST_LOAD_TIME,A.INVALIDATIONS, A.PARSE_CALLS,"); Página 22
  23. 23. func_dyn_statement_set.c strcat (dyn_sts,"A.DISK_READS, A.BUFFER_GETS,rawtohex(A.ADDRESS) SQL_ADDRESS, "); strcat (dyn_sts,"A.HASH_VALUE SQL_HASH_VALUE,A.ROWS_PROCESSED, "); strcat (dyn_sts,"A.COMMAND_TYPE, A.OPTIMIZER_MODE,PU.USERNAME PARSING_USER,"); strcat (dyn_sts,"PS.USERNAME PARSING_SCHEMA,A.KEPT_VERSIONS, A.MODULE, "); strcat (dyn_sts,"A.ACTION, A.SERIALIZABLE_ABORTS n"); strcat (dyn_sts,"FROM sys.V_$SQLAREA A, SYS.ALL_USERSPU, SYS.ALL_USERS PS "); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_IDAND "); strcat (dyn_sts,"PS.USER_ID = A.PARSING_SCHEMA_ID and"); strcat (dyn_sts,"buffer_gets > 1282729/10 n"); strcat (dyn_sts,"ORDER BY buffer_gets desc n"); break; /*#define CASE_INIT_PARAMETERS_VALUES_STATUS 56 */ case CASE_INIT_PARAMETERS_VALUES_STATUS: strcpy (dyn_sts,"SELECT NUM, NAME, VALUE, ISDEFAULT,ISMODIFIED, "); strcat (dyn_sts,"ISADJUSTED, DECODE( TYPE, 1, Boolean,2, string,"); strcat (dyn_sts,"3, integer, 4, file, 6, biginteger, "); strcat (dyn_sts,"TO_CHAR(TYPE)) TYPE,DECODE(ISSES_MODIFIABLE, "); strcat (dyn_sts,"TRUE, yes, NULL) ISSES_MODIFIABLE,"); strcat (dyn_sts,"DECODE(ISSYS_MODIFIABLE, IMMEDIATE,immediate, "); strcat (dyn_sts,"DEFERRED, deferred, NULL)ISSYS_MODIFIABLE, "); strcat (dyn_sts,"DESCRIPTION n"); strcat (dyn_sts,"FROM sys.V_$PARAMETER n"); strcat (dyn_sts,"ORDER BY NUM n"); break;/* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_sts,"SELECT TABLESPACE_NAME, BYTES/1024KBYTES, "); strcat (dyn_sts,"COUNT( *) NUM_EXTENTS, SUM(BYTES) /1024 SUM_KBYTES, "); strcat (dyn_sts,"Used Extents USAGE, ");/* strcat (dyn_sts,"DECODE( BYTES,:INITIAL_EXTENT,INITIAL_SIZE,CHANGED_SIZE), "); */ strcat (dyn_sts,"TO_CHAR(BYTES,99999999999), "); strcat (dyn_sts,"BYTES ");/* strcat (dyn_sts,"FILE_ID, EXTENT_ID "); */ strcat (dyn_sts,"FROM SYS.DBA_EXTENTS n"); if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"WHERE TABLESPACE_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } strcat (dyn_sts,"GROUP BY TABLESPACE_NAME, BYTES/1024,");/* strcat (dyn_sts,"DECODE( BYTES,:INITIAL_EXTENT,INITIAL_SIZE,CHANGED_SIZE), "); */ strcat (dyn_sts,"BYTES,"); strcat (dyn_sts,"BYTES ");/* strcat (dyn_sts,"FILE_ID, EXTENT_ID "); */ Página 23
  24. 24. func_dyn_statement_set.c strcat (dyn_sts,"n"); strcat (dyn_sts,"UNION "); strcat (dyn_sts,"SELECT TABLESPACE_NAME, BYTES/1024KBYTES, "); strcat (dyn_sts,"COUNT (*) NUM_EXTENTS, SUM(BYTES)/1024SUM_KBYTES, "); strcat (dyn_sts,"Free Chunks USAGE, "); strcat (dyn_sts,"0CERO, "); strcat (dyn_sts,"to_number(null) bytes ");/* strcat (dyn_sts,"to_number(null),to_number(null) n");*/ strcat (dyn_sts,"FROM SYS.DBA_FREE_SPACE "); if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"WHERE TABLESPACE_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } strcat (dyn_sts,"GROUP BY TABLESPACE_NAME, BYTES/1024"); strcat (dyn_sts,"ORDER BY 1,2,3 n"); break; case CASE_SHOW_NLS_PARAMETERS: strcpy (dyn_sts,"select p.name, d.VALUE value_database,"); strcat (dyn_sts,"i.VALUE value_instance,s.VALUEvalue_session, "); strcat (dyn_sts,"p.comment$ comments n"); strcat (dyn_sts,"from sys.props$ p,nls_session_parameters s, "); strcat (dyn_sts,"nls_database_parameters d,nls_instance_parameters i "); strcat (dyn_sts,"where p.name = s.PARAMETER (+) and "); strcat (dyn_sts,"p.name = d.PARAMETER (+) and p.name =i.PARAMETER (+) n"); break; case CASE_CONTROL_FILES_STATUS: strcpy (dyn_sts,"SELECT NAME, NVL( STATUS, OK) STATUSn"); strcat (dyn_sts,"FROM sys.V_$CONTROLFILE n"); break; case CASE_SORT_SEGMENTS_USERS: strcpy (dyn_sts,"SELECT TABLESPACE_NAME, SEGMENT_FILE,SEGMENT_BLOCK, "); strcat (dyn_sts,"EXTENT_SIZE, CURRENT_USERS,TOTAL_EXTENTS, "); strcat (dyn_sts,"TOTAL_BLOCKS, USED_EXTENTS,USED_BLOCKS, FREE_EXTENTS,"); strcat (dyn_sts,"FREE_BLOCKS, ADDED_EXTENTS,EXTENT_HITS, FREED_EXTENTS,"); strcat (dyn_sts,"FREE_REQUESTS, MAX_SIZE, MAX_BLOCKS,MAX_USED_SIZE, "); strcat (dyn_sts,"MAX_USED_BLOCKS, MAX_SORT_SIZE,MAX_SORT_BLOCKS, "); strcat (dyn_sts,"TO_NUMBER(NULL) RELATIVE_FNO n"); strcat (dyn_sts,"FROM SYS.V_$SORT_SEGMENT n"); if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"WHERE TABLESPACE_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } strcat (dyn_sts,"ORDER BY TABLESPACE_NAME,SEGMENT_FILEn"); break; case CASE_ORACLE_QUOTAS: strcpy (dyn_sts,"SELECT Q.TABLESPACE_NAME, Q.USERNAME,Q.BYTES/1024 KBYTES, "); Página 24
  25. 25. func_dyn_statement_set.c strcat (dyn_sts,"DECODE( Q.MAX_BYTES, -1, -1,Q.MAX_BYTES/1024) MAX_KBYTES, "); strcat (dyn_sts,"Q.BLOCKS, DECODE( Q.MAX_BLOCKS, -1, -1,Q.MAX_BLOCKS) MAX_BLOCKS, "); strcat (dyn_sts,"TO_NUMBER(DECODE( Q.MAX_BYTES, -1,NULL, 100*Q.BYTES/Q.MAX_BYTES)) USAGE_PERCENT "); strcat (dyn_sts,"FROM SYS.DBA_TS_QUOTAS Q n"); if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"WHERE TABLESPACE_NAME = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } strcat (dyn_sts,"ORDER BY TABLESPACE_NAME n"); break; case CASE_TABLE_GENERAL_DESCRIPTION: strcpy (dyn_sts,"SELECT SEL.*, COMMENTS "); strcat (dyn_sts,"FROM ( "); strcat (dyn_sts,"SELECT O.OWNER, O.OBJECT_NAMETABLE_NAME, O.OBJECT_TYPE, "); strcat (dyn_sts,"O.OBJECT_TYPE R_OBJECT_TYPE, DECODE(O.OBJECT_TYPE, TABLE, 0, VIEW, 1, 5) IMAGE_INDEX, "); strcat (dyn_sts,"O.OBJECT_NAME NAME, O.OWNERSYNONYM_OWNER, O.CREATED, O.LAST_DDL_TIME, O.STATUS, "); strcat (dyn_sts,"T.TABLESPACE_NAME, T.PCT_FREE,T.PCT_USED, T.PCT_INCREASE, T.NEXT_EXTENT / 1024 NEXT_EXTENT, "); strcat (dyn_sts,"T.INI_TRANS, T.MAX_TRANS,T.INITIAL_EXTENT / 1024 INITIAL_EXTENT, T.MIN_EXTENTS, "); strcat (dyn_sts,"T.MAX_EXTENTS, T.FREELISTS,T.FREELIST_GROUPS, T.BACKED_UP, T.NUM_ROWS, T.BLOCKS, "); strcat (dyn_sts,"T.EMPTY_BLOCKS, T.AVG_SPACE,T.CHAIN_CNT, T.AVG_ROW_LEN, T.DEGREE, T.INSTANCES, "); strcat (dyn_sts,"LTRIM(T.CACHE) CACHE, TO_DATE(NULL)LAST_ANALYZED, YES LOGGING, NO PARTITIONED, "); strcat (dyn_sts,"DEFAULT BUFFER_POOL, IOT_NAME, IOT_TYPE, TABLE_LOCK, "); strcat (dyn_sts," NESTED, TO_NUMBER(0)AVG_SPACE_FREELIST_BLOCKS, TO_NUMBER(NULL) NUM_FREELIST_BLOCKS, "); strcat (dyn_sts,"TO_NUMBER(NULL) SAMPLE_SIZE, nulltable_type_owner, null table_type, SECONDARY, "); strcat (dyn_sts," ROW_MOVEMENT, GLOBAL_STATS, USER_STATS, DURATION, SKIP_CORRUPT, "); strcat (dyn_sts," MONITORING, N TEMPORARY n"); strcat (dyn_sts,"FROM SYS.ALL_OBJECTS O, ALL_TABLES Tn"); strcat (dyn_sts,"WHERE n"); if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"O.OWNER = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," AND T.OWNER = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," AND n"); } strcat (dyn_sts,"T.TABLE_NAME = O.OBJECT_NAME ANDO.OBJECT_TYPE = TABLE n"); strcat (dyn_sts,") SEL, SYS.ALL_TAB_COMMENTS C n"); strcat (dyn_sts,"WHERE C.OWNER = SEL.OWNER ANDC.TABLE_NAME = SEL.TABLE_NAME AND n"); strcat (dyn_sts,"SEL.OBJECT_TYPE = TABLE n"); strcat (dyn_sts,"ORDER BYNLSSORT(SEL.NAME,NLS_SORT=BINARY) n"); break; case CASE_TABLE_COLUMN_DESCRIPTION: strcpy (dyn_sts,"select c.owner,c.table_name,column_namen"); strcat (dyn_sts,"from sys.all_cons_columns cc, Página 25

×