Your SlideShare is downloading. ×
0
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Orastat line command
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Orastat line command

462

Published on

A simple orastat command for Oracle 8, 9, 10 and 11, like onstat do for Informix IDS Database. You can use for free modificaction.

A simple orastat command for Oracle 8, 9, 10 and 11, like onstat do for Informix IDS Database. You can use for free modificaction.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
462
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. ********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: CASE_CONSTANT_DEFINITION.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#define CASE_ORACLE_VERSION 0#define CASE_ACTIVE_PARAMETERS 1#define CASE_USERS_CONNECTED 2#define CASE_WAIT_STATISTICS 3#define CASE_DATAFILE_I_0 4#define CASE_DATAFILE_BLOCKS_R_W 5#define CASE_WAIT_EVENTS 6#define CASE_INSTANCE_STATUS 7#define CASE_TEMPORAL_SPACE_BY_USER 8#define CASE_TOT_FREELIST_WAIT_PERCENT 9#define CASE_LAST_CHECKPOINT_TIME 10#define CASE_LIST_TABLESPACES 11#define CASE_ACTIVE_TRANSACTIONS 12#define CASE_LATCH_DETAILS 13#define CASE_RESOURCE_LIMITS 14#define CASE_LIST_DATAFILES 15#define CASE_LIST_DATAFILES_NEW_9I 16#define CASE_LIST_TABLESPACES_NEW_9I 17#define CASE_ACTIVE_SESSIONS 18#define CASE_SESSIONS_WAITS 19#define CASE_DEFAULT_STORAGE_SETS_TABLESPACE 20#define CASE_ALL_TABLES_STORAGE_SETTINGS 21
  • 2. #define CASE_ALL_NON_SYS_TABLES_SETTINGS 22#define CASE_ALL_NON_SYS_INDEXES_SETTINGS 23#define CASE_USER_DEFINED 24#define CASE_LIST_DATAFILE_REDO_CONTROL_FILES 25#define CASE_LIST_DATAFILES_USED_BLOCKS 26#define CASE_LIST_SORT_BY_USER 27#define CASE_LIST_LOCK_STATUS 28#define CASE_LIST_USER_BY_CPU_USAGE 29#define CASE_SQL_STATEMENT_BY_THIS_USER 30#define CASE_REDO_LOGS_STATUS 31#define CASE_ARCHIVED_LOGS_HISTORY 32#define CASE_REDO_LOG_RECOVERY_REPORT 33#define CASE_ARCHIVE_LOG_HISTROY 34#define CASE_SESSION_LATCH_WAITS_SQL 35#define CASE_SESSION_PROGRAM_RUNNING_SQL 36#define CASE_PRIVILEGES_BY_USER 37#define CASE_DETAILED_LOCKING_CAUSES 38#define CASE_CURRENT_STATISTICS_VALUES 39#define CASE_TABLE_DESCRIPTION_USER_TABLENAME 40#define CASE_INDEX_DESCRIPTION_USER_INDEXNAME 41#define CASE_CURRENT_ACTIVITY_REPORT 42#define CASE_DICTIONARY_TABLE_COMMENTS 43#define CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP 44#define CASE_SGA_STATISTIC_GENERAL 45#define CASE_SGA_STATISTIC_MEMORY_USAGE 46#define CASE_SGA_STATISTIC_INFORMATION 47#define CASE_ROW_CACHE_INFORMATION 48#define CASE_PERFORMANCE_DISK_I_O 49#define CASE_RECURSIVE_CALLS 50#define CASE_SYSTEM_EVENTS 51#define CASE_SQL_AREA_ALL_ENTRIES 52#define CASE_SQL_AREA_CPU_USAGE 53#define CASE_SQL_AREA_MEMORY_USAGE 54#define CASE_SQL_AREA_BUFFER_GET_SUM 55#define CASE_INIT_PARAMETERS_VALUES_STATUS 56#define CASE_TABLESPACE_FRAGMENTATION 57--- ------ -----------------------------------------------------------------------------------------------------------------------------------------------------
  • 3. ----------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: CASE_CONSTANT_FUNC_DEF.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#define FUNC_DB_BLOCK_SIZE 1#define FUNC_COMMAND_SQL 2#define FUNC_LOCK_MODE 3#define FUNC_LOCK_NAME_MODE 4#define FUNC_DB_BLOCK_SIZE0 5#define FUNC_DB_OBJECT_TYPE 6#define FUNC_DB_OBJECT_OWNER_NAME 7#define FUNC_DB_SESSION_SID 8#define FUNC_CONVERT_HH_MM_SS 9#define FUNC_DB_COMP_TBLSPC_INI_EXT 10--- ---
  • 4. --- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: CASE_CONSTANT_SQL_STMT_DEF.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* Inicio de la programacion */#define CASE_ORACLE_VERSION 0#define CASE_ACTIVE_PARAMETERS 1#define CASE_USERS_CONNECTED 2#define CASE_WAIT_STATISTICS 3#define CASE_DATAFILE_I_0 4#define CASE_DATAFILE_BLOCKS_R_W 5#define CASE_WAIT_EVENTS 6#define CASE_INSTANCE_STATUS 7#define CASE_TEMPORAL_SPACE_BY_USER 8#define CASE_TOT_FREELIST_WAIT_PERCENT 9#define CASE_LAST_CHECKPOINT_TIME 10
  • 5. #define CASE_LIST_TABLESPACES 11#define CASE_ACTIVE_TRANSACTIONS 12#define CASE_LATCH_DETAILS 13#define CASE_RESOURCE_LIMITS 14#define CASE_LIST_DATAFILES 15#define CASE_LIST_DATAFILES_NEW_9I 16#define CASE_LIST_TABLESPACES_NEW_9I 17#define CASE_ACTIVE_SESSIONS 18#define CASE_SESSIONS_WAITS 19#define CASE_DEFAULT_STORAGE_SETS_TABLESPACE 20#define CASE_ALL_TABLES_STORAGE_SETTINGS 21#define CASE_ALL_NON_SYS_TABLES_SETTINGS 22#define CASE_ALL_NON_SYS_INDEXES_SETTINGS 23#define CASE_USER_DEFINED 24#define CASE_LIST_DATAFILE_REDO_CONTROL_FILES 25#define CASE_LIST_DATAFILES_USED_BLOCKS 26#define CASE_LIST_SORT_BY_USER 27#define CASE_LIST_LOCK_STATUS 28#define CASE_LIST_USER_BY_CPU_USAGE 29#define CASE_SQL_STATEMENT_BY_THIS_USER 30#define CASE_REDO_LOGS_STATUS 31#define CASE_ARCHIVED_LOGS_HISTORY 32#define CASE_REDO_LOG_RECOVERY_REPORT 33#define CASE_ARCHIVE_LOG_HISTROY 34#define CASE_SESSION_LATCH_WAITS_SQL 35#define CASE_SESSION_PROGRAM_RUNNING_SQL 36#define CASE_PRIVILEGES_BY_USER 37#define CASE_DETAILED_LOCKING_CAUSES 38#define CASE_CURRENT_STATISTICS_VALUES 39#define CASE_TABLE_DESCRIPTION_USER_TABLENAME 40#define CASE_INDEX_DESCRIPTION_USER_INDEXNAME 41#define CASE_CURRENT_ACTIVITY_REPORT 42#define CASE_DICTIONARY_TABLE_COMMENTS 43#define CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP 44#define CASE_SGA_STATISTIC_GENERAL 45#define CASE_SGA_STATISTIC_MEMORY_USAGE 46#define CASE_SGA_STATISTIC_INFORMATION 47#define CASE_ROW_CACHE_INFORMATION 48#define CASE_PERFORMANCE_DISK_I_O 49#define CASE_RECURSIVE_CALLS 50
  • 6. #define CASE_SYSTEM_EVENTS 51#define CASE_SQL_AREA_ALL_ENTRIES 52#define CASE_SQL_AREA_CPU_USAGE 53#define CASE_SQL_AREA_MEMORY_USAGE 54#define CASE_SQL_AREA_BUFFER_GET_SUM 55#define CASE_INIT_PARAMETERS_VALUES_STATUS 56#define CASE_TABLESPACE_FRAGMENTATION 57#define CASE_SHOW_NLS_PARAMETERS 58#define CASE_CONTROL_FILES_STATUS 59#define CASE_SORT_SEGMENTS_USERS 60#define CASE_ORACLE_QUOTAS 61#define CASE_TABLE_GENERAL_DESCRIPTION 62#define CASE_TABLE_COLUMN_DESCRIPTION 63#define CASE_TABLE_CONSTRAINTS 64#define CASE_INDEX_GENERAL_DESCRIPTION 65/* Agregado el 19-01-2004 */#define CASE_AUDIT_DEFINITION 66#define CASE_SHOW_SEGMENTS_EXTENTS 67#define CASE_SHOW_EXTENTS_INSIDE_DATAFILES 68#define CASE_SHOW_USER_LISTS 69#define CASE_SHOW_ROLES_PRIVILEGES 70#define CASE_SHOW_PRIVILEGES_COLUMNS 71#define CASE_SHOW_LOCKS_VIEWS 72#define CASE_GRAPH_LOCK_WAITS 73#define CASE_OBJECT_ACCESS_SESSION 74#define CASE_SHOW_LATCHES 75#define CASE_SHOW_STATISTICS 76#define CASE_SHOW_TRANSACTIONS 77#define CASE_SHOW_DATAFILES_STATUS 78#define CASE_SHOW_DB_OBJECT_CACHE 79/* Agregado el 22-01-2004 */#define CASE_TABLE_ALERT_EXTENT_USED 80#define CASE_INDEX_ALERT_EXTENT_USED 81/* Agregado el 18-03-2004 */#define CASE_USER_TIME_WORKING 82#define CASE_IS_USER_WORKING 83
  • 7. /* Agregado el 22-03-2004 */#define CASE_VER_SQL_PROGRAM 84/* Agregado el 07-04-2004 */#define CASE_SQL_SESS_IO 85#define CASE_SQL_SESSION_EVENT 86#define CASE_SQL_SESSION_WAIT 87#define CASE_SQL_SESSION_LONG_OPER 88#define CASE_SQL_LOCKED_OBJECTS 89/* Agregado el 13-04-2004 */#define CASE_SQL_TRANSACTION_DETAIL 90/* Agregado el 14-04-2004 */#define CASE_SQL_LOCK_MEDIUM_INFO 91#define CASE_SQL_LOCK_FULL_INFO 92#define CASE_SQL_LOCK_BY_SESSION_ID 93#define CASE_SQL_WHO_IS_WAITING_FOR 94#define CASE_SQL_WHICH_SQL_RUNNING 95#define CASE_WHICH_OBJECTS_LOCKED_BY_USER 96/* Agregado el 25-Agosto-2005 */#define CASE_BUFFER_CACHE_DEFINED 97#define CASE_BUFFER_CACHE_TOTAL_SIZE 98#define CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE 99#define CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE 100--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---***************************************************************************************************************************************************************************************************************************
  • 8. ****************************************************************************************************************************************************************************************************************************** ****** ****** ARCHIVO: CONSTANT_DEFINITION.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#define MAX_NRO_OPCION 100 // OPCION INCLUSIVE // /* Modificado el 25-Ago-2005 - 14:00 (ex valor 99) */ /* Modificado el 25-Ago-2005 - 14:00 (ex valor 98) */ /* Modificado el 25-Ago-2005 - 14:00 (ex valor 97) */ /* Modificado el 25-Ago-2005 - 14:00 (ex valor 96) */ /* Modificado el 18-03-2004 - 14:00 (ex valor 81) */ /* Modificado el 18-03-2004 - 16:45 (ex valor 82) */ /* Modificado el 22-03-2004 - 10:13 (ex valor 83) */ /* Modificado el 07-04-2004 - 13:40 (ex valor 84) */ /* Modificado el 07-04-2004 - 14:20 (ex valor 85) */ /* Modificado el 07-04-2004 - 14:33 (ex valor 86) */ /* Modificado el 07-04-2004 - 14:33 (ex valor 87) */ /* Modificado el 07-04-2004 - 14:33 (ex valor 88) */ /* Modificado el 07-04-2004 - 14:33 (ex valor 89) */ /* Modificado el 14-04-2004 - 09:59 (ex valor 90) */ /* Modificado el 14-04-2004 - 09:59 (ex valor 91) */ /* Modificado el 14-04-2004 - 11:30 (ex valor 92) */ /* Modificado el 14-04-2004 - 12:11 (ex valor 93) */ /* Modificado el 14-04-2004 - 12:11 (ex valor 94) */ /* Modificado el 14-04-2004 - 15:08 (ex valor 95) */
  • 9. #define MAX_ITEMS 512#define MAX_VNAME_LEN 512#define MAX_INAME_LEN 512#define MAX_BUFFER 512#define MAX_LINE 512#define MAX_STMT 16384#define MAX_STMT_SIZE 16384#define MAX_BIND_VARIABLE 512#define MAX_VAR_SIZE 512#define MAX_VERSION_LEN 256#define MAX_LEN_ARG 512#define MAX_LEN_CONNECT 512#define MAX_WORD_STMT 256#define MAX_LEN_DATOS_AUXI 1024#define MAX_LEN_VARCHAR 128#define SI_PROCESAR 1#define NO_PROCESAR 0#define SI_ERROR 1#define NO_ERROR 0#define ASCII_SEPARADOR 124#define ASCII_FIN_LINEA 0#define ASCII_SLASH 47#define ASCII_ARROBA 64#define ASCII_PUNTO 46#define ASCII_SPACE 32#define ASCII_COMA 44#define ASCII_IGUAL 61#define ASCII_MENOR 60#define ASCII_MAYOR 62#define ASCII_PARENT_IZQ 40#define ASCII_PARENT_DER 41#define ASCII_COMILLA 34#define ASCII_PORCENTAJE 37#define ASCII_COMITA_SIMPLE 39#define ASCII_SIGNO_MAS 43#define ASCII_ASTERISCO 42
  • 10. #define ASCII_SIGNO_MENOS 45#define ASCII_PUNTO_Y_COMA 59#define ASCII_DOS_PUNTOS 58#define ASCII_ENTER 13#define ASCII_RETURN 10/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#define USERNAME 1#define PASSWORD 2#define CONEXION 3/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: CONSTANT_ORACLE_VERSIONS.h ****** ****** *****************************************************************************************************************************************************
  • 11. ****************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#define VERSION_ORACLE_734 734#define VERSION_ORACLE_816 816#define VERSION_ORACLE_817 817#define VERSION_ORACLE_901 901#define VERSION_ORACLE_902 902#define VERSION_ORACLE_910 910#define VERSION_ORACLE_920 920#define VERSION_ORACLE_1000 1000#define VERSION_ORACLE_UNK 000--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: decode_command_oracle.c ****** ****** ****************************************************************************
  • 12. ******************************************************************************************************************************************************************************************************************************************************************************************************* ****** ***#include <stdio.h>#include <stdlib.h>#include <string.h>extern vaciar_cadena ();char *decode_command_oracle (int nro_decodificar) { static char dato_1[64]; vaciar_cadena (dato_1,64); switch (nro_decodificar) { case 0: strcpy (dato_1,"BACKGROUND"); break; case 1: strcpy (dato_1,"CREATE TABLE"); break; case 2: strcpy (dato_1,"INSERT"); break; case 3: strcpy (dato_1,"SELECT"); break; case 4: strcpy (dato_1,"CREATE CLUSTER"); break; case 5: strcpy (dato_1,"ALTER CLUSTER"); break; case 6: strcpy (dato_1,"UPDATE"); break; case 7: strcpy (dato_1,"DELETE"); break; case 8: strcpy (dato_1,"DROP"); break; case 9: strcpy (dato_1,"CREATE INDEX"); break; case 10: strcpy (dato_1,"DROP INDEX"); break; case 11: strcpy (dato_1,"ALTER INDEX"); break; case 12: strcpy (dato_1,"DROP TABLE"); break; case 13: strcpy (dato_1,"CREATE SEQUENCE"); break; case 14: strcpy (dato_1,"ALTER SEQUENCE"); break; case 15: strcpy (dato_1,"ALTER TABLE"); break; case 16: strcpy (dato_1,"DROP SEQUENCE"); break; case 17: strcpy (dato_1,"GRANT"); break; case 18: strcpy (dato_1,"REVOKE"); break; case 19: strcpy (dato_1,"CREATE SYNONYM"); break; case 20: strcpy (dato_1,"DROP SYNONYM"); break;
  • 13. case 21: strcpy (dato_1,"CREATE VIEW"); break;case 22: strcpy (dato_1,"DROP VIEW"); break;case 23: strcpy (dato_1,"VALIDATE INDEX"); break;case 24: strcpy (dato_1,"CREATE PROCEDURE"); break;case 25: strcpy (dato_1,"ALTER PROCEDURE"); break;case 26: strcpy (dato_1,"LOCK TABLE"); break;case 27: strcpy (dato_1,"NO OPERATION"); break;case 28: strcpy (dato_1,"RENAME"); break;case 29: strcpy (dato_1,"COMMENT"); break;case 30: strcpy (dato_1,"AUDIT"); break;case 31: strcpy (dato_1,"NOAUDIT"); break;case 32: strcpy (dato_1,"CREATE EXTERNAL DATABASE"); break;case 33: strcpy (dato_1,"DROP EXTERNAL DATABASE"); break;case 34: strcpy (dato_1,"CREATE DATABASE"); break;case 35: strcpy (dato_1,"ALTER DATABASE"); break;case 36: strcpy (dato_1,"CREATE ROLLBACK SEGMENT"); break;case 37: strcpy (dato_1,"ALTER ROLLBACK SEGMENT"); break;case 38: strcpy (dato_1,"DROP ROLLBACK SEGMENT"); break;case 39: strcpy (dato_1,"CREATE TABLESPACE"); break;case 40: strcpy (dato_1,"ALTER TABLESPACE"); break;case 41: strcpy (dato_1,"DROP TABLESPACE"); break;case 42: strcpy (dato_1,"ALTER SESSION"); break;case 43: strcpy (dato_1,"ALTER USER"); break;case 44: strcpy (dato_1,"COMMIT"); break;case 45: strcpy (dato_1,"ROLLBACK"); break;case 46: strcpy (dato_1,"SAVEPOINT"); break;case 47: strcpy (dato_1,"PL/SQL EXECUTE"); break;case 48: strcpy (dato_1,"SET TRANSACTION"); break;case 49: strcpy (dato_1,"ALTER SYSTEM SWITCH LOG"); break;case 50: strcpy (dato_1,"EXPLAIN"); break;case 51: strcpy (dato_1,"CREATE USER"); break;case 52: strcpy (dato_1,"CREATE ROLE"); break;case 53: strcpy (dato_1,"DROP USER"); break;case 54: strcpy (dato_1,"DROP ROLE"); break;case 55: strcpy (dato_1,"SET ROLE"); break;case 56: strcpy (dato_1,"CREATE SCHEMA"); break;case 57: strcpy (dato_1,"CREATE CONTROL FILE"); break;case 58: strcpy (dato_1,"ALTER TRACING"); break;case 59: strcpy (dato_1,"CREATE TRIGGER"); break;case 60: strcpy (dato_1,"ALTER TRIGGER"); break;
  • 14. case 61: strcpy (dato_1,"DROP TRIGGER"); break; case 62: strcpy (dato_1,"ANALYZE TABLE"); break; case 63: strcpy (dato_1,"ANALYZE INDEX"); break; case 64: strcpy (dato_1,"ANALYZE CLUSTER"); break; case 65: strcpy (dato_1,"CREATE PROFILE"); break; case 66: strcpy (dato_1,"DROP PROFILE"); break; case 67: strcpy (dato_1,"ALTER PROFILE"); break; case 68: strcpy (dato_1,"DROP PROCEDURE"); break; case 69: strcpy (dato_1,"DROP PROCEDURE"); break; case 70: strcpy (dato_1,"ALTER RESOURCE COST"); break; case 71: strcpy (dato_1,"CREATE SNAPSHOT LOG"); break; case 72: strcpy (dato_1,"ALTER SNAPSHOT LOG"); break; case 73: strcpy (dato_1,"DROP SNAPSHOT LOG"); break; case 74: strcpy (dato_1,"CREATE SNAPSHOT"); break; case 75: strcpy (dato_1,"ALTER SNAPSHOT"); break; case 76: strcpy (dato_1,"DROP SNAPSHOT"); break; case 79: strcpy (dato_1,"ALTER ROLE"); break; case 85: strcpy (dato_1,"TRUNCATE TABLE"); break; case 86: strcpy (dato_1,"TRUNCATE CLUSTER"); break; case 88: strcpy (dato_1,"ALTER VIEW"); break; case 91: strcpy (dato_1,"CREATE FUNCTION"); break; case 92: strcpy (dato_1,"ALTER FUNCTION"); break; case 93: strcpy (dato_1,"DROP FUNCTION"); break; case 94: strcpy (dato_1,"CREATE PACKAGE"); break; case 95: strcpy (dato_1,"ALTER PACKAGE"); break; case 96: strcpy (dato_1,"DROP PACKAGE"); break; case 97: strcpy (dato_1,"CREATE PACKAGE BODY"); break; case 98: strcpy (dato_1,"ALTER PACKAGE BODY"); break; case 99: strcpy (dato_1,"DROP PACKAGE BODY"); break; default: strcpy (dato_1,"-"); break; } return dato_1; }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---
  • 15. --- ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: decode_lock_mode.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>#include <stdlib.h>#include <string.h>extern vaciar_cadena ();char *decode_lock_mode (int nro_decodificar) { static char dato_1[64]; vaciar_cadena (dato_1,64); switch (nro_decodificar) { case 1: strcpy (dato_1,"No Lock"); break; case 2: strcpy (dato_1,"Row Share"); break; case 3: strcpy (dato_1,"Row Exclusive"); break; case 4: strcpy (dato_1,"Share"); break; case 5: strcpy (dato_1,"Share Row Exclusive"); break; case 6: strcpy (dato_1,"Exclusive"); break;
  • 16. default: strcpy (dato_1,"NONE"); break; } return dato_1; }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: decode_name_lock.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>#include <stdlib.h>#include <string.h>extern vaciar_cadena ();extern char *decode_name_lock (char *cad_decodificar) { static char dato_1[256];
  • 17. vaciar_cadena (dato_1,256);if ( strncmp (cad_decodificar,"BL",2) == 0) strcpy (dato_1,"Buffer hash table instance lock"); elseif ( strncmp (cad_decodificar,"CF",2) == 0) strcpy (dato_1," Control file schema global enqueue lock"); elseif ( strncmp (cad_decodificar,"CI",2) == 0) strcpy (dato_1,"Cross-instance function invocation instance lock"); elseif ( strncmp (cad_decodificar,"CS",2) == 0) strcpy (dato_1,"Control file schema global enqueue lock"); elseif ( strncmp (cad_decodificar,"CU",2) == 0) strcpy (dato_1,"Cursor bind lock"); elseif ( strncmp (cad_decodificar,"DF",2) == 0) strcpy (dato_1,"Data file instance lock"); elseif ( strncmp (cad_decodificar,"DL",2) == 0) strcpy (dato_1,"Direct loader parallel index create"); elseif ( strncmp (cad_decodificar,"DM",2) == 0) strcpy (dato_1,"Mount/startup db primary/secondary instance lock"); elseif ( strncmp (cad_decodificar,"DR",2) == 0) strcpy (dato_1,"Distributed recovery process lock"); elseif ( strncmp (cad_decodificar,"DX",2) == 0) strcpy (dato_1,"Distributed transaction entry lock"); elseif ( strncmp (cad_decodificar,"FI",2) == 0) strcpy (dato_1,"SGA open-file information lock"); elseif ( strncmp (cad_decodificar,"FS",2) == 0) strcpy (dato_1,"File set lock"); elseif ( strncmp (cad_decodificar,"HW",2) == 0) strcpy (dato_1,"Space management operations on a specific segment lock"); elseif ( strncmp (cad_decodificar,"IN",2) == 0) strcpy (dato_1,"Instance number lock"); elseif ( strncmp (cad_decodificar,"IR",2) == 0) strcpy (dato_1,"Instance recovery serialization global enqueue lock"); elseif ( strncmp (cad_decodificar,"IS",2) == 0) strcpy (dato_1,"Instance state lock"); elseif ( strncmp (cad_decodificar,"IV",2) == 0) strcpy (dato_1,"Library cache invalidation instance lock"); elseif ( strncmp (cad_decodificar,"JQ",2) == 0) strcpy (dato_1,"Job queue lock"); elseif ( strncmp (cad_decodificar,"KK",2) == 0) strcpy (dato_1,"Thread kick lock"); elseif ( strncmp (cad_decodificar,"MB",2) == 0) strcpy (dato_1,"Master buffer hash table instance lock"); elseif ( strncmp (cad_decodificar,"MM",2) == 0) strcpy (dato_1,"Mount definition gloabal enqueue lock"); elseif ( strncmp (cad_decodificar,"MR",2) == 0) strcpy (dato_1,"Media recovery lock"); elseif ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Password file lock"); elseif ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Process startup lock"); elseif ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"RE",2) == 0) strcpy (dato_1,"USE_ROW_ENQUEUE enforcement lock"); elseif ( strncmp (cad_decodificar,"RT",2) == 0) strcpy (dato_1,"Redo thread global enqueue lock"); elseif ( strncmp (cad_decodificar,"RW",2) == 0) strcpy (dato_1,"Row wait enqueue lock"); elseif ( strncmp (cad_decodificar,"SC",2) == 0) strcpy (dato_1,"System commit number instance lock"); elseif ( strncmp (cad_decodificar,"SH",2) == 0) strcpy (dato_1,"System commit number high water mark enqueue lock"); elseif ( strncmp (cad_decodificar,"SM",2) == 0) strcpy (dato_1,"SMON lock"); elseif ( strncmp (cad_decodificar,"SN",2) == 0) strcpy (dato_1,"Sequence number instance lock"); elseif ( strncmp (cad_decodificar,"SQ",2) == 0) strcpy (dato_1,"Sequence number enqueue lock"); elseif ( strncmp (cad_decodificar,"SS",2) == 0) strcpy (dato_1,"Sort segment lock"); elseif ( strncmp (cad_decodificar,"ST",2) == 0) strcpy (dato_1,"Space transaction enqueue lock"); elseif ( strncmp (cad_decodificar,"SV",2) == 0) strcpy (dato_1,"Sequence number value lock"); else
  • 18. if ( strncmp (cad_decodificar,"TA",2) == 0) strcpy (dato_1,"Generic enqueue lock"); else if ( strncmp (cad_decodificar,"TD",2) == 0) strcpy (dato_1,"DDL enqueue lock"); else if ( strncmp (cad_decodificar,"TE",2) == 0) strcpy (dato_1,"Extend-segment enqueue lock"); else if ( strncmp (cad_decodificar,"TM",2) == 0) strcpy (dato_1,"DML enqueue lock"); else if ( strncmp (cad_decodificar,"TT",2) == 0) strcpy (dato_1,"Temporary table enqueue lock"); else if ( strncmp (cad_decodificar,"TX",2) == 0) strcpy (dato_1,"Transaction enqueue lock"); else if ( strncmp (cad_decodificar,"UL",2) == 0) strcpy (dato_1,"User supplied lock"); else if ( strncmp (cad_decodificar,"UN",2) == 0) strcpy (dato_1,"User name lock"); else if ( strncmp (cad_decodificar,"US",2) == 0) strcpy (dato_1,"Undo segment DDL lock"); else if ( strncmp (cad_decodificar,"WL",2) == 0) strcpy (dato_1,"Being-written redo log instance lock"); else if ( strncmp (cad_decodificar,"WS",2) == 0) strcpy (dato_1,"Write-atomic-log-switch global enqueue lock"); else if ( strncmp (cad_decodificar,"TS",2) == 0) strcpy (dato_1,"Temporary segment enqueue lock (ID2=0) New block allocation enqueue lock(ID2=1)"); else if ( strncmp (cad_decodificar,"LA",2) == 0) strcpy (dato_1,"Library cache lock instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"LB",2) == 0) strcpy (dato_1,"Library cache lock instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"LC",2) == 0) strcpy (dato_1,"Library cache lock instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"LD",2) == 0) strcpy (dato_1,"Library cache lock instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"LE",2) == 0) strcpy (dato_1,"Library cache lock instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"LF",2) == 0) strcpy (dato_1,"Library cache lock instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"LG",2) == 0) strcpy (dato_1,"Library cache lock instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"LH",2) == 0) strcpy (dato_1,"Library cache lock instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"LI",2) == 0) strcpy (dato_1,"Library cache lock instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"LJ",2) == 0) strcpy (dato_1,"Library cache lock instance lock (J=namespace)"); else if ( strncmp (cad_decodificar,"LK",2) == 0) strcpy (dato_1,"Library cache lock instance lock (K=namespace)"); else if ( strncmp (cad_decodificar,"LL",2) == 0) strcpy (dato_1,"Library cache lock instance lock (L=namespace)"); else if ( strncmp (cad_decodificar,"LM",2) == 0) strcpy (dato_1,"Library cache lock instance lock (M=namespace)"); else if ( strncmp (cad_decodificar,"LN",2) == 0) strcpy (dato_1,"Library cache lock instance lock (N=namespace)"); else if ( strncmp (cad_decodificar,"LO",2) == 0) strcpy (dato_1,"Library cache lock instance lock (O=namespace)"); else if ( strncmp (cad_decodificar,"LP",2) == 0) strcpy (dato_1,"Library cache lock instance lock (P=namespace)"); else if ( strncmp (cad_decodificar,"LS",2) == 0) strcpy (dato_1,"Log start/log switch enqueue lock"); else if ( strncmp (cad_decodificar,"PA",2) == 0) strcpy (dato_1,"Library cache pin instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"PB",2) == 0) strcpy (dato_1,"Library cache pin instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"PC",2) == 0) strcpy (dato_1,"Library cache pin instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"PD",2) == 0) strcpy (dato_1,"Library cache pin instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"PE",2) == 0) strcpy (dato_1,"Library cache pin instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Library cache pin instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"PG",2) == 0) strcpy (dato_1,"Library cache pin instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"PH",2) == 0) strcpy (dato_1,"Library cache pin instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Library cache pin instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"PJ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (J=namespace)"); else
  • 19. if ( strncmp (cad_decodificar,"PL",2) == 0) strcpy (dato_1,"Library cache pin instance lock (K=namespace)"); elseif ( strncmp (cad_decodificar,"PK",2) == 0) strcpy (dato_1,"Library cache pin instance lock (L=namespace)"); elseif ( strncmp (cad_decodificar,"PM",2) == 0) strcpy (dato_1,"Library cache pin instance lock (M=namespace)"); elseif ( strncmp (cad_decodificar,"PN",2) == 0) strcpy (dato_1,"Library cache pin instance lock (N=namespace)"); elseif ( strncmp (cad_decodificar,"PO",2) == 0) strcpy (dato_1,"Library cache pin instance lock (O=namespace)"); elseif ( strncmp (cad_decodificar,"PP",2) == 0) strcpy (dato_1,"Library cache pin instance lock (P=namespace)"); elseif ( strncmp (cad_decodificar,"PQ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Q=namespace)"); elseif ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Library cache pin instance lock (R=namespace)"); elseif ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Library cache pin instance lock (S=namespace)"); elseif ( strncmp (cad_decodificar,"PT",2) == 0) strcpy (dato_1,"Library cache pin instance lock (T=namespace)"); elseif ( strncmp (cad_decodificar,"PU",2) == 0) strcpy (dato_1,"Library cache pin instance lock (U=namespace)"); elseif ( strncmp (cad_decodificar,"PV",2) == 0) strcpy (dato_1,"Library cache pin instance lock (V=namespace)"); elseif ( strncmp (cad_decodificar,"PW",2) == 0) strcpy (dato_1,"Library cache pin instance lock (W=namespace)"); elseif ( strncmp (cad_decodificar,"PX",2) == 0) strcpy (dato_1,"Library cache pin instance lock (X=namespace)"); elseif ( strncmp (cad_decodificar,"PY",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Y=namespace)"); elseif ( strncmp (cad_decodificar,"PZ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Z=namespace)"); elseif ( strncmp (cad_decodificar,"QA",2) == 0) strcpy (dato_1,"Row cache instance lock (A=cache)"); elseif ( strncmp (cad_decodificar,"QB",2) == 0) strcpy (dato_1,"Row cache instance lock (B=cache)"); elseif ( strncmp (cad_decodificar,"QC",2) == 0) strcpy (dato_1,"Row cache instance lock (C=cache)"); elseif ( strncmp (cad_decodificar,"QD",2) == 0) strcpy (dato_1,"Row cache instance lock (D=cache)"); elseif ( strncmp (cad_decodificar,"QE",2) == 0) strcpy (dato_1,"Row cache instance lock (E=cache)"); elseif ( strncmp (cad_decodificar,"QF",2) == 0) strcpy (dato_1,"Row cache instance lock (F=cache)"); elseif ( strncmp (cad_decodificar,"QG",2) == 0) strcpy (dato_1,"Row cache instance lock (G=cache)"); elseif ( strncmp (cad_decodificar,"QH",2) == 0) strcpy (dato_1,"Row cache instance lock (H=cache)"); elseif ( strncmp (cad_decodificar,"QI",2) == 0) strcpy (dato_1,"Row cache instance lock (I=cache)"); elseif ( strncmp (cad_decodificar,"QJ",2) == 0) strcpy (dato_1,"Row cache instance lock (J=cache)"); elseif ( strncmp (cad_decodificar,"QL",2) == 0) strcpy (dato_1,"Row cache instance lock (K=cache)"); elseif ( strncmp (cad_decodificar,"QK",2) == 0) strcpy (dato_1,"Row cache instance lock (L=cache)"); elseif ( strncmp (cad_decodificar,"QM",2) == 0) strcpy (dato_1,"Row cache instance lock (M=cache)"); elseif ( strncmp (cad_decodificar,"QN",2) == 0) strcpy (dato_1,"Row cache instance lock (N=cache)"); elseif ( strncmp (cad_decodificar,"QO",2) == 0) strcpy (dato_1,"Row cache instance lock (O=cache)"); elseif ( strncmp (cad_decodificar,"QP",2) == 0) strcpy (dato_1,"Row cache instance lock (P=cache)"); elseif ( strncmp (cad_decodificar,"QQ",2) == 0) strcpy (dato_1,"Row cache instance lock (Q=cache)"); elseif ( strncmp (cad_decodificar,"QR",2) == 0) strcpy (dato_1,"Row cache instance lock (R=cache)"); elseif ( strncmp (cad_decodificar,"QS",2) == 0) strcpy (dato_1,"Row cache instance lock (S=cache)"); elseif ( strncmp (cad_decodificar,"QT",2) == 0) strcpy (dato_1,"Row cache instance lock (T=cache)"); elseif ( strncmp (cad_decodificar,"QU",2) == 0) strcpy (dato_1,"Row cache instance lock (U=cache)"); elseif ( strncmp (cad_decodificar,"QV",2) == 0) strcpy (dato_1,"Row cache instance lock (V=cache)"); elseif ( strncmp (cad_decodificar,"QW",2) == 0) strcpy (dato_1,"Row cache instance lock (W=cache)"); elseif ( strncmp (cad_decodificar,"QX",2) == 0) strcpy (dato_1,"Row cache instance lock (X=cache)"); else
  • 20. if ( strncmp (cad_decodificar,"QY",2) == 0) strcpy (dato_1,"Row cache instance lock (Y=cache)"); else if ( strncmp (cad_decodificar,"QZ",2) == 0) strcpy (dato_1,"Row cache instance lock (Z=cache)"); return (dato_1); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: decode_name_mode.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>#include <stdlib.h>#include <string.h>extern char *decode_name_lock (char *cad_decodificar) { static char dato_1[256];
  • 21. vaciar_cadena (dato_1,256);if ( strncmp (cad_decodificar,"BL",2) == 0) strcpy (dato_1,"Buffer hash table instance lock"); elseif ( strncmp (cad_decodificar,"CF",2) == 0) strcpy (dato_1," Control file schema global enqueue lock"); elseif ( strncmp (cad_decodificar,"CI",2) == 0) strcpy (dato_1,"Cross-instance function invocation instance lock"); elseif ( strncmp (cad_decodificar,"CS",2) == 0) strcpy (dato_1,"Control file schema global enqueue lock"); elseif ( strncmp (cad_decodificar,"CU",2) == 0) strcpy (dato_1,"Cursor bind lock"); elseif ( strncmp (cad_decodificar,"DF",2) == 0) strcpy (dato_1,"Data file instance lock"); elseif ( strncmp (cad_decodificar,"DL",2) == 0) strcpy (dato_1,"Direct loader parallel index create"); elseif ( strncmp (cad_decodificar,"DM",2) == 0) strcpy (dato_1,"Mount/startup db primary/secondary instance lock"); elseif ( strncmp (cad_decodificar,"DR",2) == 0) strcpy (dato_1,"Distributed recovery process lock"); elseif ( strncmp (cad_decodificar,"DX",2) == 0) strcpy (dato_1,"Distributed transaction entry lock"); elseif ( strncmp (cad_decodificar,"FI",2) == 0) strcpy (dato_1,"SGA open-file information lock"); elseif ( strncmp (cad_decodificar,"FS",2) == 0) strcpy (dato_1,"File set lock"); elseif ( strncmp (cad_decodificar,"HW",2) == 0) strcpy (dato_1,"Space management operations on a specific segment lock"); elseif ( strncmp (cad_decodificar,"IN",2) == 0) strcpy (dato_1,"Instance number lock"); elseif ( strncmp (cad_decodificar,"IR",2) == 0) strcpy (dato_1,"Instance recovery serialization global enqueue lock"); elseif ( strncmp (cad_decodificar,"IS",2) == 0) strcpy (dato_1,"Instance state lock"); elseif ( strncmp (cad_decodificar,"IV",2) == 0) strcpy (dato_1,"Library cache invalidation instance lock"); elseif ( strncmp (cad_decodificar,"JQ",2) == 0) strcpy (dato_1,"Job queue lock"); elseif ( strncmp (cad_decodificar,"KK",2) == 0) strcpy (dato_1,"Thread kick lock"); elseif ( strncmp (cad_decodificar,"MB",2) == 0) strcpy (dato_1,"Master buffer hash table instance lock"); elseif ( strncmp (cad_decodificar,"MM",2) == 0) strcpy (dato_1,"Mount definition gloabal enqueue lock"); elseif ( strncmp (cad_decodificar,"MR",2) == 0) strcpy (dato_1,"Media recovery lock"); elseif ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Password file lock"); elseif ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Process startup lock"); elseif ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"RE",2) == 0) strcpy (dato_1,"USE_ROW_ENQUEUE enforcement lock"); elseif ( strncmp (cad_decodificar,"RT",2) == 0) strcpy (dato_1,"Redo thread global enqueue lock"); elseif ( strncmp (cad_decodificar,"RW",2) == 0) strcpy (dato_1,"Row wait enqueue lock"); elseif ( strncmp (cad_decodificar,"SC",2) == 0) strcpy (dato_1,"System commit number instance lock"); elseif ( strncmp (cad_decodificar,"SH",2) == 0) strcpy (dato_1,"System commit number high water mark enqueue lock"); elseif ( strncmp (cad_decodificar,"SM",2) == 0) strcpy (dato_1,"SMON lock"); elseif ( strncmp (cad_decodificar,"SN",2) == 0) strcpy (dato_1,"Sequence number instance lock"); elseif ( strncmp (cad_decodificar,"SQ",2) == 0) strcpy (dato_1,"Sequence number enqueue lock"); elseif ( strncmp (cad_decodificar,"SS",2) == 0) strcpy (dato_1,"Sort segment lock"); elseif ( strncmp (cad_decodificar,"ST",2) == 0) strcpy (dato_1,"Space transaction enqueue lock"); elseif ( strncmp (cad_decodificar,"SV",2) == 0) strcpy (dato_1,"Sequence number value lock"); elseif ( strncmp (cad_decodificar,"TA",2) == 0) strcpy (dato_1,"Generic enqueue lock"); else
  • 22. if ( strncmp (cad_decodificar,"TD",2) == 0) strcpy (dato_1,"DDL enqueue lock"); else if ( strncmp (cad_decodificar,"TE",2) == 0) strcpy (dato_1,"Extend-segment enqueue lock"); else if ( strncmp (cad_decodificar,"TM",2) == 0) strcpy (dato_1,"DML enqueue lock"); else if ( strncmp (cad_decodificar,"TT",2) == 0) strcpy (dato_1,"Temporary table enqueue lock"); else if ( strncmp (cad_decodificar,"TX",2) == 0) strcpy (dato_1,"Transaction enqueue lock"); else if ( strncmp (cad_decodificar,"UL",2) == 0) strcpy (dato_1,"User supplied lock"); else if ( strncmp (cad_decodificar,"UN",2) == 0) strcpy (dato_1,"User name lock"); else if ( strncmp (cad_decodificar,"US",2) == 0) strcpy (dato_1,"Undo segment DDL lock"); else if ( strncmp (cad_decodificar,"WL",2) == 0) strcpy (dato_1,"Being-written redo log instance lock"); else if ( strncmp (cad_decodificar,"WS",2) == 0) strcpy (dato_1,"Write-atomic-log-switch global enqueue lock"); else if ( strncmp (cad_decodificar,"TS",2) == 0) strcpy (dato_1,"Temporary segment enqueue lock (ID2=0) New block allocation enqueue lock(ID2=1)"); else if ( strncmp (cad_decodificar,"LA",2) == 0) strcpy (dato_1,"Library cache lock instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"LB",2) == 0) strcpy (dato_1,"Library cache lock instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"LC",2) == 0) strcpy (dato_1,"Library cache lock instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"LD",2) == 0) strcpy (dato_1,"Library cache lock instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"LE",2) == 0) strcpy (dato_1,"Library cache lock instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"LF",2) == 0) strcpy (dato_1,"Library cache lock instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"LG",2) == 0) strcpy (dato_1,"Library cache lock instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"LH",2) == 0) strcpy (dato_1,"Library cache lock instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"LI",2) == 0) strcpy (dato_1,"Library cache lock instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"LJ",2) == 0) strcpy (dato_1,"Library cache lock instance lock (J=namespace)"); else if ( strncmp (cad_decodificar,"LK",2) == 0) strcpy (dato_1,"Library cache lock instance lock (K=namespace)"); else if ( strncmp (cad_decodificar,"LL",2) == 0) strcpy (dato_1,"Library cache lock instance lock (L=namespace)"); else if ( strncmp (cad_decodificar,"LM",2) == 0) strcpy (dato_1,"Library cache lock instance lock (M=namespace)"); else if ( strncmp (cad_decodificar,"LN",2) == 0) strcpy (dato_1,"Library cache lock instance lock (N=namespace)"); else if ( strncmp (cad_decodificar,"LO",2) == 0) strcpy (dato_1,"Library cache lock instance lock (O=namespace)"); else if ( strncmp (cad_decodificar,"LP",2) == 0) strcpy (dato_1,"Library cache lock instance lock (P=namespace)"); else if ( strncmp (cad_decodificar,"LS",2) == 0) strcpy (dato_1,"Log start/log switch enqueue lock"); else if ( strncmp (cad_decodificar,"PA",2) == 0) strcpy (dato_1,"Library cache pin instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"PB",2) == 0) strcpy (dato_1,"Library cache pin instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"PC",2) == 0) strcpy (dato_1,"Library cache pin instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"PD",2) == 0) strcpy (dato_1,"Library cache pin instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"PE",2) == 0) strcpy (dato_1,"Library cache pin instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Library cache pin instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"PG",2) == 0) strcpy (dato_1,"Library cache pin instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"PH",2) == 0) strcpy (dato_1,"Library cache pin instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Library cache pin instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"PJ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (J=namespace)"); else if ( strncmp (cad_decodificar,"PL",2) == 0) strcpy (dato_1,"Library cache pin instance lock (K=namespace)"); else
  • 23. if ( strncmp (cad_decodificar,"PK",2) == 0) strcpy (dato_1,"Library cache pin instance lock (L=namespace)"); elseif ( strncmp (cad_decodificar,"PM",2) == 0) strcpy (dato_1,"Library cache pin instance lock (M=namespace)"); elseif ( strncmp (cad_decodificar,"PN",2) == 0) strcpy (dato_1,"Library cache pin instance lock (N=namespace)"); elseif ( strncmp (cad_decodificar,"PO",2) == 0) strcpy (dato_1,"Library cache pin instance lock (O=namespace)"); elseif ( strncmp (cad_decodificar,"PP",2) == 0) strcpy (dato_1,"Library cache pin instance lock (P=namespace)"); elseif ( strncmp (cad_decodificar,"PQ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Q=namespace)"); elseif ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Library cache pin instance lock (R=namespace)"); elseif ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Library cache pin instance lock (S=namespace)"); elseif ( strncmp (cad_decodificar,"PT",2) == 0) strcpy (dato_1,"Library cache pin instance lock (T=namespace)"); elseif ( strncmp (cad_decodificar,"PU",2) == 0) strcpy (dato_1,"Library cache pin instance lock (U=namespace)"); elseif ( strncmp (cad_decodificar,"PV",2) == 0) strcpy (dato_1,"Library cache pin instance lock (V=namespace)"); elseif ( strncmp (cad_decodificar,"PW",2) == 0) strcpy (dato_1,"Library cache pin instance lock (W=namespace)"); elseif ( strncmp (cad_decodificar,"PX",2) == 0) strcpy (dato_1,"Library cache pin instance lock (X=namespace)"); elseif ( strncmp (cad_decodificar,"PY",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Y=namespace)"); elseif ( strncmp (cad_decodificar,"PZ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Z=namespace)"); elseif ( strncmp (cad_decodificar,"QA",2) == 0) strcpy (dato_1,"Row cache instance lock (A=cache)"); elseif ( strncmp (cad_decodificar,"QB",2) == 0) strcpy (dato_1,"Row cache instance lock (B=cache)"); elseif ( strncmp (cad_decodificar,"QC",2) == 0) strcpy (dato_1,"Row cache instance lock (C=cache)"); elseif ( strncmp (cad_decodificar,"QD",2) == 0) strcpy (dato_1,"Row cache instance lock (D=cache)"); elseif ( strncmp (cad_decodificar,"QE",2) == 0) strcpy (dato_1,"Row cache instance lock (E=cache)"); elseif ( strncmp (cad_decodificar,"QF",2) == 0) strcpy (dato_1,"Row cache instance lock (F=cache)"); elseif ( strncmp (cad_decodificar,"QG",2) == 0) strcpy (dato_1,"Row cache instance lock (G=cache)"); elseif ( strncmp (cad_decodificar,"QH",2) == 0) strcpy (dato_1,"Row cache instance lock (H=cache)"); elseif ( strncmp (cad_decodificar,"QI",2) == 0) strcpy (dato_1,"Row cache instance lock (I=cache)"); elseif ( strncmp (cad_decodificar,"QJ",2) == 0) strcpy (dato_1,"Row cache instance lock (J=cache)"); elseif ( strncmp (cad_decodificar,"QL",2) == 0) strcpy (dato_1,"Row cache instance lock (K=cache)"); elseif ( strncmp (cad_decodificar,"QK",2) == 0) strcpy (dato_1,"Row cache instance lock (L=cache)"); elseif ( strncmp (cad_decodificar,"QM",2) == 0) strcpy (dato_1,"Row cache instance lock (M=cache)"); elseif ( strncmp (cad_decodificar,"QN",2) == 0) strcpy (dato_1,"Row cache instance lock (N=cache)"); elseif ( strncmp (cad_decodificar,"QO",2) == 0) strcpy (dato_1,"Row cache instance lock (O=cache)"); elseif ( strncmp (cad_decodificar,"QP",2) == 0) strcpy (dato_1,"Row cache instance lock (P=cache)"); elseif ( strncmp (cad_decodificar,"QQ",2) == 0) strcpy (dato_1,"Row cache instance lock (Q=cache)"); elseif ( strncmp (cad_decodificar,"QR",2) == 0) strcpy (dato_1,"Row cache instance lock (R=cache)"); elseif ( strncmp (cad_decodificar,"QS",2) == 0) strcpy (dato_1,"Row cache instance lock (S=cache)"); elseif ( strncmp (cad_decodificar,"QT",2) == 0) strcpy (dato_1,"Row cache instance lock (T=cache)"); elseif ( strncmp (cad_decodificar,"QU",2) == 0) strcpy (dato_1,"Row cache instance lock (U=cache)"); elseif ( strncmp (cad_decodificar,"QV",2) == 0) strcpy (dato_1,"Row cache instance lock (V=cache)"); elseif ( strncmp (cad_decodificar,"QW",2) == 0) strcpy (dato_1,"Row cache instance lock (W=cache)"); elseif ( strncmp (cad_decodificar,"QX",2) == 0) strcpy (dato_1,"Row cache instance lock (X=cache)"); elseif ( strncmp (cad_decodificar,"QY",2) == 0) strcpy (dato_1,"Row cache instance lock (Y=cache)"); else
  • 24. if ( strncmp (cad_decodificar,"QZ",2) == 0) strcpy (dato_1,"Row cache instance lock (Z=cache)"); return (dato_1); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: EXTERN_FUNCTIONS_FUNCIONES_AUXILIARES.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */extern char *db_object_type ();extern char *db_object_owner_name ();extern char *db_session_sid_locked ();extern int db_tablspace_ini_ext_size ();
  • 25. extern int db_block_size ();extern int version_oracle ();extern char *decode_command_oracle ();extern char *decode_lock_mode ();extern char *decode_name_lock ();extern void esperar_seg();extern void sleep();--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: EXTERN_FUNCTIONS_ORASTAT_PRINCIPAL.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****---- FUNCIONES DECLARADAS EXTERNAS ****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */ extern int col_size (); extern int filtrar_char ();
  • 26. extern char *separar_dato (); extern int procesar_columna_funcion (); extern char *convert_ss_to_hh_mm_ss (); extern void vaciar_cadena (); extern void vaciar_estructura (); extern int procesar_encabe (); extern int procesar_cadena (); extern char *pasar_amayus (); extern char *funcion_columna (); extern char *decode_name_lock (); extern char *decode_command_oracle (); extern char *decode_lock_mode (); extern char *ver_menu_opcion(); extern char *func_dyn_column_set (); extern char *func_dyn_title_set(); extern char *func_dyn_size_set(); extern char *func_dyn_statement_set(); extern char *func_dyn_proc_func_set(); extern char *formatear_sql_statement(); extern int func_menu_mostrar();--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_dyn_column_set.c ****** ****** ***
  • 27. ******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#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();char *func_dyn_column_set (int version, int sentencia) { static char dyn_column [MAX_VAR_SIZE]; vaciar_cadena (dyn_column,MAX_VAR_SIZE ); switch (sentencia) { case CASE_ORACLE_VERSION: strcpy (dyn_column,"|ORACLE_VERSION|"); break; case CASE_ACTIVE_PARAMETERS: strcpy (dyn_column,"|NOMBRE|VALOR|DESCRIPCION|"); break; case CASE_USERS_CONNECTED: strcpy (dyn_column,"|DIRECCION|SES|NOMBRE|CMD|ESTADO|PID|TERMINAL|LOCKWAIT|INICIADO|"); break; case CASE_WAIT_STATISTICS: strcpy (dyn_column,"|CANTIDAD|TIEMPO|CLASE|"); break; case CASE_DATAFILE_I_0: switch (version) { case VERSION_ORACLE_920:
  • 28. strcpy (dyn_column,"|READPHY|READBLK|WRITPHY||WRITBLK|DATAFILE|IO_STAT|"); break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: strcpy (dyn_column,"|READPHY|READBLK|WRITPHY|WRITBLK|DATAFILE|"); break; default: break; } break; case CASE_DATAFILE_BLOCKS_R_W: strcpy (dyn_column,"|DATAFILE|BLKREAD|BLKWRITE|BLKTOT|"); break; case CASE_WAIT_EVENTS: strcpy (dyn_column,"|SID|USUARIO|CANTIDAD|EVENTO|"); break; case CASE_INSTANCE_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy(dyn_column,"|INSTNRO|INSTNAME|HOSTNAME|VERSION|INICIADO|ESTADO|PARALELO|DATAESTA|INSTROLE|ACTSTATUS|LOG_MODE|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|INSTNAME|CREADA|ARCHIVESTATUS|CHECK_CHANGE|ARCHI_CHANGE|DATASTATE|SHUTDOWN?|INICIADA|HORA|LOG_MODE|"); break; default: break; } break; case CASE_TEMPORAL_SPACE_BY_USER: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920:
  • 29. strcpy (dyn_column,"|SES|SERIAL|USER|EXTENTS|CONTENTS|SIZEKB"); break; case VERSION_ORACLE_734: strcpy(dyn_column,"|TBLSPACE|EXTSIZE|CURUSER|TOTEXT|TOTBLK|USEXT|USEBLK|FREEXT|FREEBLK|MUSESIZE|MUSEBLK|MSORTSIZE|MSORTBLK|"); default: break; } break; case CASE_TOT_FREELIST_WAIT_PERCENT: strcpy (dyn_column,"|PCTFREE|"); break; case CASE_LAST_CHECKPOINT_TIME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|CHEKPOINT_VALUE|FECHA|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|CHEKPOINT_VALUE|FECHA|"); break; default: break; } break; case CASE_LIST_TABLESPACES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|TBLSPACE|CONTENT|AVAILA_KB|MAX_ID|USED_KB|FREE_KB|PCT_USED|STATUS|MANAGMENT|ALLOCTYPE|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|TBLSPACE|CONTENT|AVAILA_KB|MAX_ID|USED_KB|FREE_KB|PCT_USED|STATUS|"); break; } break;
  • 30. case CASE_ACTIVE_TRANSACTIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ADDRESS|TIMESTART|ESTADO|BLK_USED|KB_USED|USED_UREC|SESSION|SERIAL|NOMBRE|USUARIO|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|ADDRESS|TIMESTART|ESTADO|BLK_USED|KB_USED|USED_UREC|SESSION|SERIAL|NOMBRE|USUARIO|"); break; } break;case CASE_LATCH_DETAILS: strcpy (dyn_column,"|GETS|MISS|HITRATIO|IMM_GETS|IMM_MISS|SLEEP|GETSPIN|ADDRESS|LATCH|NOMBRE|"); break;case CASE_RESOURCE_LIMITS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|NOMBRE|INIT_ALLOC|CURR_UTILIZA|MAX_UTILIZA|LIMITE|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|NOMBRE|LIMITE|"); break; } break;case CASE_LIST_DATAFILES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|DATAFILE|MBYTES|ESTADO|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|DATAFILE|MBYTES|ESTADO|"); break;
  • 31. } break;case CASE_LIST_DATAFILES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ESTADO|DATAFILE|TBLSPACE|SIZE_KB|USED_KB|USED_PCT|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|ESTADO|DATAFILE|TBLSPACE|SIZE_KB|USED_KB|USED_PCT|"); break; } break;case CASE_LIST_TABLESPACES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ESTADO|TBLSPACE|TIPO|EXTENT_MGM|SIZE_KB|USED_KB|USED_PCT|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|ESTADO|TBLSPACE|TIPO|EXTENT_MGM|SIZE_KB|USED_KB|USED_PCT|"); break; } break;case CASE_ACTIVE_SESSIONS: strcpy (dyn_column,"|SES|SERIAL|TIPO|OS_USER|LOGON|ESTADO|PROCESO|MAQUINA|NOMBRE|PID|PROGRAMA|"); break;case CASE_SESSIONS_WAITS: strcpy (dyn_column,"|SES|SEQ|W_T|S_W_T|USUARIO|ESTADO|EVENT|STATE|P1TEXT|P1|P1RAW|P2TEXT|P2|P2RAW|P3TEXT|P3|P3RAW|"); break;case CASE_DEFAULT_STORAGE_SETS_TABLESPACE: strcpy (dyn_column,"|TBLSPACE|INI_EXT|NEX_EXT|MIN_EXT|MAX_EXT|PCT_INC|"); break;case CASE_ALL_TABLES_STORAGE_SETTINGS: switch (version) {
  • 32. case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|OWNER_TABLE|SEG_NAME|TBLSPACE|BLOCKS|SIZE_KB|EXTENTS|MAX_EXT|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|OWNER_TABLE|SEG_NAME|TBLSPACE|BLOCKS|SIZE_KB|EXTENTS|MAX_EXT|"); break; } break;case CASE_ALL_NON_SYS_TABLES_SETTINGS: strcpy (dyn_column,"|OWNER|TABLNAME|TBLSPACE|BLOCK|NROWS|BUFF_POOL|LAST_ANALIZE|SIZE_KB"); break;case CASE_ALL_NON_SYS_INDEXES_SETTINGS: strcpy (dyn_column,"|OWNER|INDEXNAME|TBLSPACE|LEAFBLK|NROROWS|BUFFPOOL|LASTANALIZ|SIZE_KB|"); break;case CASE_USER_DEFINED: printf ("Pasando Seteo Columna 24 n"); switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|USUARIO|ESTADO|EXPIRY DATE|DEFAULT TBLNAME|TEMP TBLNAME|PROFILE|CREATED|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|USUARIO|ESTADO|EXPIRY DATE|DEFAULT TBLNAME|TEMP TBLNAME|PROFILE|CREATED|"); break; } break;case CASE_LIST_DATAFILE_REDO_CONTROL_FILES: strcpy (dyn_column,"|FILENAME|TBLSPACE|ESTADO|"); break;case CASE_LIST_DATAFILES_USED_BLOCKS: strcpy (dyn_column,"|TBLSPACE|FILENAME|BYTES|HIGHWATER|"); break;case CASE_LIST_SORT_BY_USER: strcpy (dyn_column,"|VALOR|TYPESORT|SID|OS_USER|DB_USER|"); break;case CASE_LIST_LOCK_STATUS:
  • 33. switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ADDRESS|KADDRESS|SES|TIPO|OBJ_ID|ID2|LOCK TYP|REQU TYP|OBJECTTYPE|OWNER.NAME|LOCK_SID|TIME|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|ADDRESS|KADDRESS|SES|TIPO|OBJ_ID|ID2|LOCK TYP|REQU TYP|OBJECTTYPE|OWNER.NAME|LOCK_SID|TIME|"); break; } break; case CASE_LIST_USER_BY_CPU_USAGE: strcpy (dyn_column,"|SES|SERIAL|TYPE|OSUSER|LOGON|PROCESS|MACHINE|USER|VALUE|PROGRAM|"); break; case CASE_SQL_STATEMENT_BY_THIS_USER: strcpy (dyn_column,"|TEXT_SQL|"); break; case CASE_REDO_LOGS_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|GRUPO|THREAD|SEQUENCE|BYTES|MEMBER|ARCHIVED|ESTADO|FSTCHANGE|FSTTIME|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|GRUPO|THREAD|SEQUENCE|BYTES|MEMBER|ARCHIVED|ESTADO|FSTCHANGE|FSTTIME|"); break; } break; case CASE_ARCHIVED_LOGS_HISTORY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|THREAD|SEQUEN|NAME|FSTCHANGE|FSTTIME|BLOCKS|BLKSIZE|COMPTIME|");
  • 34. break; case VERSION_ORACLE_734: strcpy (dyn_column,"|THREAD|SEQUEN|TIME|LOW_CHANGE|HIGH_CHANGE|NAME"); break; } break;case CASE_REDO_LOG_RECOVERY_REPORT: strcpy (dyn_column,"|GROUP|FSTCHANGE|MEMBER|SEQUENCE|"); break;case CASE_ARCHIVE_LOG_HISTROY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|THREAD|SEQUENCE|FSTCHANGE|SWICHANGE|FSTTIME|"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|THREAD|SEQUENCE|FSTCHANGE|SWICHANGE|FSTTIME|"); break; } break;case CASE_SESSION_LATCH_WAITS_SQL: strcpy (dyn_column,"|SES|USER|STATUS|SQLTEXT|"); break;case CASE_SESSION_PROGRAM_RUNNING_SQL: strcpy (dyn_column,"|SES|USER|PROGRAM|SQLTEXT|"); break;case CASE_PRIVILEGES_BY_USER: strcpy (dyn_column,"|GRANTEE|USER|PRIVILEGE|"); break;case CASE_DETAILED_LOCKING_CAUSES: strcpy (dyn_column,"|USERNAME|SID|TERMINAL|TAB|COMMAND|LMODE|REQUEST|LADDR|LOCKT|LOCKTYPE|"); break;case CASE_CURRENT_STATISTICS_VALUES: strcpy (dyn_column,"|STATISTIC|NOMBRE|VALOR|"); break;case CASE_TABLE_DESCRIPTION_USER_TABLENAME: switch (version) {
  • 35. case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|TBLSPACE|OWNER|TABLENAME|NROWS|LASTANALIZED|INIEXT|NEXEXT|MINEXT|MAXEXT|PCTINC|BUFPOL|BLOCKS|FREELST|PCTFREE|INITRANS|MAXTRANS|FREEGRP"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|TBLSPACE|OWNER|TABLENAME|NROWS|LASTANALIZED|INIEXT|NEXEXT|MINEXT|MAXEXT|PCTINC|BUFPOL|BLOCKS|FREELST|PCTFREE|INITRANS|MAXTRANS|FREEGRP"); break; } break; case CASE_INDEX_DESCRIPTION_USER_INDEXNAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy(dyn_column,"|OWNER|IDXNAME|TABLEOWNER|TABLENAME|TBLTYPE|UNIQUE|TBLSPACE|INITRA|MAXTRA|INIEXT|NEXEXT|MINEXT|MAXEXT|PCTINC|FREELIST|FRELISTGRP|PCTFREE|BLEVEL|LEAFBLK|"); break; case VERSION_ORACLE_734: strcpy(dyn_column,"|OWNER|IDXNAME|TABLEOWNER|TABLENAME|TBLTYPE|UNIQUE|TBLSPACE|INITRA|MAXTRA|INIEXT|NEXEXT|MINEXT|MAXEXT|PCTINC|FREELIST|FRELISTGRP|PCTFREE|BLEVEL|LEAFBLK|"); break; } break; case CASE_CURRENT_ACTIVITY_REPORT: strcpy (dyn_column,"|DIRECCION|BUF_GETS|NRO_EXEC|AVG_EXEC|SQL_TEXT|"); break; case CASE_DICTIONARY_TABLE_COMMENTS: strcpy (dyn_column,"|TABLE NAME|COMMENTS|"); break; case CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP: strcpy (dyn_column,"|TABNAME|COL_NAME|COMMENTS|SQL_TYPE|IMAGEIDX|COL_ID|STATUS|"); break; case CASE_SGA_STATISTIC_GENERAL: strcpy
  • 36. (dyn_column,"|NUM|VALUE|ISDEFAULT|ISMODIFIED|ISADJUSTED|TYPE|ISSES_MODIFIABLE|ISSYS_MODIFIABLE|DESCRIPTION|UPDATE_COMMENT|"); break; case CASE_SGA_STATISTIC_MEMORY_USAGE: strcpy (dyn_column,"|POOL|NAME|KBYTES|USAGE_PCT|VALUE|"); break; case CASE_SGA_STATISTIC_INFORMATION: strcpy (dyn_column,"|NAME|VALUE_KBYTE|"); break; case CASE_ROW_CACHE_INFORMATION: strcpy(dyn_column,"CACHE#|SUBORDINATE#|PARAMETER|GETS|GETMISSES|GETMISSRATIO|SCANS|SCANMISSES|SCANCOMPLETES|SCANMISSRATIO|COUNT|USAGE|FIXED|FLUSHES|MODIFICATIONS|"); break; case CASE_PERFORMANCE_DISK_I_O: strcpy (dyn_column,"|NAMES|READS|WRITES|WEIGHT|"); break; case CASE_RECURSIVE_CALLS: strcpy (dyn_column,"|NAME|VALUE|"); break; case CASE_SYSTEM_EVENTS: strcpy (dyn_column,"|EVENT|TOTAL_WAITS|TOTAL_TIMEOUTS|TIME_WAITED|AVERAGE_WAIT|"); break;/* -------------------------------------------------------------- */ /*#define CASE_SQL_AREA_ALL_ENTRIES 52 */ case CASE_SQL_AREA_ALL_ENTRIES: strcpy (dyn_column,"|AVGETS|SQLTEX|SHAMEM|PERMEM|RUNMEM|"); strcat (dyn_column,"SORTS|VCO|VLO|VOP|UOP|EXECS|UEXEC|LOADS|"); strcat (dyn_column,"FIRSTLOADTIME|INVAL|PARCALLS|DSKREADS|"); strcat (dyn_column,"BUFGETS|SQLADDR|HASHVAL|SQLHVAL|"); strcat (dyn_column,"ROWPROC|CMDTYPE|OPTMODE|PARUSER|"); strcat (dyn_column,"PARSCHEM|KEPTVER|MOD|ACTION|SERABEND|"); break; /*#define CASE_SQL_AREA_CPU_USAGE 53 */ case CASE_SQL_AREA_CPU_USAGE: strcpy (dyn_column,"|AVGETS|SQLTEX|SHAMEM|PERMEM|RUNMEM|");
  • 37. strcat (dyn_column,"SORTS|VCO|VLO|VOP|UOP|EXECS|UEXEC|LOADS|"); strcat (dyn_column,"FIRSTLOADTIME|INVAL|PARCALLS|DSKREADS|"); strcat (dyn_column,"BUFGETS|SQLADDR|SQLHVAL|ROWPROC|"); strcat (dyn_column,"CMDTYPE|OPTMODE|PARUSER|PARSCHEM|"); strcat (dyn_column,"KEPTVER|MOD|ACTION|SERABEND|"); break; /*#define CASE_SQL_AREA_MEMORY_USAGE 54 */ case CASE_SQL_AREA_MEMORY_USAGE: strcpy (dyn_column,"|AVGETS|SHAMEM|PERMEM|RUNMEM|SORTS|"); strcat (dyn_column,"VCO|VLO|VOP|UOP|EXECS|UEXEC|LOADS|INVAL|PARCALLS|"); strcat (dyn_column,"DSKREADS|BUFGETS|ROWSPROC|KEPTVER|"); strcat (dyn_column,"SERABEND|"); break; /*#define CASE_SQL_AREA_BUFFER_GET_SUM 55 */ case CASE_SQL_AREA_BUFFER_GET_SUM: strcpy (dyn_column,"|AVGETS|SQLTEXT|SHAMEM|PERMEM|RUNMEM|"); strcat (dyn_column,"SORTS|VCO|VLO|VOP|UOP|EXECS|UEXEC|LOADS|FIRSTLOADTIME|INVAL|"); strcat (dyn_column,"PARCALLS|DSKREADS|BUFGETS|SQLADDR|HASHVAL|"); strcat (dyn_column,"SQLHVAL|ROWPROC|CMDTYPE|OPTMODE|"); strcat (dyn_column,"PARUSER|PARSCHEM|KEPTVER|MOD|ACTION|SERABEND|"); break; /* /*#define CASE_INIT_PARAMETERS_VALUES_STATUS 56 */ case CASE_INIT_PARAMETERS_VALUES_STATUS: strcpy (dyn_column,"|NUM|NAME|VALUE|ISDEF|ISMOD|ISADJ|TYPE|"); strcat (dyn_column,"ISSESMOD|ISSYSMOD|DESCRIP|"); break;/* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_column,"|TABLESPACE|KBYTES|NROEXT|SUMKBYTE|USAGE|BYTESEXT|CHANGED?|FILEID|EXTID|BLKID|"); break; case CASE_SHOW_NLS_PARAMETERS:
  • 38. strcpy (dyn_column,"|NAME|VALUE_DBMS|VALUE_INST|VALUE_SES|COMMENTS|"); break;case CASE_CONTROL_FILES_STATUS: strcpy (dyn_column,"|NAME|STATUS|"); break;case CASE_SORT_SEGMENTS_USERS: strcpy (dyn_column,"|TABLESPACE_NAME|SEGFIL|SEGBLOCK|EXTSIZE|"); strcat (dyn_column,"CURUSR|TOTEXTENT|TOTBLCKS|USEDEXT|"); strcat (dyn_column,"USEDBLCKS|FREEXT|FREEBLCKS|ADDEXTS|"); strcat (dyn_column,"EXTHITS|FREEEXT|FREEREQU|MSIZE|MBLCKS|"); strcat (dyn_column,"MUSEDSIZE|MUSEDBLCKS|MSORTSIZE|"); strcat (dyn_column,"MSORTBLCKS|TEMP|"); break;case CASE_ORACLE_QUOTAS: strcpy (dyn_column,"|TABLESPACE_NAME|USERNAME|KBYTES|MAX_KBYTES|"); strcat (dyn_column,"BLOCKS|MAX_BLOCKS|USAGEPERC|"); break;case CASE_TABLE_GENERAL_DESCRIPTION: strcpy (dyn_column,"|OWNER|OBJECT_NAME|TABLE_NAME|OBJECT_TYPE|OBJECT_TYPE|R_OBJECT_TYPE|IMAGE_INDEX|"); strcat (dyn_column,"OBJECT_NAME|SYNONYM_OWNER|CREATED|LAST_DDL_TIME|STATUS|TABLESPACE_NAME|PCT_FREE|"); strcat (dyn_column,"PCT_USED|PCT_INCREASE|NEXT_EXTENT|INI_TRANSMAX_TRANS|INITIAL_EXTENT|MIN_EXTENTS|"); strcat (dyn_column,"MAX_EXTENTS|FREELISTS|FREELIST_GROUPS|BACKED_UP|NUM_ROWS|BLOCKS|EMPTY_BLOCKS|AVG_SPACE|"); strcat (dyn_column,"CHAIN_CNT|AVG_ROW_LEN|DEGREE|INSTANCES|CACHE|LAST_ANALYZED|LOGGING|PARTITIONED|"); strcat (dyn_column,"BUFFER_POOL|IOT_NAME|IOT_TYPE|TABLE_LOCK|NESTED|AVG_SPACE_FREELIST_BLOCKS|"); strcat (dyn_column,"NUM_FREELIST_BLOCKS|SAMPLE_SIZE|table_type_owner|table_type|SECONDARY|ROW_MOVEMENT|"); strcat (dyn_column,"GLOBAL_STATS|USER_STATS|DURATION|SKIP_CORRUPT|MONITORING|TEMPORARY|"); break;case CASE_TABLE_COLUMN_DESCRIPTION: strcpy (dyn_column,"|OWNER|TABLNAME|COLUMN|"); break;case CASE_TABLE_CONSTRAINTS: strcpy (dyn_column,"| | | | | | | | | | | | | | | | | |"); strcat (dyn_column,"| | | | | | | | | | | | | | | | | |"); strcat (dyn_column,"| | | | | | | | | | | | | | | | | |"); strcat (dyn_column,"| | | | | | | | | | | | | | | | | |"); break;case CASE_INDEX_GENERAL_DESCRIPTION: strcpy (dyn_column,"|INDEX_OWNER|INDEX_NAME|COLPOS|COLUMN_NAME|"); strcat (dyn_column,"SQL_TYPE|NULLABLE|DESCEND|IMAGE_INDEX|"); break;
  • 39. case CASE_AUDIT_DEFINITION: strcpy (dyn_column,"|OBJECT_NAME|OBJECT_TYPE|AUDIT_OPTION|WHENEVER_SUCC|WHENEVER_UNSUCC|"); break;case CASE_SHOW_SEGMENTS_EXTENTS: strcpy (dyn_column,"|OWNER|SEGMENT_NAME|SEGMENT_TYPE|TABLESPACE_NAME|KBYTES|"); strcat (dyn_column,"BLOCKS|EXTENTS|NEXT_EXTENT|PCT_INCREASE|MAX_EXTENTS|"); strcat (dyn_column,"FREE_EXTENTS|IMAGE_INDEX|"); break;case CASE_SHOW_EXTENTS_INSIDE_DATAFILES: strcpy (dyn_column,"|EXTENT_ID|OWNER|SEGMENT_NAME|SEGMENT_TYPE|"); strcat (dyn_column,"TABLESPACE_NAME|FILE_ID|BLOCK_ID|KBYTES|BLOCKS|FILE_NAME|"); break;case CASE_SHOW_USER_LISTS: strcpy (dyn_column,"|USERNAME|USER_ID|DEFAULT_TABLESPACE|password|TEMPORARY_TABLESPACE|"); strcat (dyn_column,"CREATED|PROFILE|ACCOUNT_STATUS|LOCK_DATE|EXPIRY_DATE|"); strcat (dyn_column,"INITIAL_RSRC_CONSUMER_GROUP|SYSDBA|SYSOPER|"); break;case CASE_SHOW_ROLES_PRIVILEGES: strcpy (dyn_column,"|PRIVILEGE|OWNER|TABLE_NAME|GRANTOR|GRANTEE|GRANTABLE|COL_PRIVS|"); break;case CASE_SHOW_PRIVILEGES_COLUMNS: strcpy (dyn_column,"|COLUMN_NAME|GRANTOR|GRANTEE|PRIVILEGE|GRANTABLE|DATA_TYPE|"); strcat (dyn_column,"SQL_TYPE|NULLABLE|IMAGE_INDEX|"); break;case CASE_SHOW_LOCKS_VIEWS: strcpy (dyn_column,"|id1|type|lmode|request|object_name|owner|"); strcat (dyn_column,"object_type|image_index|"); break;case CASE_GRAPH_LOCK_WAITS: strcpy (dyn_column,"|SID|PROGRAM|USERNAME|TERMINAL|"); break;case CASE_OBJECT_ACCESS_SESSION: strcpy (dyn_column,"|SID|OBJECT ACCESED|TYPE|"); break;case CASE_SHOW_LATCHES: strcpy (dyn_column,"|ADDR|LATCH#|LEVEL#|NAME|GETS|MISSES|SLEEPS|IMMEDIATE_GETS|"); strcat (dyn_column,"IMMEDIATE_MISSES|WAITERS_WOKEN|WAITS_HOLDING_LATCH|SPIN_GETS|"); strcat (dyn_column,"SLEEP1|SLEEP2|SLEEP3|SLEEP4|SLEEP5|SLEEP6|SLEEP7|SLEEP8|"); strcat (dyn_column,"SLEEP9|SLEEP10|SLEEP11|NAME|"); break;
  • 40. case CASE_SHOW_STATISTICS: strcpy (dyn_column,"|ID|NAME|SET_MSIZE|CNUM_REPL|CNUM_WRITE|"); strcat (dyn_column,"CNUM_SET|BUF_GOT|SUM_WRITE|SUM_SCAN|"); strcat (dyn_column,"FREE_BUF_WAIT|WRI_COM_WAIT|BUF_BUSY_WAIT|"); strcat (dyn_column,"FREE_BUF_INSPECTED|DIRTY_BUF_INSPECTED|"); strcat (dyn_column,"DB_BLOCK_CHANGE|DB_BLOCK_GETS|"); strcat (dyn_column,"CONSIST_GETS|PHYS_READ|PHYS_WRIT|"); break;case CASE_SHOW_TRANSACTIONS: strcpy (dyn_column,"|SID|ADDR|XIDUSN|XIDSLOT|XIDSQN|UBAFIL|UBABLK|UBASQN|UBAREC|STATUS|"); strcat (dyn_column,"START_TI|START_SCNB|START_SCNW|START_UEXT|START_UBAFIL|"); strcat (dyn_column,"START_UBABLK|START_UBASQN|START_UBAREC|SES_ADDR|FLAG|SPACE|"); strcat (dyn_column,"RECURSIVE|NOUNDO|PRV_XIDUSN|PRV_XIDSLT|PRV_XIDSQN|PTX|PTX_XIDUSN|"); strcat (dyn_column,"PTX_XIDSLT|PTX_XIDSQN|DSCN_B|DSCN_W|USED_UBLK|USED_UREC|LOG_IO|"); strcat (dyn_column,"PHY_IO|CR_GET|CR_CHANGE|"); break;case CASE_SHOW_DATAFILES_STATUS: strcpy (dyn_column,"|FILEID|TABLESPACE_NAME|AUEXT|MAXBYTES|NEXT_SIZE|"); strcat (dyn_column,"KBYTES|BLOCKS|STATUS|MAX_CHUNK_SPACE|MIN_CHUNK_SPACE|FREE_SPACE|"); strcat (dyn_column,"FRAGMENTS|USAGE_PCT|BACKUP_STATUS|BACKUP_CHANGE#|BACKUP_TIME|"); strcat (dyn_column,"FILE_NAME|"); break;case CASE_SHOW_DB_OBJECT_CACHE: strcpy (dyn_column,"|OWNER|NAMESPACE|LOADS|EXECS|LOCKS|PINS|KEPT|SHAREDMEM|NAME|"); break;case CASE_TABLE_ALERT_EXTENT_USED: strcpy (dyn_column,"|OWNER|TABLENAME|TIPO|MINEXT|MAXEXT|EXTUSED|PORCEN|"); break;case CASE_INDEX_ALERT_EXTENT_USED: strcpy (dyn_column,"|OWNER|INDEXNAME|TIPO|MINEXT|MAXEXT|EXTUSED|PORCEN|"); break;case CASE_USER_TIME_WORKING: strcpy (dyn_column,"|OSUSER|USUARIO|ESTADO|KILL|PIDUNIX|VTEXT|READS|GETS|"); strcat (dyn_column,"MINUTOS|LOGON|"); break;case CASE_IS_USER_WORKING: strcpy (dyn_column,"|OSUSER|USERNAME|ESTADO|KILL|PIDUNIX|VTEXT|READS|GETS|"); strcat (dyn_column,"MINUTOS|LOGON|"); break;case CASE_VER_SQL_PROGRAM:
  • 41. strcpy (dyn_column,"|PID|SPID|SID|STATUS|OSUSER|USERNAME|MACHINE|TERMINAL|KILL|VTEXT|MINUTOS|"); break;case CASE_SQL_SESS_IO: strcpy (dyn_column,"|SID|USERNAME|TERMINAL|MACHINE|BLCKGETS|"); strcat (dyn_column,"CONSISGETS|PHYSREADS|BLCKCHGS|"); strcat (dyn_column,"CONSISCHGS|"); break;case CASE_SQL_SESSION_EVENT: strcpy (dyn_column,"|SID|USERNAME|TERMINAL|MACHINE|"); strcat (dyn_column,"EVENT|TOTWAIT|TOTTIME|TIMWAITED|"); strcat (dyn_column,"AVGWAIT|MAXWAIT|"); break;case CASE_SQL_SESSION_WAIT: strcpy (dyn_column,"|SID|USERNAME|TERMINAL|MACHINE|"); strcat (dyn_column,"SEQ#|EVENT|P1TEXT|P1|P1RAW|"); strcat (dyn_column,"P2TEXT|P2|P2RAW|P3|P3TEXT|P3RAW|"); strcat (dyn_column,"WAIT_TIME|SECINWAIT|STATE|"); break;case CASE_SQL_SESSION_LONG_OPER: strcpy (dyn_column,"|SID|USERNAME|TERMINAL|MACHINE|SERIAL#|OPNAME|TARGET|"); strcat (dyn_column,"TARGET_DESC|SOFAR|TOTALWORK|UNITS|START_TIME|"); strcat (dyn_column,"LAST_UPDATE_TIME|TIME_REMAINING|ELAPSED_SECONDS|"); strcat (dyn_column,"CONTEXT|MESSAGE|USERNAME|SQL_ADDRESS|"); strcat (dyn_column,"SQL_HASH_VALUE|QCSID|"); break;case CASE_SQL_LOCKED_OBJECTS: strcpy (dyn_column,"|XIDUSN|XIDSLOT|XIDSQN|OBJID|SESID|ORAUSER|"); strcat (dyn_column,"OSUSER|PROCESS|LOCKMODE|"); break;case CASE_SQL_TRANSACTION_DETAIL: strcpy (dyn_column,"|ADDR|XIDUSN|XIDSLOT|XIDSQN|UBAFIL|"); strcat (dyn_column,"UBABLK|UBASQN|UBAREC|START_UBAFIL|"); strcat (dyn_column,"START_UBABLK|START_UBASQN|START_UBAREC|"); strcat (dyn_column,"LOG_IO|PHY_IO|"); break;case CASE_SQL_LOCK_MEDIUM_INFO: strcpy (dyn_column,"|SADDR|SID|SERIAL|USERNAME|TERMINAL|TYPE|"); strcat (dyn_column,"TABLE|OWNER|ID1|ID2|LMODE|RMODE|"); break;case CASE_SQL_LOCK_FULL_INFO:
  • 42. strcpy (dyn_column,"|USER|SID|TERMINAL||||||||||||||||"); break; case CASE_SQL_LOCK_BY_SESSION_ID: strcpy (dyn_column,"|USER OS|PID|SID|USER ORA|LOCKS|TYPE|MODE|WAIT|"); break; case CASE_SQL_WHO_IS_WAITING_FOR: strcpy (dyn_column,"|WAITING USER|USER OS|SID|PID|HOLDING USER|"); strcat (dyn_column,"USER OS|SID|PID|"); break; case CASE_SQL_WHICH_SQL_RUNNING: strcpy (dyn_column,"||||||||||||||||"); break; case CASE_WHICH_OBJECTS_LOCKED_BY_USER: strcpy (dyn_column,"|ADDR|INDX|INST_ID|KGLLKADR|KGLLKUSE|"); strcat (dyn_column,"KGLLKSES|KGLLKSNM|KGLLKHDL|KGLLKPNC|KGLLKPNS|"); strcat (dyn_column,"KGLLKCNT|KGLLKMOD|KGLLKREQ|KGLLKFLG|KGLLKSPN|"); strcat (dyn_column,"KGLLKHTB|KGLNAHSH|KGLHDPAR|KGLHDNSP|USER_NAME|"); strcat (dyn_column,"KGLNAOBJ|"); break;/* ------------------------------------------------- *//************* Agregado 25-Agosto-2005 ***************/ case CASE_BUFFER_CACHE_DEFINED: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|ID|NAME|BLOCK_SZ|CURRENT_SZ|"); strcat (dyn_column,"BUFFERS|"); break; } break;/* ------------------------------------------------- */ case CASE_BUFFER_CACHE_TOTAL_SIZE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|TOT_CUR_SIZE|TOT_BUFFERS|"); break; } break;
  • 43. /* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|OPTIMIZER_INDEX_COST_ADJ|"); break; } break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|OPTIMIZER_INDEX_CACHING|"); break; } break;/* ------------------------------------------------- *//* ------------------------------------------------- */ default: strcpy (dyn_column,"|ORACLE_VERSION|"); break; } return (dyn_column); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---****************************************************************************************************************************************************************************************************************************************************************************************************
  • 44. ***************************************************************************************************************************************************** ****** ****** ARCHIVO: func_dyn_proc_func_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();char *func_dyn_proc_func_set (int version, int sentencia) { static char dyn_proc_func [MAX_VAR_SIZE]; vaciar_cadena (dyn_proc_func,MAX_VAR_SIZE); strcpy (dyn_proc_func,"|NO|"); switch (sentencia) { case CASE_ORACLE_VERSION: break; case CASE_ACTIVE_PARAMETERS: break; case CASE_USERS_CONNECTED: break; case CASE_WAIT_STATISTICS: break;
  • 45. case CASE_DATAFILE_I_0: switch (version) { case VERSION_ORACLE_920: break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: break; default: break; } break;case CASE_DATAFILE_BLOCKS_R_W: break;case CASE_WAIT_EVENTS: break;case CASE_INSTANCE_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: strcpy (dyn_proc_func,"|SI|0809|"); break; default: break; } break;case CASE_TEMPORAL_SPACE_BY_USER: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: default:
  • 46. break; } break;case CASE_TOT_FREELIST_WAIT_PERCENT: break;case CASE_LAST_CHECKPOINT_TIME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; default: break; } break;case CASE_LIST_TABLESPACES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; } break;case CASE_ACTIVE_TRANSACTIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0401|");
  • 47. /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; } break;case CASE_LATCH_DETAILS: break;case CASE_RESOURCE_LIMITS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; } break;case CASE_LIST_DATAFILES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; } break;case CASE_LIST_DATAFILES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; } break;case CASE_LIST_TABLESPACES_NEW_9I:
  • 48. switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: break; case VERSION_ORACLE_734: break; } break;case CASE_ACTIVE_SESSIONS: break;case CASE_SESSIONS_WAITS: break;case CASE_DEFAULT_STORAGE_SETS_TABLESPACE: break;case CASE_ALL_TABLES_STORAGE_SETTINGS: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0405|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break;case CASE_ALL_NON_SYS_TABLES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0701|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; case VERSION_ORACLE_734: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0501|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; }
  • 49. break;case CASE_ALL_NON_SYS_INDEXES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0701|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; case VERSION_ORACLE_734: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0401|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; } break;case CASE_USER_DEFINED: printf ("Pasando Seteo Funcion 24 n"); break;case CASE_LIST_DATAFILE_REDO_CONTROL_FILES: break;case CASE_LIST_DATAFILES_USED_BLOCKS: break;case CASE_LIST_SORT_BY_USER: break;case CASE_LIST_LOCK_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0603||1109|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break;
  • 50. case VERSION_ORACLE_734: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0703||0603||0806||0907||1008||1109|"); /* |1008|"); */ /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break; } break;case CASE_LIST_USER_BY_CPU_USAGE: break;case CASE_SQL_STATEMENT_BY_THIS_USER: break;case CASE_REDO_LOGS_STATUS: break;case CASE_ARCHIVED_LOGS_HISTORY: break;case CASE_REDO_LOG_RECOVERY_REPORT: break;case CASE_ARCHIVE_LOG_HISTROY: break;case CASE_SESSION_LATCH_WAITS_SQL: break;case CASE_SESSION_PROGRAM_RUNNING_SQL: break;case CASE_PRIVILEGES_BY_USER: break;case CASE_DETAILED_LOCKING_CAUSES: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0402||0503||0603||0804|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ break;case CASE_CURRENT_STATISTICS_VALUES: break;case CASE_TABLE_DESCRIPTION_USER_TABLENAME: break;case CASE_INDEX_DESCRIPTION_USER_INDEXNAME: break;case CASE_CURRENT_ACTIVITY_REPORT: break;
  • 51. case CASE_DICTIONARY_TABLE_COMMENTS: break; case CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP: break; case CASE_SGA_STATISTIC_GENERAL: break; case CASE_SGA_STATISTIC_MEMORY_USAGE: break; case CASE_SGA_STATISTIC_INFORMATION: break; case CASE_ROW_CACHE_INFORMATION: break; case CASE_PERFORMANCE_DISK_I_O: break; case CASE_RECURSIVE_CALLS: break; case CASE_SYSTEM_EVENTS: break;/* -------------------------------------------------------------- */ case CASE_SQL_AREA_ALL_ENTRIES: break; case CASE_SQL_AREA_CPU_USAGE: break; case CASE_SQL_AREA_MEMORY_USAGE: break; case CASE_SQL_AREA_BUFFER_GET_SUM: break; case CASE_INIT_PARAMETERS_VALUES_STATUS: break;/* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_proc_func,"|SI|0610|"); break; case CASE_SHOW_NLS_PARAMETERS: break; case CASE_CONTROL_FILES_STATUS: break;
  • 52. case CASE_SORT_SEGMENTS_USERS: break;case CASE_ORACLE_QUOTAS: break;case CASE_TABLE_GENERAL_DESCRIPTION: break;case CASE_TABLE_COLUMN_DESCRIPTION: break;case CASE_TABLE_CONSTRAINTS: break;case CASE_INDEX_GENERAL_DESCRIPTION: break;case CASE_AUDIT_DEFINITION: break;case CASE_SHOW_SEGMENTS_EXTENTS: break;case CASE_SHOW_EXTENTS_INSIDE_DATAFILES: break;case CASE_SHOW_USER_LISTS: break;case CASE_SHOW_ROLES_PRIVILEGES: break;case CASE_SHOW_PRIVILEGES_COLUMNS: break;case CASE_SHOW_LOCKS_VIEWS: break;case CASE_GRAPH_LOCK_WAITS: break;case CASE_OBJECT_ACCESS_SESSION: break;case CASE_SHOW_LATCHES: break;case CASE_SHOW_STATISTICS: break;case CASE_SHOW_DATAFILES_STATUS: break;case CASE_SHOW_DB_OBJECT_CACHE: break;case CASE_TABLE_ALERT_EXTENT_USED: break;
  • 53. case CASE_INDEX_ALERT_EXTENT_USED: break; case CASE_USER_TIME_WORKING: break; case CASE_IS_USER_WORKING: break; case CASE_VER_SQL_PROGRAM: break; case CASE_SQL_SESS_IO: break; case CASE_SQL_SESSION_EVENT: break; case CASE_SQL_SESSION_WAIT: break; case CASE_SQL_SESSION_LONG_OPER: break; case CASE_SQL_LOCKED_OBJECTS: break; case CASE_SQL_TRANSACTION_DETAIL: break; case CASE_SQL_LOCK_MEDIUM_INFO: break; case CASE_SQL_LOCK_FULL_INFO: break; case CASE_SQL_LOCK_BY_SESSION_ID: break; case CASE_SQL_WHO_IS_WAITING_FOR: break; case CASE_SQL_WHICH_SQL_RUNNING: break; case CASE_WHICH_OBJECTS_LOCKED_BY_USER: break;/* ------------------------------------------------- *//************* Agregado 25-Agosto-2005 ***************/ case CASE_BUFFER_CACHE_DEFINED: break;/* ------------------------------------------------- */ case CASE_BUFFER_CACHE_TOTAL_SIZE: break;/* ------------------------------------------------- */
  • 54. case CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE: break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE: break;/* ------------------------------------------------- *//* ------------------------------------------------- */ default: break; } return (dyn_proc_func); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_dyn_size_set.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>
  • 55. #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();char *func_dyn_size_set (int version, int sentencia) { static char dyn_size[MAX_VAR_SIZE]; vaciar_cadena (dyn_size,MAX_VAR_SIZE); switch (sentencia) { case CASE_ORACLE_VERSION: strcpy (dyn_size,"800"); break; case CASE_ACTIVE_PARAMETERS: strcpy (dyn_size,"3555400"); break; case CASE_USERS_CONNECTED: strcpy (dyn_size,"0804150608151611220"); break; case CASE_WAIT_STATISTICS: strcpy (dyn_size,"1010300"); break; case CASE_DATAFILE_I_0: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_size,"0808080860100"); break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: strcpy (dyn_size,"06060606600"); break; default:
  • 56. break; } break;case CASE_DATAFILE_BLOCKS_R_W: strcpy (dyn_size,"600606060"); break;case CASE_WAIT_EVENTS: strcpy (dyn_size,"082010300"); break;case CASE_INSTANCE_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"03080910220503101020300"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"061815121209081010200"); 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_size,"1010101010300"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"09070706060506060808080808060"); default: break; } break;case CASE_TOT_FREELIST_WAIT_PERCENT: strcpy (dyn_size,"120");
  • 57. break;case CASE_LAST_CHECKPOINT_TIME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"15220"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"150"); break; default: break; } break;case CASE_LIST_TABLESPACES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"1510100610100708101010100"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"1510100610100708101010100"); break; } break;case CASE_ACTIVE_TRANSACTIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"102208080810040605400"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"0820070808100706051010100"); break;
  • 58. } break;case CASE_LATCH_DETAILS: strcpy (dyn_size,"100408080805070808250"); break;case CASE_RESOURCE_LIMITS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"30101010100"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"50100"); break; } break;case CASE_LIST_DATAFILES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"7010080"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"7010080"); break; } break;case CASE_LIST_DATAFILES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"0660181212080"); break; case VERSION_ORACLE_734:
  • 59. strcpy (dyn_size,"0660181212080"); break; } break;case CASE_LIST_TABLESPACES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"062510121212121212121210101010100"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"062510121212121212121210101010100"); break; } break;case CASE_ACTIVE_SESSIONS: strcpy (dyn_size,"04041015221009221509400"); break;case CASE_SESSIONS_WAITS: strcpy (dyn_size,"04040505150825201010101010101010101010101010100"); break;case CASE_DEFAULT_STORAGE_SETS_TABLESPACE: strcpy (dyn_size,"2012121212070"); break;case CASE_ALL_TABLES_STORAGE_SETTINGS: strcpy (dyn_size,"152020101010080"); break;case CASE_ALL_NON_SYS_TABLES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"18202008081018080"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"18202008081018080"); break;
  • 60. } break;case CASE_ALL_NON_SYS_INDEXES_SETTINGS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"12252008081018080"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"12252008081018080"); break; } break;case CASE_USER_DEFINED: printf ("Pasando Seteo ColSize 24 n0"); switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"201812202020221010100"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"201812202020221010100"); break; } break;case CASE_LIST_DATAFILE_REDO_CONTROL_FILES: strcpy (dyn_size,"7020100"); break;case CASE_LIST_DATAFILES_USED_BLOCKS: strcpy (dyn_size,"2560121212120"); break;case CASE_LIST_SORT_BY_USER: strcpy (dyn_size,"141806202510100"); break;case CASE_LIST_LOCK_STATUS: switch (version)
  • 61. { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"0909040607041111082504090"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"0909040405041111082504090"); break; } break;case CASE_LIST_USER_BY_CPU_USAGE: strcpy (dyn_size,"050710102310252007700"); break;case CASE_SQL_STATEMENT_BY_THIS_USER: strcpy (dyn_size,"700"); break;case CASE_REDO_LOGS_STATUS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"0707101010101012200"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"0707101010101012200"); break; } break;case CASE_ARCHIVED_LOGS_HISTORY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"06075010230808100"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"0607180808500");
  • 62. break; } break;case CASE_REDO_LOG_RECOVERY_REPORT: strcpy (dyn_size,"061252080"); break;case CASE_ARCHIVE_LOG_HISTROY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"08101717220"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"06080808220"); break; } break;case CASE_SESSION_LATCH_WAITS_SQL: strcpy (dyn_size,"053030600"); break;case CASE_SESSION_PROGRAM_RUNNING_SQL: strcpy (dyn_size,"073060800"); break;case CASE_PRIVILEGES_BY_USER: strcpy (dyn_size,"2525400"); break;case CASE_DETAILED_LOCKING_CAUSES: strcpy (dyn_size,"3005152810181814500"); break;case CASE_CURRENT_STATISTICS_VALUES: strcpy (dyn_size,"0855150"); break;case CASE_TABLE_DESCRIPTION_USER_TABLENAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920:
  • 63. strcpy (dyn_size,"12123208190707070707070707070707070"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"12123208190707070707070707070707070"); break; } break;case CASE_INDEX_DESCRIPTION_USER_INDEXNAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_size,"15121512080915060606060606060706070707070"); break; case VERSION_ORACLE_734: strcpy (dyn_size,"15121512080915060606060606060706070707070"); break; } break;case CASE_CURRENT_ACTIVITY_REPORT: strcpy (dyn_size,"10120812990"); break;case CASE_DICTIONARY_TABLE_COMMENTS: strcpy (dyn_size,"35700"); break;case CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP: strcpy (dyn_size,"253065150806120"); break;case CASE_SGA_STATISTIC_GENERAL: strcpy (dyn_size,"042510101005101010450"); break;case CASE_SGA_STATISTIC_MEMORY_USAGE: strcpy (dyn_size,"15351212120"); break;case CASE_SGA_STATISTIC_INFORMATION: strcpy (dyn_size,"40200"); break;case CASE_ROW_CACHE_INFORMATION: strcpy (dyn_size,"060625101007101010070506060");
  • 64. break; case CASE_PERFORMANCE_DISK_I_O: strcpy (dyn_size,"501010100"); break; case CASE_RECURSIVE_CALLS: strcpy (dyn_size,"30200"); break; case CASE_SYSTEM_EVENTS: strcpy (dyn_size,"40121212120"); break;/* -------------------------------------------------------------- */ /*#define CASE_SQL_AREA_ALL_ENTRIES 52 */ case CASE_SQL_AREA_ALL_ENTRIES: strcpy (dyn_size,"0807090909050303030305050519"); strcat (dyn_size,"0508080815151508071215080505060"); break; /*#define CASE_SQL_AREA_CPU_USAGE 53 */ case CASE_SQL_AREA_CPU_USAGE: strcpy (dyn_size,"0807070707050303030305050519"); strcat (dyn_size,"050808081515150807121508050506"); break; /*#define CASE_SQL_AREA_MEMORY_USAGE 54 */ case CASE_SQL_AREA_MEMORY_USAGE: strcpy (dyn_size,"0807070707050303030305050519"); strcat (dyn_size,"050808081515150807121508050506"); break; /* /*#define CASE_SQL_AREA_BUFFER_GET_SUM 55 */ case CASE_SQL_AREA_BUFFER_GET_SUM: strcpy (dyn_size,"0807070707050303030305050519"); strcat (dyn_size,"050808081515150807121508050506");
  • 65. break; /*#define CASE_INIT_PARAMETERS_VALUES_STATUS 56 */ case CASE_INIT_PARAMETERS_VALUES_STATUS: strcpy (dyn_size,"05355005050508050535"); break;/* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_size,"250909091516120606060"); break; case CASE_SHOW_NLS_PARAMETERS: strcpy (dyn_size,"30404040350"); break; case CASE_CONTROL_FILES_STATUS: strcpy (dyn_size,"50120"); break; case CASE_SORT_SEGMENTS_USERS: strcpy (dyn_size,"1506080706070707090709"); strcat (dyn_size,"07070708060609090909090"); break; case CASE_ORACLE_QUOTAS: strcpy (dyn_size,"30191111111111"); break; case CASE_TABLE_GENERAL_DESCRIPTION: strcpy (dyn_size,"20303012120909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909"); break; case CASE_TABLE_COLUMN_DESCRIPTION: strcpy (dyn_size,"2040350"); break; case CASE_TABLE_CONSTRAINTS: strcpy (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909");
  • 66. strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); strcat (dyn_size,"09090909090909090909"); break;case CASE_INDEX_GENERAL_DESCRIPTION: strcpy (dyn_size,"2535063525151515"); break;case CASE_AUDIT_DEFINITION: strcpy (dyn_size,"3520301212"); break;case CASE_SHOW_SEGMENTS_EXTENTS: strcpy (dyn_size,"122525301212121212121212"); break;case CASE_SHOW_EXTENTS_INSIDE_DATAFILES: strcpy (dyn_size,"08253012250808080880"); break;case CASE_SHOW_USER_LISTS: strcpy (dyn_size,"30083010302312081010101010101010"); break;case CASE_SHOW_ROLES_PRIVILEGES: strcpy (dyn_size,"1010101010101010101010101010"); break;case CASE_SHOW_PRIVILEGES_COLUMNS: strcpy (dyn_size,"10101010101010101010"); break;case CASE_SHOW_LOCKS_VIEWS: strcpy (dyn_size,"082020201020101020101010"); break;case CASE_GRAPH_LOCK_WAITS: strcpy (dyn_size,"08653025"); break;case CASE_OBJECT_ACCESS_SESSION: strcpy (dyn_size,"087015"); break;case CASE_SHOW_LATCHES: strcpy (dyn_size,"10101010101010101010"); strcat (dyn_size,"10101010101010101010"); strcat (dyn_size,"10101010"); break;
  • 67. case CASE_SHOW_STATISTICS: strcpy (dyn_size,"05101010101010101015151515151515151515"); break;case CASE_SHOW_TRANSACTIONS: strcpy (dyn_size,"0509060606060606060609"); strcat (dyn_size,"10101010101010100707"); strcat (dyn_size,"10071010100610101008"); strcat (dyn_size,"08101008080810101010"); break;case CASE_SHOW_DATAFILES_STATUS: strcpy (dyn_size,"063007101010101010"); strcat (dyn_size,"1010101013121260"); break;case CASE_SHOW_DB_OBJECT_CACHE: strcpy (dyn_size,"202006060606061060"); break;case CASE_TABLE_ALERT_EXTENT_USED: strcpy (dyn_size,"30301010101006"); break;case CASE_INDEX_ALERT_EXTENT_USED: strcpy (dyn_size,"30301010101006"); break;case CASE_USER_TIME_WORKING: strcpy (dyn_size,"13200923122008081522"); break;case CASE_IS_USER_WORKING: strcpy (dyn_size,"10200923122008081522"); break;case CASE_VER_SQL_PROGRAM: strcpy (dyn_size,"0606060813201222212010"); break;case CASE_SQL_SESS_IO: strcpy (dyn_size,"05301218090909090909"); break;case CASE_SQL_SESSION_EVENT: strcpy (dyn_size,"05301218320808080808"); break;case CASE_SQL_SESSION_WAIT: strcpy (dyn_size,"053012180615121009121009121009070707"); break;
  • 68. case CASE_SQL_SESSION_LONG_OPER: strcpy (dyn_size,"05281218071840060808061818050505"); strcat (dyn_size,"1825101408"); break; case CASE_SQL_LOCKED_OBJECTS: strcpy (dyn_size,"080808080830121509"); break; case CASE_SQL_TRANSACTION_DETAIL: strcpy (dyn_size,"1010101010101010101010101010"); break; case CASE_SQL_LOCK_MEDIUM_INFO: strcpy (dyn_size,"160507251218252507071212"); break; case CASE_SQL_LOCK_FULL_INFO: strcpy (dyn_size,"300610351515151525"); break; case CASE_SQL_LOCK_BY_SESSION_ID: strcpy (dyn_size,"101010101010101010101010101010101010"); break; case CASE_SQL_WHO_IS_WAITING_FOR: strcpy (dyn_size,"101010101010101010101010101010101010"); break; case CASE_SQL_WHICH_SQL_RUNNING: strcpy (dyn_size,"101010101010101010101010101010101010"); break; case CASE_WHICH_OBJECTS_LOCKED_BY_USER: strcpy (dyn_size,"1010101010101010101010101010101010101010101010101010"); break;/* ------------------------------------------------- *//************* Agregado 25-Agosto-2005 ***************/ case CASE_BUFFER_CACHE_DEFINED: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_size,"1010101010101010101010101010101010101010101010101010"); break; } break;/* ------------------------------------------------- */
  • 69. case CASE_BUFFER_CACHE_TOTAL_SIZE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_size,"1010101010101010101010101010101010101010101010101010"); break; } break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_size,"1010"); break; } break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_size,"1010"); break; }/* ------------------------------------------------- */ default: strcpy (dyn_size,"800"); break; } return (dyn_size); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ---
  • 70. --- ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: 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)
  • 71. {case CASE_ORACLE_VERSION: strcpy (dyn_sts,"select ltrim(lpad(banner,70)) Version from v$version "); strcat (dyn_sts,"where banner like %Oracle% "); break;case CASE_ACTIVE_PARAMETERS: strcpy (dyn_sts,"select name,value,description from v$parameter order by 1 "); break;case CASE_USERS_CONNECTED: strcpy (dyn_sts,"select saddr ADDRESS,sid SES,username NOMBRE,command CMD, n"); strcat (dyn_sts,"status ESTADO,process PID,terminal TERMINAL,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,class CLASE 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 by 2 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$filestat f,v$datafile d "); strcat (dyn_sts,"where f.file# = d.file# "); strcat (dyn_sts,"order by 2 n"); break; default: break; } break;
  • 72. case CASE_DATAFILE_BLOCKS_R_W: strcpy (dyn_sts,"select d.name DATAFILE, f.phyblkrd BLK_READ, f.phyblkwrt BLK_WRITE, n"); strcat (dyn_sts,"f.phyblkrd+f.phyblkwrt BLK_TOTAL from v$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.username USUARIO,count(*) CANTIDAD,sw.event EVENTO n"); strcat (dyn_sts,"from v$session se, v$session_wait sw where sw.sid=se.sid and n"); strcat (dyn_sts,"se.username > A and sw.event not like SQL*Net% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Table Q Normal% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Execution Msg% 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,"select a.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 log from 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 where key=RESTRICTED MODE) b, n"); strcat (dyn_sts,"(select decode(value,0,NO) val2 n"); strcat (dyn_sts,"from v$instance where key=SHUTDOWN PENDING) c, n"); strcat (dyn_sts,"(select to_char(to_date(value, J),DD/MM/YYYY) val3 n"); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - JULIAN ) d, n"); strcat (dyn_sts,"(select value n"); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - SECONDS ) e n"); break; default:
  • 73. 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)*(select value 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 by se.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_segment n"); default: break; } break;case CASE_TOT_FREELIST_WAIT_PERCENT: strcpy (dyn_sts,"select (a.count/sum(b.value))*100 PCT_FREELIST from v$waitstat a, n"); strcat (dyn_sts,"v$sysstat b where a.class=free list and n"); strcat (dyn_sts,"b.name in (db block gets,consistent gets) 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,"from v$datafile_header"); break; case VERSION_ORACLE_734:
  • 74. strcpy (dyn_sts,"select count(sid) Cantidad from v$session n"); break; default: break; } break;case CASE_LIST_TABLESPACES: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select a.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB, n"); strcat (dyn_sts,"a.max_id MAX_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 (select tablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id from dba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(select tablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group by tablespace_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,"select a.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB, n"); strcat (dyn_sts,"a.max_id MAX_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 (select tablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id from dba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(select tablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group by tablespace_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) {
  • 75. 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.status ESTADO,tr.used_ublk BLK_USED,tr.used_ublk*(select value n"); strcat (dyn_sts,"from v$parameter where name in db_block_size)/1000 KB_USED,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.saddr order 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.status ESTADO,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.saddr order by 2,6"); break; } break;case CASE_LATCH_DETAILS: strcpy (dyn_sts,"select gets GETS,misses MISS,round((gets-misses)*100/gets,2) HITRATIO, n"); strcat (dyn_sts,"immediate_gets IMM_GETS,immediate_misses IMM_MISS,sleeps SLEEP, n"); strcat (dyn_sts,"spin_gets GETSPIN,addr ADDR,latch#,name NOMBRE 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_name NOMBRE,initial_allocation INIT_ALLOC, n"); strcat (dyn_sts,"current_utilization CURR_UTILIZA,max_utilization MAX_UTILIZA, n"); strcat (dyn_sts,"limit_value LIMITE from v$resource_limit order by 4");
  • 76. break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select resource_name, limit n"); strcat (dyn_sts,"from user_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 name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n"); strcat (dyn_sts," order by MBYTES desc n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n");/* FALTARIA VER COMO HACEMOS PARA BUSCAR LA PARTE TEMPORAL EN VERSIONES 7.3.4 strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n");*/ strcat (dyn_sts," order by MBYTES desc n"); 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");
  • 77. strcat (dyn_sts,"from sys.dba_data_files d, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_space group by file_id) s n"); strcat (dyn_sts,"where s.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_files d, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"where t.file_id(+)=d.file_id and d.file_id=v.file# n"); strcat (dyn_sts,"order by SIZE_KB desc n"); 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"); strcat (dyn_sts,"from sys.dba_data_files d, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_space group by file_id) s n"); strcat (dyn_sts,"where s.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_files d, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"where t.file_id(+)=d.file_id and d.file_id=v.file# n");*/ strcat (dyn_sts,"order by SIZE_KB desc n"); break; } break; case CASE_LIST_TABLESPACES_NEW_9I: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817:
  • 78. case VERSION_ORACLE_920: strcpy (dyn_sts,"select d.status ESTADO, d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat (dyn_sts,"d.extent_management EXTENT_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,"from sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_space group by tablespace_name ) f n"); strcat (dyn_sts,"where d.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_management EXTENT_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 from sys.dba_tablespaces d, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group by tablespace_name) t where d.tablespace_name=a.tablespace_name (+) and n"); strcat (dyn_sts,"d.tablespace_name=t.tablespace_name (+) and d.extent_management like LOCAL and n"); strcat (dyn_sts,"d.contents like TEMPORARY n"); strcat (dyn_sts,"order by SIZE_KB desc n"); 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,"from sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_space group by tablespace_name ) f n"); strcat (dyn_sts,"where d.tablespace_name=a.tablespace_name(+) and n"); strcat (dyn_sts,"d.tablespace_name = f.tablespace_name(+) and n"); strcat (dyn_sts,"not 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");
  • 79. 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 from sys.dba_tablespaces d, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group by tablespace_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 like TEMPORARY "); */ strcat (dyn_sts,"order by SIZE_KB desc n"); break; } break; case CASE_ACTIVE_SESSIONS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: 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.program PROGRAMA n"); strcat (dyn_sts,"from v$session s, v$process p n"); strcat (dyn_sts,"where osuser is not null and p.addr=s.paddr n"); strcat (dyn_sts,"order by LOGON, ESTADO n"); 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.program PROGRAMA n"); strcat (dyn_sts,"from v$session s, v$process p n"); strcat (dyn_sts,"where osuser is not null and p.addr=s.paddr n"); strcat (dyn_sts,"order by LOGON, ESTADO n"); break; } break; case CASE_SESSIONS_WAITS:
  • 80. 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 se n"); strcat (dyn_sts,"where sw.sid = se.sid order by 6,8 n"); 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_extents MAX_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_name SEG_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,2 n"); break;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 by owner,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");
  • 81. strcat (dyn_sts,"group by owner,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,"select owner,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,"select owner,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: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select * from (select distinct 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");
  • 82. 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 initcap(username) n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select distinct username, 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 from v$logfile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name, CONTROL FILE, status from 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) maximum n"); 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 from v$parameter where name=db_block_size) d n"); strcat (dyn_sts,"where a.file_id = b.file_id n"); 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;
  • 83. 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,"(select ltrim(object_type) n"); strcat (dyn_sts,"from all_objects where object_id=lo.id1) OBJ_TYP, n"); strcat (dyn_sts,"(select ltrim(owner)||.||ltrim(object_name) n"); strcat (dyn_sts,"from all_objects where object_id=lo.id1) OWN_OBJ, n"); strcat (dyn_sts,"(select sid SES n"); strcat (dyn_sts,"from v$session where lockwait=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");
  • 84. 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");/* 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 session n"); 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 ( select vses.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:
  • 85. 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_log order by 6 n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select thread#, sequence#,time, n"); strcat (dyn_sts,"low_change#, high_change#, archive_name n"); strcat (dyn_sts,"from v$log_history n"); 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");
  • 86. 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 and n"); 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 and n"); 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$ sa2, sys.user$ u1, n"); strcat (dyn_sts,"sys.user$ u2, sys.system_privilege_map spm 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");
  • 87. 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,"select tablespace_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");
  • 88. if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where table_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where owner="); 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,"select tablespace_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,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && ( strlen (opcion_dos) > 0 ))
  • 89. { strcat (dyn_sts,"where table_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where owner="); 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; } break;case CASE_INDEX_DESCRIPTION_USER_INDEXNAME: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select owner,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,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where index_name = "); strcat (dyn_sts,opcion_dos);
  • 90. strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where owner="); 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,"select owner,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,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where index_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and index_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n");
  • 91. } 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, 3 desc 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 AND C.OWNER = SYS AND "); strcat (dyn_sts,"S.TABLE_OWNER = SYS AND C.TABLE_NAME = 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 ");
  • 92. 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 AND C.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, "); strcat (dyn_sts,"4, file, 6, big integer, TO_CHAR(TYPE)) TYPE, "); strcat (dyn_sts,"DECODE(ISSES_MODIFIABLE, TRUE, yes, NULL) ISSES_MODIFIABLE, ");
  • 93. 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 or name = large_pool_size or "); strcat (dyn_sts,"name = create_bitmap_area_size or name = java_pool_size or "); strcat (dyn_sts,"name = sort_area_retained_size or name = 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");
  • 94. 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"); 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_USERS PU, SYS.ALL_USERS PS n"); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_ID AND "); strcat (dyn_sts,"PS.USER_ID = A.PARSING_SCHEMA_ID n"); strcat (dyn_sts,"ORDER BY sharable_mem+persistent_mem+runtime_mem desc n"); break; /*#define CASE_SQL_AREA_CPU_USAGE 53 */
  • 95. 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, PU.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_USERS PU, "); strcat (dyn_sts,"SYS.ALL_USERS PS, v$session s n"); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_ID AND "); 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 BY sharable_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, ");
  • 96. 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,"); 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_USERS PU, SYS.ALL_USERS PS "); strcat (dyn_sts,"WHERE PU.USER_ID = A.PARSING_USER_ID AND "); 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, big integer, "); 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;
  • 97. /* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_sts,"SELECT TABLESPACE_NAME, BYTES/1024 KBYTES, "); 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 "); */ strcat (dyn_sts,"n"); strcat (dyn_sts,"UNION "); strcat (dyn_sts,"SELECT TABLESPACE_NAME, BYTES/1024 KBYTES, "); strcat (dyn_sts,"COUNT (*) NUM_EXTENTS, SUM(BYTES)/1024 SUM_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;
  • 98. case CASE_SHOW_NLS_PARAMETERS: strcpy (dyn_sts,"select p.name, d.VALUE value_database, "); strcat (dyn_sts,"i.VALUE value_instance,s.VALUE value_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) STATUS n"); 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_FILE n"); break;case CASE_ORACLE_QUOTAS: strcpy (dyn_sts,"SELECT Q.TABLESPACE_NAME, Q.USERNAME, Q.BYTES/1024 KBYTES, "); 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);
  • 99. 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_NAME TABLE_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.OWNER SYNONYM_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, null table_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 T n"); 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 AND O.OBJECT_TYPE = TABLE n"); strcat (dyn_sts,") SEL, SYS.ALL_TAB_COMMENTS C n"); strcat (dyn_sts,"WHERE C.OWNER = SEL.OWNER AND C.TABLE_NAME = SEL.TABLE_NAME AND n"); strcat (dyn_sts,"SEL.OBJECT_TYPE = TABLE n"); strcat (dyn_sts,"ORDER BY NLSSORT(SEL.NAME,NLS_SORT=BINARY) n"); break;case CASE_TABLE_COLUMN_DESCRIPTION: strcpy (dyn_sts,"select c.owner,c.table_name,column_name n"); strcat (dyn_sts,"from sys.all_cons_columns cc, sys.all_constraints c "); strcat (dyn_sts,"where cc.owner = c.owner n");
  • 100. if ( strlen (opcion_uno) > 0 ) { strcat (dyn_sts,"and c.owner = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," and cc.owner = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } strcat (dyn_sts,"and cc.constraint_name = c.constraint_name and "); if ( strlen (opcion_dos) > 0 ) { strcat (dyn_sts,"c.table_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," AND n"); } strcat (dyn_sts,"c.constraint_type = P n"); strcat (dyn_sts,"order by c.owner,c.table_name,cc.position n"); break; case CASE_TABLE_CONSTRAINTS: strcpy (dyn_sts,"SELECT DISTINCT C1.POSITION, SUBSTR(C1.COLUMN_NAME,1,30) COLUMN_NAME, "); strcat (dyn_sts,"C2.TABLE_NAME, SUBSTR(C2.COLUMN_NAME,1,30) R_COLUMN_NAME, "); strcat (dyn_sts,"DATA_TYPE || DECODE(DATA_TYPE,NUMBER,DECODE( DATA_PRECISION, NULL, "); strcat (dyn_sts,"NULL, ( ||DATA_PRECISION || DECODE( DATA_SCALE, NULL, NULL, , || DATA_SCALE) || )), "); strcat (dyn_sts,"VARCHAR2, ( || DATA_LENGTH || ), CHAR, ( || DATA_LENGTH || ), NULL) SQL_TYPE, "); strcat (dyn_sts,"DECODE( C.NULLABLE, N, NOT NULL, NULL) NULLABLE, "); strcat (dyn_sts,"DECODE( DATA_TYPE, VARCHAR2, 0, CHAR, 0, NUMBER, 1, DATE, 2, "); strcat (dyn_sts,"LONG, 3, RAW, 4, LONG RAW, 5, MLSLABEL, 6, -1) IMAGE_INDEX n"); strcat (dyn_sts,"FROM SYS.ALL_TAB_COLUMNS C, SYS.ALL_CONS_COLUMNS C1, SYS.ALL_CONS_COLUMNS C2 n"); strcat (dyn_sts,"WHERE C1.OWNER = :OWNER AND C1.CONSTRAINT_NAME = :CONSTRAINT_NAME AND n"); strcat (dyn_sts,"C1.TABLE_NAME = :TABLE_NAME AND C.OWNER = :OWNER AND "); strcat (dyn_sts,"C.TABLE_NAME = :TABLE_NAME AND C.OWNER = C1.OWNER AND C.TABLE_NAME = C1.TABLE_NAME "); strcat (dyn_sts,"AND C.COLUMN_NAME = C1.COLUMN_NAME AND C2.OWNER = :R_OWNER AND C2.CONSTRAINT_NAME = :R_CONSTRAINT_NAME "); strcat (dyn_sts,"AND C2.TABLE_NAME = :R_TABLE_NAME AND C1.POSITION= C2.POSITION n"); strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT DISTINCT C1.POSITION, SUBSTR(C1.COLUMN_NAME,1,30) COLUMN_NAME, NULL TABLE_NAME, "); strcat (dyn_sts,"NULL R_COLUMN_NAME, DATA_TYPE || DECODE( DATA_TYPE, NUMBER, "); strcat (dyn_sts,"DECODE( DATA_PRECISION, NULL, NULL, ( || DATA_PRECISION || "); strcat (dyn_sts,"DECODE( DATA_SCALE, NULL, NULL, , || DATA_SCALE) || )), VARCHAR2, ( || DATA_LENGTH || ), "); strcat (dyn_sts,"CHAR, ( || DATA_LENGTH || ), NULL) SQL_TYPE, DECODE( C.NULLABLE, N, NOT NULL, NULL) NULLABLE,");
  • 101. strcat (dyn_sts,"DECODE( DATA_TYPE, VARCHAR2, 0, CHAR, 0, NUMBER, 1, DATE, 2, LONG, "); strcat (dyn_sts,"3, RAW, 4, LONG RAW, 5, MLSLABEL, 6, -1) IMAGE_INDEX n"); strcat (dyn_sts,"FROM (select * from SYS.ALL_TAB_COLUMNS n"); strcat (dyn_sts,"where owner = :owner and table_name = :table_name) C, n"); strcat (dyn_sts,"SYS.ALL_CONS_COLUMNS C1 n"); strcat (dyn_sts,"WHERE C1.OWNER = :OWNER AND C1.CONSTRAINT_NAME = :CONSTRAINT_NAME AND n"); strcat (dyn_sts,"C1.TABLE_NAME = :TABLE_NAME AND C.OWNER (+) = C1.OWNER AND n"); strcat (dyn_sts,"C.TABLE_NAME (+) = C1.TABLE_NAME AND C.COLUMN_NAME (+) = C1.COLUMN_NAME AND n"); strcat (dyn_sts,":R_CONSTRAINT_NAME IS NULL n"); strcat (dyn_sts,"AND :R_TABLE_NAME IS NULL n"); break;case CASE_INDEX_GENERAL_DESCRIPTION: strcpy (dyn_sts,"SELECT I.INDEX_OWNER OWNER, I.INDEX_NAME, I.COLUMN_POSITION, "); strcat (dyn_sts,"SUBSTR(I.COLUMN_NAME,1,255) COLUMN_NAME,DATA_TYPE || "); strcat (dyn_sts,"DECODE( DATA_TYPE,NUMBER, DECODE( DATA_PRECISION, NULL, NULL,"); strcat (dyn_sts," ( || DATA_PRECISION || DECODE( DATA_SCALE , NULL, NULL, , || "); strcat (dyn_sts,"DATA_SCALE) || )),VARCHAR2, ( || DATA_LENGTH || ), CHAR,"); strcat (dyn_sts," ( || DATA_LENGTH || ), NULL) SQL_TYPE, DECODE( C.NULLABLE, N,"); strcat (dyn_sts,"NOT NULL, NULL ) NULLABLE, ASC DESCEND,DECODE( C.DATA_TYPE, VARCHAR2,"); strcat (dyn_sts,"0 , CHAR, 0, NUMBER, 1, DATE, 2, LONG, 3, RAW, 4, LONG RAW, 5,"); strcat (dyn_sts,"MLSLABEL, 6, -1) IMAGE_INDEX n"); strcat (dyn_sts,"FROM (select * from SYS.ALL_TAB_COLUMNS n"); if ( (strlen (opcion_uno) > 0) && (strlen (opcion_dos) == 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } else if ( (strlen(opcion_uno) == 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where table_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else if ( (strlen (opcion_uno) > 0) && ( strlen (opcion_dos) > 0 )) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); strcat (dyn_sts,"and table_name = ");
  • 102. strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } strcat (dyn_sts," ) C, n"); strcat (dyn_sts,"SYS.ALL_IND_COLUMNS I n"); strcat (dyn_sts,"WHERE n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"I.INDEX_OWNER ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," AND "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts,"I.INDEX_NAME ="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," AND "); } strcat (dyn_sts,"C.OWNER (+) = I.INDEX_OWNER AND C.TABLE_NAME (+) = I.TABLE_NAME "); strcat (dyn_sts,"AND C.COLUMN_NAME (+) = I.COLUMN_NAME n"); strcat (dyn_sts,"ORDER BY I.INDEX_OWNER,I.INDEX_NAME,I.COLUMN_POSITION n"); break; case CASE_AUDIT_DEFINITION: strcpy (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, AUDIT_OPTION, "); strcat (dyn_sts,"decode ( substr(SUCCESS,1,1), -, null, S,"); strcat (dyn_sts,"BY SESSION, A, BY ACCESS, substr(SUCCESS,1,1)) "); strcat (dyn_sts,"WHENEVER_SUCCESSFUL, decode( substr (SUCCESS,3,1),"); strcat (dyn_sts,"-, null, S, BY SESSION, A, BY ACCESS, "); strcat (dyn_sts,"substr(SUCCESS,3,1)) WHENEVER_UNSUCCESSFUL n"); strcat (dyn_sts,"FROM n"); strcat (dyn_sts,"(SELECT OBJECT_NAME, OBJECT_TYPE, "); strcat (dyn_sts,"ALTER AUDIT_OPTION,ALT SUCCESS "); strcat (dyn_sts,"FROM sys.DBA_OBJ_AUDIT_OPTS n");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); }
  • 103. if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, AUDIT, AUD "); strcat (dyn_sts,"FROM sys.DBA_OBJ_AUDIT_OPTS n");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */
  • 104. /* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, COMMENT, COM "); strcat (dyn_sts,"FROM sys.DBA_OBJ_AUDIT_OPTS n");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, DELETE, DEL "); strcat (dyn_sts,"FROM sys.DBA_OBJ_AUDIT_OPTS n");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," ");
  • 105. } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, GRANT, GRA "); strcat (dyn_sts,"FROM sys.DBA_OBJ_AUDIT_OPTS n");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }
  • 106. /* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts," OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, INDEX, IND FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts," WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, INSERT, INS FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); }
  • 107. if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, LOCK, LOC FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n");
  • 108. strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, RENAME, REN FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts," WHERE OWNER =:OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, SELECT, SEL FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) {
  • 109. strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, UPDATE, UPD FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");
  • 110. */ strcat (dyn_sts," UNION n"); strcat (dyn_sts,"SELECT OBJECT_NAME, OBJECT_TYPE, REFERENCES, REF FROM sys.DBA_OBJ_AUDIT_OPTS ");/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," and object_name ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," and object_type="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); }/* -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *//* strcat (dyn_sts,"WHERE OWNER = :OWNER AND n"); strcat (dyn_sts,"OBJECT_NAME = :TABLE_NAME AND n"); strcat (dyn_sts,"OBJECT_TYPE = :OBJECT_TYPE n");*/ strcat (dyn_sts,") n"); break; case CASE_SHOW_SEGMENTS_EXTENTS: strcpy (dyn_sts,"SELECT S.OWNER, S.SEGMENT_NAME, S.SEGMENT_TYPE, S.TABLESPACE_NAME, "); strcat (dyn_sts,"S.BYTES/1024 KBYTES, S.BLOCKS, S.EXTENTS, S.NEXT_EXTENT/1024 NEXT_EXTENT , "); strcat (dyn_sts,"S.PCT_INCREASE, S.MAX_EXTENTS, S.MAX_EXTENTS - S.EXTENTS FREE_EXTENTS, "); strcat (dyn_sts,"DECODE( SEGMENT_TYPE, CACHE, 14, CLUSTER, 15, INDEX, 17, "); strcat (dyn_sts,"ROLLBACK, 13, TABLE , 0, TABLE PARTITION, 38, INDEX PARTITION, 39, -1) IMAGE_INDEX n"); strcat (dyn_sts,"FROM SYS.DBA_SEGMENTS S n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where TABLESPACE_NAME ="); strcat (dyn_sts,opcion_uno);
  • 111. strcat (dyn_sts," AND "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," OWNER ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," AND "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," SEGMENT_TYPE="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); } strcat (dyn_sts,"ORDER BY S.OWNER, FREE_EXTENTS n"); break;case CASE_SHOW_EXTENTS_INSIDE_DATAFILES: strcpy (dyn_sts,"SELECT TO_CHAR(X.EXTENT_ID) EXTENT_ID, X.OWNER, "); strcat (dyn_sts,"X.SEGMENT_NAME, X.SEGMENT_TYPE, X.TABLESPACE_NAME, "); strcat (dyn_sts,"X.FILE_ID, X.BLOCK_ID, X.BYTES/1024 KBYTES, X.BLOCKS, "); strcat (dyn_sts,"F.FILE_NAME n"); strcat (dyn_sts,"FROM SYS.DBA_EXTENTS X, SYS.DBA_DATA_FILES F n"); strcat (dyn_sts,"WHERE n"); strcat (dyn_sts,"F.TABLESPACE_NAME = X.TABLESPACE_NAME AND n"); strcat (dyn_sts,"F.FILE_ID = X.FILE_ID n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND TABLESPACE_NAME ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts," AND OWNER ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," "); } if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts," AND SEGMENT_NAME=");
  • 112. strcat (dyn_sts,opcion_tres); strcat (dyn_sts," n"); } strcat (dyn_sts,"ORDER BY 1 n"); break;case CASE_SHOW_USER_LISTS: strcpy (dyn_sts,"SELECT u.USERNAME, u.USER_ID, u.DEFAULT_TABLESPACE, n"); strcat (dyn_sts,"u.password, u.TEMPORARY_TABLESPACE, u.CREATED, u.PROFILE, "); strcat (dyn_sts,"N/A ACCOUNT_STATUS, to_date(null) LOCK_DATE, "); strcat (dyn_sts,"to_date(null) EXPIRY_DATE, null INITIAL_RSRC_CONSUMER_GROUP, "); strcat (dyn_sts,"p.SYSDBA, p.SYSOPER n"); strcat (dyn_sts,"FROM SYS.DBA_USERS u, SYS.V_$PWFILE_USERS p n"); strcat (dyn_sts,"WHERE u.USERNAME = p.USERNAME (+) n"); strcat (dyn_sts,"UNION n"); strcat (dyn_sts,"SELECT PUBLIC USERNAME, TO_NUMBER(NULL) USER_ID, "); strcat (dyn_sts,"NULL DEFAULT_TABLESPACE, null password, NULL TEMPORARY_TABLESPACE, "); strcat (dyn_sts,"TO_DATE(NULL) CREATED, NULL PROFILE, LOCKED ACCOUNT_STATUS, "); strcat (dyn_sts,"TO_DATE(NULL) LOCK_DATE, TO_DATE(NULL) EXPIRY_DATE, "); strcat (dyn_sts,"null INITIAL_RSRC_CONSUMER_GROUP, FALSE SYSDBA, FALSE SYSOPER "); strcat (dyn_sts,"FROM DUAL n"); strcat (dyn_sts,"ORDER BY 1 n"); break;case CASE_SHOW_ROLES_PRIVILEGES: strcpy (dyn_sts,"SELECT distinct PRIVILEGE, OWNER, TABLE_NAME, GRANTOR, n"); strcat (dyn_sts,"GRANTEE,GRANTABLE, NO COL_PRIVS "); strcat (dyn_sts,"FROM SYS.DBA_TAB_PRIVS n"); strcat (dyn_sts,"WHERE n"); strcat (dyn_sts," OWNER = :OWNER n"); strcat (dyn_sts," AND TABLE_NAME = :TABLE_NAME n"); strcat (dyn_sts," AND GRANTEE = :GRANTEE n"); strcat (dyn_sts,"UNION "); strcat (dyn_sts, "SELECT DISTINCT PRIVILEGE, OWNER, TABLE_NAME, GRANTOR, n"); strcat (dyn_sts,"GRANTEE,NULL GRANTABLE, YES COL_PRIVS n"); strcat (dyn_sts,"FROM SYS.DBA_COL_PRIVS n"); strcat (dyn_sts,"WHERE n"); strcat (dyn_sts," OWNER = :OWNER n"); strcat (dyn_sts," AND TABLE_NAME = :TABLE_NAME n"); strcat (dyn_sts," AND GRANTEE = :GRANTEE n"); strcat (dyn_sts," ORDER BY 1 n"); break;
  • 113. case CASE_SHOW_PRIVILEGES_COLUMNS: strcpy (dyn_sts,"SELECT P.COLUMN_NAME, P.GRANTOR, P.GRANTEE, P.PRIVILEGE, "); strcat (dyn_sts,"P.GRANTABLE, DATA_TYPE || DECODE( DATA_TYPE,NUMBER, "); strcat (dyn_sts,"DECODE( DATA_PRECISION, NULL, NULL, ( || DATA_PRECISION || "); strcat (dyn_sts,"DECODE( DATA_SCALE, NULL, NULL, , || DATA_SCALE) || )), "); strcat (dyn_sts,"VARCHAR2, ( || DATA_LENGTH || ), CHAR, "); strcat (dyn_sts," ( || DATA_LENGTH || ), NULL) SQL_TYPE, "); strcat (dyn_sts,"DECODE( C.NULLABLE, N, NOT NULL, NULL) NULLABLE, "); strcat (dyn_sts,"DECODE( C.DATA_TYPE, VARCHAR2, 0, CHAR, 0, NUMBER,"); strcat (dyn_sts," 1, DATE, 2, LONG, 3, RAW, 4, LONG RAW,"); strcat (dyn_sts," 5, MLSLABEL, 6, -1) IMAGE_INDEX n"); strcat (dyn_sts,"FROM SYS.ALL_COL_PRIVS P, SYS.ALL_TAB_COLUMNS C n"); strcat (dyn_sts,"WHERE C.COLUMN_NAME = P.COLUMN_NAME n");/* *************************************************************** */ if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND P.TABLE_SCHEMA ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," AND "); strcat (dyn_sts,"AND C.OWNER ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } /* strcat (dyn_sts," AND P.TABLE_SCHEMA = :OWNER n"); strcat (dyn_sts," AND C.OWNER = :OWNER n"); *//* *************************************************************** */ if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts,"AND P.TABLE_NAME ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," AND "); strcat (dyn_sts,"AND C.TABLE_NAME ="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } /* strcat (dyn_sts," AND P.TABLE_NAME = :TABLE_NAME n"); strcat (dyn_sts," AND C.TABLE_NAME = :TABLE_NAME n");
  • 114. */ /* *************************************************************** */ if ( (strlen (opcion_tres) > 0) ) { strcat (dyn_sts,"AND P.PRIVILEGE ="); strcat (dyn_sts,opcion_tres); strcat (dyn_sts," "); } /* strcat (dyn_sts," AND P.PRIVILEGE = :PRIVILEGE n"); */ /* *************************************************************** */ if ( (strlen (opcion_cuatro) > 0) ) { strcat (dyn_sts,"AND P.GRANTEE ="); strcat (dyn_sts,opcion_cuatro); strcat (dyn_sts," "); } /* strcat (dyn_sts," AND P.GRANTEE = :GRANTEE n"); */ /* *************************************************************** */ strcat (dyn_sts," ORDER BY C.COLUMN_ID n"); break; case CASE_SHOW_LOCKS_VIEWS: strcpy (dyn_sts,"select l.id1,decode(l.type, MR, Media Recovery, RT, Redo Thread, UN, User Name, "); strcat (dyn_sts,"TX, Transaction, TM, DML, UL, PL/SQL User Lock, DX, Distributed Xaction, "); strcat (dyn_sts,"CF, Control File, IS, Instance State, FS, File Set, IR, Instance Recovery, "); strcat (dyn_sts,"ST, Disk Space Transaction, TS, Temp Segment, IV, Library Cache Invalidation, "); strcat (dyn_sts,"LS, Log Start or Switch, RW, Row Wait, SQ, Sequence Number, "); strcat (dyn_sts,"TE, Extend Table, TT, Temp Table, l.type) type, "); strcat (dyn_sts,"decode( l.lmode, 2,share update, 3, row exclusive, 4, share, 5, share row exclusive, "); strcat (dyn_sts,"6, exclusive, 0, -, l.lmode) lmode, "); strcat (dyn_sts,"decode( l.request, 0, -, 2, share update, 3, row exclusive, 4, share, "); strcat (dyn_sts,"5, share row exclusive, 6, exclusive, l.request) request , ");/* strcat (dyn_sts,"null object_name, n"); */ strcat (dyn_sts,"o.object_name object_name, n");/* strcat (dyn_sts,"null owner, n"); */ strcat (dyn_sts,"o.owner owner, n");
  • 115. /* strcat (dyn_sts,"null object_type, n"); */ strcat (dyn_sts,"o.object_type object_type, n"); strcat (dyn_sts," -1 image_index , n"); strcat (dyn_sts," nvl(o.object_name, (ID=||to_char(l.id1)||))object_name, o.owner, o.object_type, "); strcat (dyn_sts," DECODE( O.OBJECT_TYPE, TABLE, 0, VIEW, 1, SYNONYM, 2, TRIGGER, "); strcat (dyn_sts,"4, PACKAGE, 5, PACKAGE BODY, 6, PROCEDURE, 7, FUNCTION, 8, INDEX, 17, "); strcat (dyn_sts," SEQUENCE, 18, -1) IMAGE_INDEX n"); strcat (dyn_sts,"from sys.v_$lock l , SYS.all_objects o n"); strcat (dyn_sts,"where l.id1 = o.object_id (+) n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND l.sid ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); }/* strcat (dyn_sts,"and l.sid = :SID n"); */ strcat (dyn_sts,"order by lmode desc, request n"); break; case CASE_GRAPH_LOCK_WAITS: strcpy (dyn_sts,"select l.sid, S.PROGRAM, S.USERNAME, S.TERMINAL n"); strcat (dyn_sts,"from n"); strcat (dyn_sts," (SELECT SID FROM SYS.V_$LOCK WHERE LMODE>1 n"); strcat (dyn_sts," MINUS select SID FROM sys.v_$LOCK WHERE REQUEST>0 ) L, n"); strcat (dyn_sts," SYS.V_$SESSION S n"); strcat (dyn_sts,"WHERE L.SID = S.SID AND S.USERNAME IS NOT NULL n"); break; case CASE_OBJECT_ACCESS_SESSION: strcpy (dyn_sts,"SELECT SID, DECODE( OWNER, USER, NULL, OWNER || . ) || "); strcat (dyn_sts,"OBJECT OBJECT, TYPE OBJ_TYPE n"); strcat (dyn_sts,"FROM SYS.V_$ACCESS n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"WHERE SID="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } strcat (dyn_sts,"ORDER BY 1 n"); break;
  • 116. case CASE_SHOW_LATCHES: strcpy (dyn_sts,"SELECT L.*, N.NAME n"); strcat (dyn_sts,"FROM SYS.V_$LATCH L, n"); strcat (dyn_sts,"SYS.V_$LATCHHOLDER H, n"); strcat (dyn_sts,"SYS.V_$LATCHNAME N n"); strcat (dyn_sts,"WHERE L.ADDR = H.LADDR n"); strcat (dyn_sts," AND N.LATCH# = L.LATCH# n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"AND H.PID="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," n"); } break;case CASE_SHOW_STATISTICS: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_sts,"select id, name, set_msize, cnum_repl, n"); strcat (dyn_sts,"cnum_write, cnum_set, buf_got, sum_write, n"); strcat (dyn_sts,"sum_scan, free_buffer_wait, n"); strcat (dyn_sts,"write_complete_wait, buffer_busy_wait, n"); strcat (dyn_sts,"free_buffer_inspected, dirty_buffers_inspected, n"); strcat (dyn_sts,"db_block_change, db_block_gets, n"); strcat (dyn_sts,"consistent_gets, physical_reads, n"); strcat (dyn_sts,"physical_writes n"); strcat (dyn_sts,"from v$buffer_pool_statistics n"); break; case VERSION_ORACLE_734: strcpy (dyn_sts,"select bannern"); strcat (dyn_sts," from v$version "); break; } break;case CASE_SHOW_TRANSACTIONS: strcpy (dyn_sts,"SELECT s.sid,t.ADDR, t.XIDUSN, t.XIDSLOT, t.XIDSQN, t.UBAFIL, t.UBABLK, "); strcat (dyn_sts,"t.UBASQN,t.UBAREC,t.STATUS,to_date( t.start_time, MM/DD/RR HH24:MI:SS) start_time, "); strcat (dyn_sts,"t.START_SCNB, t.START_SCNW, t.START_UEXT, t.START_UBAFIL,t.START_UBABLK, ");
  • 117. strcat (dyn_sts,"t.START_UBASQN, t.START_UBAREC, t.SES_ADDR, t.FLAG, t.SPACE, t.RECURSIVE, "); strcat (dyn_sts,"t.NOUNDO, t.PRV_XIDUSN, t.PRV_XIDSLT, t.PRV_XIDSQN, null PTX, null PTX_XIDUSN, "); strcat (dyn_sts,"null PTX_XIDSLT, null PTX_XIDSQN, null DSCN_B, null DSCN_W, t.USED_UBLK, "); strcat (dyn_sts,"t.USED_UREC, t.LOG_IO, t.PHY_IO, t.CR_GET, t.CR_CHANGE n"); strcat (dyn_sts,"FROM SYS.V_$TRANSACTION T, SYS.V_$SESSION S n"); strcat (dyn_sts,"WHERE S.SADDR = T.SES_ADDR n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts," AND SID="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); } strcat (dyn_sts,"ORDER BY t.start_scnb n"); break;case CASE_SHOW_DATAFILES_STATUS: strcpy (dyn_sts,"SELECT F.FILE_ID, F.TABLESPACE_NAME, "); strcat (dyn_sts,"N/A AUTOEXTENSIBLE, TO_NUMBER(null) MAXBYTES, "); strcat (dyn_sts,"TO_NUMBER(null) NEXT_SIZE, F.BYTES/1024 KBYTES, F.BLOCKS, "); strcat (dyn_sts,"F.STATUS, NVL(MAX(S.BYTES)/1024,0) MAX_CHUNK_SPACE, "); strcat (dyn_sts,"NVL(MIN (S.BYTES)/1024,0) MIN_CHUNK_SPACE, NVL(SUM(S.BYTES)/1024, 0) FREE_SPACE, "); strcat (dyn_sts,"NVL(COUNT(S.BYTES),0) FRAGMENTS, 100*(F.BYTES-NVL(SUM(S.BYTES),0))/F.BYTES USAGE_PCT, "); strcat (dyn_sts,"B.STATUS BACKUP_STATUS, B.CHANGE# BACKUP_CHANGE#, B.TIME BACKUP_TIME, n"); strcat (dyn_sts,"F.FILE_NAME n"); strcat (dyn_sts,"FROM SYS.DBA_DATA_FILES F, SYS.DBA_FREE_SPACE S, n"); strcat (dyn_sts,"SYS.V_$BACKUP B n"); strcat (dyn_sts,"WHERE F.TABLESPACE_NAME = S.TABLESPACE_NAME (+) AND n"); strcat (dyn_sts,"F.FILE_ID = S.FILE_ID (+) AND F.FILE_ID = B.FILE# n"); strcat (dyn_sts,"GROUP BY F.FILE_NAME, F.FILE_ID , F.TABLESPACE_NAME, n"); strcat (dyn_sts,"F.BYTES, F.BLOCKS, F.STATUS, N/A, TO_NUMBER(null), n"); strcat (dyn_sts,"TO_NUMBER(null), B.STATUS, B.CHANGE#, B.TIME n"); strcat (dyn_sts,"ORDER BY F.FILE_NAME n"); break;case CASE_SHOW_DB_OBJECT_CACHE: strcpy (dyn_sts,"select owner, namespace, loads, executions, locks, pins, kept, "); strcat (dyn_sts,"sum(sharable_mem), name n"); strcat (dyn_sts," from v$db_object_cache n"); strcat (dyn_sts," group by owner, name, namespace, loads, "); strcat (dyn_sts," executions, locks, pins, kept n"); strcat (dyn_sts," order by sum(sharable_mem) desc n"); break;
  • 118. case CASE_TABLE_ALERT_EXTENT_USED: strcpy (dyn_sts,"select t1.owner,t1.segment_name,t1.segment_type, n"); strcat (dyn_sts,"t2.min_extents, t2.max_extents, count(*), n"); strcat (dyn_sts,"to_char(100*count(*)/t2.max_extents,99.99) n"); strcat (dyn_sts,"from dba_extents t1, dba_segments t2 n"); strcat (dyn_sts,"where t1.segment_type=TABLE n"); strcat (dyn_sts,"and t1.owner = t2.owner n"); strcat (dyn_sts,"and t1.segment_type = t2.segment_type n"); strcat (dyn_sts,"and t1.segment_name = t2.segment_name n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and t1.owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); } if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts,"and t1.segment_name="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } strcat (dyn_sts,"group by t1.owner,t1.segment_name,t1.segment_type, "); strcat (dyn_sts,"t2.min_extents, t2.max_extents n"); strcat (dyn_sts,"order by 7 desc n"); break;case CASE_INDEX_ALERT_EXTENT_USED: strcpy (dyn_sts,"select t1.owner,t1.segment_name,t1.segment_type, n"); strcat (dyn_sts,"t2.min_extents, t2.max_extents, count(*), n"); strcat (dyn_sts,"to_char(100*count(*)/t2.max_extents,99.99) n"); strcat (dyn_sts,"from dba_extents t1, dba_segments t2 n"); strcat (dyn_sts,"where t1.segment_type=INDEX n"); strcat (dyn_sts,"and t1.owner = t2.owner n"); strcat (dyn_sts,"and t1.segment_type = t2.segment_type n"); strcat (dyn_sts,"and t1.segment_name = t2.segment_name n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and t1.owner="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); }
  • 119. if ( (strlen (opcion_dos) > 0) ) { strcat (dyn_sts,"and t1.segment_name="); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } strcat (dyn_sts,"group by t1.owner,t1.segment_name,t1.segment_type, "); strcat (dyn_sts,"t2.min_extents, t2.max_extents n"); strcat (dyn_sts,"order by 7 desc n"); break;case CASE_USER_TIME_WORKING: strcpy (dyn_sts,"select vse.osuser, vse.username usernm, vse.status status, n"); strcat (dyn_sts,"@$SCR/killer ||rpad(vse.sid||,||vse.serial#,9) kill, n"); strcat (dyn_sts,"spid UNIX, nvl(substr(vse.module,1,60),substr(vse.program,1,60)) vtext, n"); strcat (dyn_sts,"to_char(to_number(sysdate - vse.logon_time)*24*60, 99999.99) minutos, n"); strcat (dyn_sts,"to_char(vse.logon_time,dd-mon hh24:mm) logon n"); strcat (dyn_sts,"from v$session vse, v$process vps n"); strcat (dyn_sts,"where vse.PADDR = vps.ADDR n"); strcat (dyn_sts,"order by vtext, minutos desc n"); break;case CASE_IS_USER_WORKING: strcpy (dyn_sts,"select vse.osuser, vse.username usernm, vse.status status, n"); strcat (dyn_sts,"@$SCR/killer ||rpad(vse.sid||,||vse.serial#,9) kill, n"); strcat (dyn_sts,"spid UNIX, nvl(substr(vse.module,1,60),substr(vse.program,1,60)) vtext, n"); strcat (dyn_sts,"sum(vsa.disk_reads) reads, sum(vsa.buffer_gets) gets , n"); strcat (dyn_sts,"to_char(to_number(sysdate - vse.logon_time)*24*60, 99999.99) minutos, n"); strcat (dyn_sts,"to_char(vse.logon_time,dd-mon hh24:mm) logon n"); strcat (dyn_sts,"from v$session vse, v$sqlarea vsa, v$process vps n"); strcat (dyn_sts,"where vse.sql_address=vsa.address and n"); strcat (dyn_sts,"vse.sql_hash_value=vsa.hash_value and n"); strcat (dyn_sts,"vse.username is not null and vse.PADDR = vps.ADDR n"); strcat (dyn_sts,"group by vse.osuser, vse.username, vse.status, n"); strcat (dyn_sts,"vse.sid, vse.serial#, vps.spid, n"); strcat (dyn_sts,"nvl(substr(vse.module,1,60),substr(vse.program,1,60)) , n"); strcat (dyn_sts,"vsa.disk_reads, vsa.buffer_gets, vse.logon_time n"); strcat (dyn_sts,"order by minutos desc n"); break;case CASE_VER_SQL_PROGRAM: strcpy (dyn_sts,"select vps.pid, vps.spid,vse.sid,vse.status, vse.osuser,vse.username usernm, n"); strcat (dyn_sts,"vse.terminal, vse.machine, n");
  • 120. strcat (dyn_sts,"@$SCR/killer ||rpad(vse.sid||,||vse.serial#,9) kill, n"); strcat (dyn_sts,"nvl(substr(vse.module,1,60),substr(vse.program,1,60)) vtext, n"); strcat (dyn_sts,"to_char(to_number(sysdate - vse.logon_time)*24*60, 99999.99) minutos n"); strcat (dyn_sts,"from v$session vse, v$process vps n"); strcat (dyn_sts,"where vse.PADDR = vps.ADDR n"); strcat (dyn_sts,"and ( n"); strcat (dyn_sts," ( UPPER ( nvl(substr(vse.module,1,60),substr(vse.program,1,60))) like SQL*PLUS% ) or n"); strcat (dyn_sts," ( UPPER ( nvl(substr(vse.module,1,60),substr(vse.program,1,60))) like %PLUS% ) or n"); strcat (dyn_sts," ( UPPER ( nvl(substr(vse.module,1,60),substr(vse.program,1,60))) like %T.O.A.D% ) or n"); strcat (dyn_sts," ( UPPER ( nvl(substr(vse.module,1,60),substr(vse.program,1,60))) like %SQLNAV% ) or n"); strcat (dyn_sts," ( UPPER ( nvl(substr(vse.module,1,60),substr(vse.program,1,60))) like %SQL% ) ) n"); strcat (dyn_sts," order by minutos desc n"); break;case CASE_SQL_SESS_IO: strcpy (dyn_sts,"select s.sid, s.username, s.terminal, s.machine, n"); strcat (dyn_sts,"i.block_gets, i.consistent_gets, i.physical_reads, n"); strcat (dyn_sts,"i.block_changes, i.consistent_changes n"); strcat (dyn_sts,"from v$session s, v$sess_io i n"); strcat (dyn_sts,"where s.sid = i.sid n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and s.sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); } strcat (dyn_sts,"order by i.block_gets, i.physical_reads n"); break;case CASE_SQL_SESSION_EVENT: strcpy (dyn_sts,"select s.sid, s.username, s.terminal, s.machine, n"); strcat (dyn_sts,"e.event, e.total_waits, e.total_timeouts, n"); strcat (dyn_sts,"e.time_waited, e.average_wait, e.max_wait n"); strcat (dyn_sts,"from v$session s, v$session_event e n"); strcat (dyn_sts,"where s.sid = e.sid n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and s.sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); } strcat (dyn_sts,"order by s.sid, e.total_waits, e.average_wait n");
  • 121. break;case CASE_SQL_SESSION_WAIT: strcpy (dyn_sts,"select s.sid,s.username,s.terminal,s.machine, n"); strcat (dyn_sts,"w.seq#,w.event,w.p1text,w.p1, w.p1raw, w.p2text, n"); strcat (dyn_sts,"w.p2,w.p2raw, w.p3text, w.p3, w.p3raw, w.wait_time, n"); strcat (dyn_sts,"w.seconds_in_wait, w.state n"); strcat (dyn_sts,"from v$session s, v$session_wait w n"); strcat (dyn_sts,"where s.sid = w.sid n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and s.sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); } break;case CASE_SQL_SESSION_LONG_OPER: strcpy (dyn_sts,"select s.SID, s.USERNAME, s.TERMINAL, s.MACHINE, n"); strcat (dyn_sts,"sl.SERIAL#, sl.OPNAME, sl.TARGET, n"); strcat (dyn_sts,"sl.TARGET_DESC, sl.SOFAR, sl.TOTALWORK, sl.UNITS, n"); strcat (dyn_sts,"to_char(sl.start_time,DD/MM/YYYY - HH24:MI:SS), n"); strcat (dyn_sts,"to_char(sl.last_update_time,DD/MM/YYYY - HH24:MI:SS), n"); strcat (dyn_sts,"sl.time_remaining, n"); strcat (dyn_sts,"sl.ELAPSED_SECONDS, n"); strcat (dyn_sts,"sl.CONTEXT, sl.MESSAGE, sl.USERNAME, sl.SQL_ADDRESS, n"); strcat (dyn_sts,"sl.SQL_HASH_VALUE, sl.QCSID n"); strcat (dyn_sts,"from v$session_longops sl, v$session sn"); strcat (dyn_sts,"where sl.sid = s.sid n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"and s.sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,"n "); } break;case CASE_SQL_LOCKED_OBJECTS: strcpy (dyn_sts,"select XIDUSN,XIDSLOT,XIDSQN,OBJECT_ID, n"); strcat (dyn_sts,"SESSION_ID,ORACLE_USERNAME,OS_USER_NAME, n"); strcat (dyn_sts,"PROCESS,LOCKED_MODE n"); strcat (dyn_sts,"from v$locked_object n"); break;
  • 122. case CASE_SQL_TRANSACTION_DETAIL: strcpy (dyn_sts,"select addr,xidusn,xidslot,xidsqn,ubafil, n"); strcat (dyn_sts,"ubablk,ubasqn,ubarec,start_ubafil,start_ubablk, n"); strcat (dyn_sts,"start_ubasqn,start_ubarec,log_io, phy_io n"); strcat (dyn_sts,"from v$transaction n"); break;case CASE_SQL_LOCK_MEDIUM_INFO: strcpy (dyn_sts,"select s.saddr,l.sid, s.serial#, s.username, s.terminal, n"); strcat (dyn_sts,"decode(l.type,RW,RW - Row Wait Enqueue,TM,TM - DML Enqueue, n"); strcat (dyn_sts,"TX,TX - Trans Enqueue,UL,UL - User,l.type||System) res, n"); strcat (dyn_sts,"t.name tab, u.name owner, l.id1, l.id2, decode(l.lmode, n"); strcat (dyn_sts,"1,No Lock,2,Row Share,3,Row Exclusive,4,Share,5,Shr Row Excl, n"); strcat (dyn_sts,"6,Exclusive,NONE) lmode,decode(l.request,1,No Lock,2,Row Share, n"); strcat (dyn_sts,"3,Row Excl,4,Share,5,Shr Row Excl,6,Exclusive,NONE) request n"); strcat (dyn_sts,"from v$lock l, v$session s, sys.user$ u, sys.obj$ t n"); strcat (dyn_sts,"where l.sid = s.sid and s.type != BACKGROUND and n"); strcat (dyn_sts,"t.obj# = l.id1 and u.user# = t.owner# n"); break;case CASE_SQL_LOCK_FULL_INFO: strcpy (dyn_sts,"select nvl(S.USERNAME,Internal) username,L.SID, nvl(S.TERMINAL,None) terminal,n"); strcat (dyn_sts,"decode(command,0,None,decode(l.id2,0,U1.NAME||.||substr(T1.NAME,1,35),None)) tab,n"); strcat (dyn_sts,"decode(command,0,BACKGROUND,1,Create Table,2,INSERT,3,SELECT, n"); strcat (dyn_sts,"4,CREATE CLUSTER,5,ALTER CLUSTER,6,UPDATE,7,DELETE,8,DROP, n"); strcat (dyn_sts,"9,CREATE INDEX,10,DROP INDEX,11,ALTER INDEX,12,DROP TABLE, n"); strcat (dyn_sts,"13,CREATE SEQUENCE,14,ALTER SEQUENCE,15,ALTER TABLE, n"); strcat (dyn_sts,"16,DROP SEQUENCE,17,GRANT,18,REVOKE,19,CREATE SYNONYM, n"); strcat (dyn_sts,"20,DROP SYNONYM,21,CREATE VIEW,22,DROP VIEW,23,VALIDATE INDEX, n"); strcat (dyn_sts,"24,CREATE PROCEDURE,25,ALTER PROCEDURE,26,LOCK TABLE, n"); strcat (dyn_sts,"27,NO OPERATION,28,RENAME,29,COMMENT,30,AUDIT,31,NOAUDIT, n"); strcat (dyn_sts,"32,CREATE EXTERNAL DATABASE,33,DROP EXTERNAL DATABASE, n"); strcat (dyn_sts,"34,CREATE DATABASE,35,ALTER DATABASE,36,CREATE ROLLBACK SEGMENT,n"); strcat (dyn_sts,"37,ALTER ROLLBACK SEGMENT,38,DROP ROLLBACK SEGMENT,39,CREATE TABLESPACE, n"); strcat (dyn_sts,"40,ALTER TABLESPACE,41,DROP TABLESPACE,42,ALTER SESSION,43,ALTER USER, n"); strcat (dyn_sts,"44,COMMIT,45,ROLLBACK,46,SAVEPOINT,47,PL/SQL EXECUTE,48,SET TRANSACTION, n"); strcat (dyn_sts,"49,ALTER SYSTEM SWITCH LOG,50,EXPLAIN,51,CREATE USER,52,CREATE ROLE, n"); strcat (dyn_sts,"53,DROP USER,54,DROP ROLE,55,SET ROLE,56,CREATE SCHEMA,57,CREATE CONTROL FILE, n"); strcat (dyn_sts,"58,ALTER TRACING,59,CREATE TRIGGER,60,ALTER TRIGGER,61,DROP TRIGGER,n"); strcat (dyn_sts,"62,ANALYZE TABLE,63,ANALYZE INDEX,64,ANALYZE CLUSTER,65,CREATE PROFILE, n"); strcat (dyn_sts,"66,DROP PROFILE,67,ALTER PROFILE,68,DROP PROCEDURE,69,DROP PROCEDURE, n"); strcat (dyn_sts,"70,ALTER RESOURCE COST,71,CREATE SNAPSHOT LOG,72,ALTER SNAPSHOT LOG, n");
  • 123. strcat (dyn_sts,"73,DROP SNAPSHOT LOG,74,CREATE SNAPSHOT,75,ALTER SNAPSHOT,76,DROP SNAPSHOT, n"); strcat (dyn_sts,"79,ALTER ROLE,85,TRUNCATE TABLE,86,TRUNCATE CLUSTER,87,-,88,ALTER VIEW,n"); strcat (dyn_sts,"89,-,90,-,91,CREATE FUNCTION,92,ALTER FUNCTION,93,DROP FUNCTION,94,CREATE PACKAGE, n"); strcat (dyn_sts,"95,ALTER PACKAGE,96,DROP PACKAGE,97,CREATE PACKAGE BODY,98,ALTER PACKAGE BODY, n"); strcat (dyn_sts,"99,DROP PACKAGE BODY,command|| - ???) COMMAND, decode(L.LMODE,1,No Lock, n"); strcat (dyn_sts," 2,Row Share,3,Row Exclusive,4,Share,5,Share Row Exclusive,6,Exclusive,NONE) lmode, n"); strcat (dyn_sts," decode(L.REQUEST,1,No Lock,2,Row Share,3,Row Exclusive,4,Share,5,Share Row Exclusive, n"); strcat (dyn_sts,"6,Exclusive,NONE) request,l.id1||-||l.id2 Laddr,l.type|| - ||decode(l.type,BL,Buffer hash tableinstance lock, n"); strcat (dyn_sts,"CF, Control file schema global enqueue lock,CI,Cross-instance function invocation instance lock,n"); strcat (dyn_sts,"CS,Control file schema global enqueue lock,CU,Cursor bind lock,DF,Data file instance lock, n"); strcat (dyn_sts,"DL,Direct loader parallel index create,DM,Mount/startup db primary/secondary instance lock, n"); strcat (dyn_sts,"DR,Distributed recovery process lock,DX,Distributed transaction entry lock,FI,SGA open-fileinformation lock, n"); strcat (dyn_sts,"FS,File set lock,HW,Space management operations on a specific segment lock,IN,Instance numberlock, n"); strcat (dyn_sts,"IR,Instance recovery serialization global enqueue lock,IS,Instance state lock,IV,Library cacheinvalidation instance lock, n"); strcat (dyn_sts,"JQ,Job queue lock,KK,Thread kick lock,MB,Master buffer hash table instance lock,MM,Mountdefinition gloabal enqueue lock, n"); strcat (dyn_sts,"MR,Media recovery lock,PF,Password file lock,PI,Parallel operation lock,PR,Process startuplock, n"); strcat (dyn_sts,"PS,Parallel operation lock,RE,USE_ROW_ENQUEUE enforcement lock,RT,Redo thread global enqueuelock, n"); strcat (dyn_sts,"RW,Row wait enqueue lock,SC,System commit number instance lock,SH,System commit number high watermark enqueue lock, n"); strcat (dyn_sts,"SM,SMON lock,SN,Sequence number instance lock,SQ,Sequence number enqueue lock,SS,Sort segmentlock, n"); strcat (dyn_sts,"ST,Space transaction enqueue lock,SV,Sequence number value lock,TA,Generic enqueue lock,TD,DDLenqueue lock, n"); strcat (dyn_sts,"TE,Extend-segment enqueue lock,TM,DML enqueue lock,TT,Temporary table enqueuelock,TX,Transaction enqueue lock, n"); strcat (dyn_sts,"UL,User supplied lock,UN,User name lock,US,Undo segment DDL lock,WL,Being-written redo loginstance lock, n"); strcat (dyn_sts,"WS,Write-atomic-log-switch global enqueue lock,TS,decode(l.id2,0,Temporary segment enqueue lock (ID2=0),"); strcat (dyn_sts,"New block allocation enqueue lock (ID2=1)),LA,Library cache lock instance lock (A=namespace), n"); strcat (dyn_sts,"LB,Library cache lock instance lock (B=namespace),LC,Library cache lock instance lock (C=namespace),n");
  • 124. strcat (dyn_sts,"LD,Library cache lock instance lock (D=namespace),LE,Library cache lock instance lock (E=namespace),n"); strcat (dyn_sts,"LF,Library cache lock instance lock (F=namespace),LG,Library cache lock instance lock (G=namespace),n"); strcat (dyn_sts,"LH,Library cache lock instance lock (H=namespace),LI,Library cache lock instance lock (I=namespace),n"); strcat (dyn_sts,"LJ,Library cache lock instance lock (J=namespace),LK,Library cache lock instance lock (K=namespace),n"); strcat (dyn_sts,"LL,Library cache lock instance lock (L=namespace),LM,Library cache lock instance lock (M=namespace),n"); strcat (dyn_sts,"LN,Library cache lock instance lock (N=namespace),LO,Library cache lock instance lock (O=namespace),n"); strcat (dyn_sts,"LP,Library cache lock instance lock (P=namespace),LS,Log start/log switch enqueue lock,PA,Librarycache pin instance lock (A=namespace), n"); strcat (dyn_sts,"PB,Library cache pin instance lock (B=namespace),PC,Library cache pin instance lock (C=namespace),n"); strcat (dyn_sts,"PD,Library cache pin instance lock (D=namespace),PE,Library cache pin instance lock (E=namespace),n"); strcat (dyn_sts,"PF,Library cache pin instance lock (F=namespace),PG,Library cache pin instance lock (G=namespace),n"); strcat (dyn_sts,"PH,Library cache pin instance lock (H=namespace),PI,Library cache pin instance lock (I=namespace),n"); strcat (dyn_sts,"PJ,Library cache pin instance lock (J=namespace),PL,Library cache pin instance lock (K=namespace),n"); strcat (dyn_sts,"PK,Library cache pin instance lock (L=namespace),PM,Library cache pin instance lock (M=namespace),n"); strcat (dyn_sts,"PN,Library cache pin instance lock (N=namespace),PO,Library cache pin instance lock (O=namespace),n"); strcat (dyn_sts,"PP,Library cache pin instance lock (P=namespace),PQ,Library cache pin instance lock (Q=namespace),n"); strcat (dyn_sts,"PR,Library cache pin instance lock (R=namespace),PS,Library cache pin instance lock (S=namespace),n"); strcat (dyn_sts,"PT,Library cache pin instance lock (T=namespace),PU,Library cache pin instance lock (U=namespace),n"); strcat (dyn_sts,"PV,Library cache pin instance lock (V=namespace),PW,Library cache pin instance lock (W=namespace),n"); strcat (dyn_sts,"PX,Library cache pin instance lock (X=namespace),PY,Library cache pin instance lock (Y=namespace),n"); strcat (dyn_sts,"PZ,Library cache pin instance lock (Z=namespace),QA,Row cache instance lock (A=cache), n"); strcat (dyn_sts,"QB,Row cache instance lock (B=cache),QC,Row cache instance lock (C=cache),QD,Row cache instance
  • 125. lock (D=cache), n"); strcat (dyn_sts,"QE,Row cache instance lock (E=cache),QF,Row cache instance lock (F=cache),QG,Row cache instancelock (G=cache),n"); strcat (dyn_sts,"QH,Row cache instance lock (H=cache),QI,Row cache instance lock (I=cache),QJ,Row cache instancelock (J=cache), n"); strcat (dyn_sts,"QL,Row cache instance lock (K=cache),QK,Row cache instance lock (L=cache),QM,Row cache instancelock (M=cache), n"); strcat (dyn_sts,"QN,Row cache instance lock (N=cache),QO,Row cache instance lock (O=cache),QP,Row cache instancelock (P=cache),n"); strcat (dyn_sts,"QQ,Row cache instance lock (Q=cache),QR,Row cache instance lock (R=cache),QS,Row cache instancelock (S=cache), n"); strcat (dyn_sts,"QT,Row cache instance lock (T=cache),QU,Row cache instance lock (U=cache),QV,Row cache instancelock (V=cache), n"); strcat (dyn_sts,"QW,Row cache instance lock (W=cache),QX,Row cache instance lock (X=cache),QY,Row cache instancelock (Y=cache), n"); strcat (dyn_sts,"QZ,Row cache instance lock (Z=cache),????) Lockt 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 n"); strcat (dyn_sts,"and T1.OBJ# = decode(L.ID2,0,L.ID1,1) n"); strcat (dyn_sts,"and U1.USER# = T1.OWNER# and S.TYPE != BACKGROUND n"); strcat (dyn_sts,"order by 1,2,5 n"); break; case CASE_SQL_LOCK_BY_SESSION_ID: strcat (dyn_sts,"SELECT p.username,p.pid,p.spid,s.username ora,DECODE(l2.type, n"); strcat (dyn_sts,"TX,TRANSACTION ROW-LEVEL,TS,TEMPORARY SEGMENT , n"); strcat (dyn_sts,"TD,TABLE LOCK,TM,ROW LOCK,l2.type ) vlock, n"); strcat (dyn_sts,"DECODE(l2.type,TX,DML LOCK,TS,TEMPORARY SEGMENT, n"); strcat (dyn_sts,"TD,DECODE(l2.lmode+l2.request,4,n"); strcat (dyn_sts,"PARSE ||u.name||.||o.name,6,DDL, l2.lmode+l2.request), n"); strcat (dyn_sts,"TM,DML ||u.name||.||o.name,l2.type ) type, n"); strcat (dyn_sts,"DECODE(l2.lmode+l2.request,2,RS,3,RX,4,S,5,SRX,6,X,l2.lmode+l2.request) lmode, n"); strcat (dyn_sts,"DECODE(l2.request,0,NULL,WAIT) wait n"); strcat (dyn_sts,"FROM v$process p, v$_lock l1, v$lock l2, v$resource r, n"); strcat (dyn_sts,"sys.obj$ o, sys.user$ u, v$session s n"); strcat (dyn_sts,"WHERE s.paddr=p.addr AND s.saddr = l1.saddr n"); strcat (dyn_sts,"AND l1.raddr = r.addr AND l2.addr = l1.laddr n"); strcat (dyn_sts,"AND l2.type <> MR AND l2.type <> RT n"); strcat (dyn_sts,"AND r.id1 = o.obj# (+) AND o.owner# = u.user# (+) n"); if ( (strlen (opcion_uno) > 0) ) {
  • 126. strcat (dyn_sts,"and p.username LIKE NVL ("); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,",%) n "); } strcat (dyn_sts,"AND p.username LIKE NVL(&&us_,%) n"); strcat (dyn_sts,"ORDER BY 1, 2, 3, 4, 5 n"); break;case CASE_SQL_WHO_IS_WAITING_FOR: strcpy (dyn_sts,"SELECT substr(s1.username,1,12) , n"); strcat (dyn_sts,"substr(s1.osuser,1,8) ,substr(to_char(w.session_id),1,5) , n"); strcat (dyn_sts,"P1.spid , substr(s2.username,1,12), n"); strcat (dyn_sts,"substr(s2.osuser,1,8) ,substr(to_char(h.session_id),1,5) , n"); strcat (dyn_sts,"P2.spid n"); strcat (dyn_sts,"FROM v$process P1, n"); strcat (dyn_sts,"v$process P2, n"); strcat (dyn_sts,"v$session S1, n"); strcat (dyn_sts,"v$session S2, n"); strcat (dyn_sts,"dba_locks w, n"); strcat (dyn_sts,"dba_locks h n"); strcat (dyn_sts,"WHERE (((h.mode_held != None) and (h.mode_held != Null) n"); strcat (dyn_sts,"and ((h.mode_requested = None) or (h.mode_requested = Null))) n"); strcat (dyn_sts,"and (((w.mode_held = None) or (w.mode_held = Null)) n"); strcat (dyn_sts,"and ((w.mode_requested != None) and (w.mode_requested != Null)))) n"); strcat (dyn_sts,"and w.lock_type = h.lock_type and w.lock_id1 = h.lock_id1 n"); strcat (dyn_sts,"and w.lock_id2 = h.lock_id2 and w.session_id != h.session_id n"); strcat (dyn_sts,"and w.session_id = S1.sid and h.session_id = S2.sid AND n"); strcat (dyn_sts,"S1.paddr = P1.addr AND S2.paddr = P2.addr n"); break;case CASE_SQL_WHICH_SQL_RUNNING: strcpy (dyn_sts,"SELECT s.sid, s.username, s.osuser, n"); strcat (dyn_sts,"nvl(s.machine, ?) machine, nvl(s.program, ?) program, n"); strcat (dyn_sts,"s.process F_Ground, p.spid B_Ground, X.sql_text n"); strcat (dyn_sts,"FROM n"); strcat (dyn_sts,"sys.v_$session S, n"); strcat (dyn_sts,"sys.v_$process P, n"); strcat (dyn_sts,"sys.v_$sqlarea X n"); strcat (dyn_sts,"WHERE s.osuser like lower(nvl(&OS_User,%)) AND n"); strcat (dyn_sts,"s.username like upper(nvl(&Oracle_User,%)) AND n"); strcat (dyn_sts,"s.sid like nvl(&SID,%) AND s.paddr = p.addr AND n"); strcat (dyn_sts,"s.type != BACKGROUNDAND s.sql_address = x.address AND n");
  • 127. strcat (dyn_sts,"s.sql_hash_value = x.hash_value n"); strcat (dyn_sts,"ORDER BY S.sid n"); break; case CASE_WHICH_OBJECTS_LOCKED_BY_USER: strcpy (dyn_sts,"select ADDR, INDX, INST_ID, KGLLKADR, KGLLKUSE, n"); strcat (dyn_sts,"KGLLKSES, KGLLKSNM, KGLLKHDL, KGLLKPNC, KGLLKPNS, n"); strcat (dyn_sts,"KGLLKCNT, KGLLKMOD, KGLLKREQ, KGLLKFLG, KGLLKSPN, n"); strcat (dyn_sts,"KGLLKHTB, KGLNAHSH, KGLHDPAR, KGLHDNSP, USER_NAME, n"); strcat (dyn_sts,"KGLNAOBJ n"); strcat (dyn_sts,"from X$KGLLK n"); if ( (strlen (opcion_uno) > 0) ) { strcat (dyn_sts,"where kgllkses in (select saddr n"); strcat (dyn_sts,"from v$session where sid ="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," ) n "); } strcat (dyn_sts,"order by KGLLKSES n"); break;/* ------------------------------------------------- *//************* Agregado 25-Agosto-2005 ***************/ case CASE_BUFFER_CACHE_DEFINED: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_sts,"select id, name, block_size, current_size, n"); strcat (dyn_sts,"buffers n"); strcat (dyn_sts,"from v$buffer_pool n"); break; } break; case CASE_BUFFER_CACHE_TOTAL_SIZE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_sts,"select sum(current_size),sum(buffers) n"); strcat (dyn_sts,"from v$buffer_pool n"); break;
  • 128. } break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_sts,"select 100 * (sum(decode(event,"); strcat (dyn_sts,"db file sequential read,average_wait,0))/"); strcat (dyn_sts,"sum(decode(event,db file scattered read,"); strcat (dyn_sts,"average_wait,0))) n"); strcat (dyn_sts,"from v$system_event n"); strcat (dyn_sts,"where event like db file s% n"); break; } break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE: switch (version) { case VERSION_ORACLE_920: strcpy (dyn_sts," SELECT TO ESTIMAGE BUFFER HIT RATIO "); break; }/* ------------------------------------------------- */ default: strcpy (dyn_sts,"select bannern"); strcat (dyn_sts," from v$version "); break; } return (dyn_sts); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ---
  • 129. --- ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_dyn_title_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();char *func_dyn_title_set (int version, int sentencia ) { static char dyn_title[MAX_VAR_SIZE]; vaciar_cadena (dyn_title,MAX_VAR_SIZE); switch ( sentencia ) { case CASE_ORACLE_VERSION: strcpy (dyn_title,"Oracle Version 0");
  • 130. break;case CASE_ACTIVE_PARAMETERS: strcpy (dyn_title,"Active Parameters 0"); break;case CASE_USERS_CONNECTED: strcpy (dyn_title,"User conected0"); break;case CASE_WAIT_STATISTICS: strcpy (dyn_title,"Wait Statistics0"); break;case CASE_DATAFILE_I_0: strcpy (dyn_title,"Datafile I-O 0"); break;case CASE_DATAFILE_BLOCKS_R_W: strcpy (dyn_title,"Datafile Blocks R+W 0"); break;case CASE_WAIT_EVENTS: strcpy (dyn_title,"Wait Events 0"); break;case CASE_INSTANCE_STATUS: strcpy (dyn_title,"Instance status 0"); break;case CASE_TEMPORAL_SPACE_BY_USER: strcpy (dyn_title,"Temporal Space by user 0"); break;case CASE_TOT_FREELIST_WAIT_PERCENT: strcpy (dyn_title,"Total Freelist Wait Percentage 0"); break;case CASE_LAST_CHECKPOINT_TIME: strcpy (dyn_title,"Last Checkpoint Time 0"); break;case CASE_LIST_TABLESPACES: strcpy (dyn_title,"List Tablespaces 0"); break;case CASE_ACTIVE_TRANSACTIONS: strcpy (dyn_title,"Active Transactions 0"); break;case CASE_LATCH_DETAILS: strcpy (dyn_title,"Latch Details 0"); break;
  • 131. case CASE_RESOURCE_LIMITS: strcpy (dyn_title,"Resource Limits 0"); break;case CASE_LIST_DATAFILES: strcpy (dyn_title,"List Datafiles 0"); break;case CASE_LIST_DATAFILES_NEW_9I: strcpy (dyn_title,"List Datafiles New 9i 0"); break;case CASE_LIST_TABLESPACES_NEW_9I: strcpy (dyn_title,"List Tablespaces New 9i0"); break;case CASE_ACTIVE_SESSIONS: strcpy (dyn_title,"Active Sessions 0"); break;case CASE_SESSIONS_WAITS: strcpy (dyn_title,"Session Waits 0"); break;case CASE_DEFAULT_STORAGE_SETS_TABLESPACE: strcpy (dyn_title,"Default Storage Settings - By Tablespace 0"); break;case CASE_ALL_TABLES_STORAGE_SETTINGS: strcpy (dyn_title,"All tables Storage (Except SYS and SYSTEM) 0"); break;case CASE_ALL_NON_SYS_TABLES_SETTINGS: strcpy (dyn_title,"Non-Sys Tables 0"); break;case CASE_ALL_NON_SYS_INDEXES_SETTINGS: strcpy (dyn_title,"Non-Sys Indexes 0"); break;case CASE_USER_DEFINED: strcpy (dyn_title,"User Defined 0"); break;case CASE_LIST_DATAFILE_REDO_CONTROL_FILES: strcpy (dyn_title,"List Datafiles, Online Redo Logs, Control Files 0"); break;case CASE_LIST_DATAFILES_USED_BLOCKS: strcpy (dyn_title,"List Datafiles and their Used Blocks 0"); break;case CASE_LIST_SORT_BY_USER:
  • 132. strcpy (dyn_title,"List sorts by user 0"); break;case CASE_LIST_LOCK_STATUS: strcpy (dyn_title,"List lock status 0"); break;case CASE_LIST_USER_BY_CPU_USAGE: strcpy (dyn_title,"List Users by CPU Usage 0"); break;case CASE_SQL_STATEMENT_BY_THIS_USER: strcpy (dyn_title,"Sql statement by this user 0"); break;case CASE_REDO_LOGS_STATUS: strcpy (dyn_title,"Redo Logs - Status 0"); break;case CASE_ARCHIVED_LOGS_HISTORY: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_title,"Archived Logs History - by first TimeStamp 0"); break; case VERSION_ORACLE_734: strcpy (dyn_title,"Archived Logs History - by first TimeStamp 0"); break; } break;case CASE_REDO_LOG_RECOVERY_REPORT: strcpy (dyn_title,"Redo Log Recovery Report - CURRENT Online Redo log info 0"); break;case CASE_ARCHIVE_LOG_HISTROY: strcpy (dyn_title,"Archive Log History 0"); break;case CASE_SESSION_LATCH_WAITS_SQL: strcpy (dyn_title,"Session Latch Waits - SQL 0"); break;case CASE_SESSION_PROGRAM_RUNNING_SQL: strcpy (dyn_title,"Session and Program Running - SQL 0"); break;case CASE_PRIVILEGES_BY_USER:
  • 133. strcpy (dyn_title,"Privileges by User 0"); break;case CASE_DETAILED_LOCKING_CAUSES: strcpy (dyn_title,"Detailed locking causes 0"); break;case CASE_CURRENT_STATISTICS_VALUES: strcpy (dyn_title,"Current Statistics Values 0"); break;case CASE_TABLE_DESCRIPTION_USER_TABLENAME: strcpy (dyn_title,"Table Description del Usuario [<OWNER>] [<TABLENAME>] 0"); break;case CASE_CURRENT_ACTIVITY_REPORT: strcpy (dyn_title,"Current Activity Report 0"); break;case CASE_DICTIONARY_TABLE_COMMENTS: strcpy (dyn_title,"Table Dictionary Comments 0"); break;case CASE_DICTIONARY_TABLE_COLUMNS_DESCRIP: strcpy (dyn_title,"Table Dictionary Columns Description 0"); break;case CASE_SGA_STATISTIC_GENERAL: strcpy (dyn_title,"Sga Statistic General 0"); break;case CASE_SGA_STATISTIC_MEMORY_USAGE: strcpy (dyn_title,"Sga Statistic Memory Usage 0"); break;case CASE_SGA_STATISTIC_INFORMATION: strcpy (dyn_title,"Sga Statistic Memory Information 0"); break;case CASE_ROW_CACHE_INFORMATION: strcpy (dyn_title,"Row Cache Information 0"); break;case CASE_PERFORMANCE_DISK_I_O: strcpy (dyn_title,"Performance Disk I-O 0"); break;case CASE_RECURSIVE_CALLS: strcpy (dyn_title,"Recursive Calls 0"); break;case CASE_SYSTEM_EVENTS: strcpy (dyn_title,"System Events 0");
  • 134. break;/* -------------------------------------------------------------- */ /*#define CASE_SQL_AREA_ALL_ENTRIES 52 */ case CASE_SQL_AREA_ALL_ENTRIES: strcpy (dyn_title,"Sql Area All Information 0"); break; /*#define CASE_SQL_AREA_CPU_USAGE 53 */ case CASE_SQL_AREA_CPU_USAGE: strcpy (dyn_title,"Sql Area Cpu Usage 0"); break; /*#define CASE_SQL_AREA_MEMORY_USAGE 54 */ case CASE_SQL_AREA_MEMORY_USAGE: strcpy (dyn_title,"Sql Area Memory Usage 0"); break; /* /*#define CASE_SQL_AREA_BUFFER_GET_SUM 55 */ case CASE_SQL_AREA_BUFFER_GET_SUM: strcpy (dyn_title,"Sql Area Buffer Get Sum 0"); break; /*#define CASE_INIT_PARAMETERS_VALUES_STATUS 56 */ case CASE_INIT_PARAMETERS_VALUES_STATUS: strcpy (dyn_title,"Init Parameters Values - Status 0"); break;/* -------------------------------------------------------------- */ case CASE_TABLESPACE_FRAGMENTATION: strcpy (dyn_title,"Tablespace Defragmentation 0"); break; case CASE_SHOW_NLS_PARAMETERS: strcpy (dyn_title,"Show Nls Parameters 0");
  • 135. break;case CASE_CONTROL_FILES_STATUS: strcpy (dyn_title,"Control File Status 0"); break;case CASE_SORT_SEGMENTS_USERS: strcpy (dyn_title,"Show Sort Segments - Users 0"); break;case CASE_ORACLE_QUOTAS: strcpy (dyn_title,"Quotas by TableSpace - User 0"); break;case CASE_TABLE_GENERAL_DESCRIPTION: strcpy (dyn_title,"Tables General Description 0"); break;case CASE_TABLE_COLUMN_DESCRIPTION: strcpy (dyn_title,"Tables Column Description 0"); break;case CASE_TABLE_CONSTRAINTS: strcpy (dyn_title,"Tables Constraints 0"); break;case CASE_INDEX_GENERAL_DESCRIPTION: strcpy (dyn_title,"Index General Description 0"); break;case CASE_AUDIT_DEFINITION: strcpy (dyn_title,"Audit Definition 0"); break;case CASE_SHOW_SEGMENTS_EXTENTS: strcpy (dyn_title," Show Segments - Extents 0"); break;case CASE_SHOW_EXTENTS_INSIDE_DATAFILES: strcpy (dyn_title," Show Extents Inside Datafiles 0"); break;case CASE_SHOW_USER_LISTS: strcpy (dyn_title," Show Users Lists 0"); break;case CASE_SHOW_ROLES_PRIVILEGES: strcpy (dyn_title," Show Roles - Privileges 0"); break;case CASE_SHOW_PRIVILEGES_COLUMNS: strcpy (dyn_title," Show Privileges by Columns 0"); break;
  • 136. case CASE_SHOW_LOCKS_VIEWS: strcpy (dyn_title," Show Locks Views (Another Way ) 0"); break;case CASE_GRAPH_LOCK_WAITS: strcpy (dyn_title," Graph Session Lock Waits 0"); break;case CASE_OBJECT_ACCESS_SESSION: strcpy (dyn_title," Object access by Sid 0"); break;case CASE_SHOW_LATCHES: strcpy (dyn_title," Show Latches 0"); break;case CASE_SHOW_STATISTICS: strcpy (dyn_title," Show Statistics 0"); break;case CASE_SHOW_TRANSACTIONS: strcpy (dyn_title," Show Transaction Status 0"); break;case CASE_SHOW_DATAFILES_STATUS: strcpy (dyn_title," Datafile Status 0"); break;case CASE_SHOW_DB_OBJECT_CACHE: strcpy (dyn_title," Show Database Object Cache 0"); break;case CASE_TABLE_ALERT_EXTENT_USED: strcpy (dyn_title," Table Alert Extent Used 0"); break;case CASE_INDEX_ALERT_EXTENT_USED: strcpy (dyn_title," Index Alert Extent Used 0"); break;case CASE_USER_TIME_WORKING: strcpy (dyn_title," User Active Program Working 0"); break;case CASE_IS_USER_WORKING: strcpy (dyn_title," User Time User Working 0"); break;case CASE_VER_SQL_PROGRAM: strcpy (dyn_title," See SQL*Plus/Other Programs 0"); break;case CASE_SQL_SESS_IO:
  • 137. strcpy (dyn_title," Show Session I/O Activity 0"); break; case CASE_SQL_SESSION_EVENT: strcpy (dyn_title," Show Session Event Times 0"); break; case CASE_SQL_SESSION_WAIT: strcpy (dyn_title," Show Session Wait Reasons 0"); break; case CASE_SQL_SESSION_LONG_OPER: strcpy (dyn_title," Show Session Long Opers 0"); break; case CASE_SQL_LOCKED_OBJECTS: strcpy (dyn_title," Show Locked Objects 0"); break; case CASE_SQL_TRANSACTION_DETAIL: strcpy (dyn_title," Show Transactions Details 0"); break; case CASE_SQL_LOCK_MEDIUM_INFO: strcpy (dyn_title," Show Lock Medium Details 0"); break; case CASE_SQL_LOCK_FULL_INFO: strcpy (dyn_title," Show Lock Full Details 0"); break; case CASE_SQL_LOCK_BY_SESSION_ID: strcpy (dyn_title," Show Lock Session by SID 0"); break; case CASE_SQL_WHO_IS_WAITING_FOR: strcpy (dyn_title,"Locking for who is waiting ? 0"); break; case CASE_SQL_WHICH_SQL_RUNNING: strcpy (dyn_title,"Which Sql is Running 0"); break; case CASE_WHICH_OBJECTS_LOCKED_BY_USER: strcpy (dyn_title,"Which Object Locked By User 0"); break;/* ------------------------------------------------- *//************* Agregado 25-Agosto-2005 ***************/ case CASE_BUFFER_CACHE_DEFINED: strcpy (dyn_title,"Show Buffer Cached Defined 0"); break;
  • 138. /* ------------------------------------------------- */ case CASE_BUFFER_CACHE_TOTAL_SIZE: strcpy (dyn_title,"Show Buffer Total Size 0"); break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_COST_ADJ_ESTIMATE: strcpy (dyn_title,"Estimate parameter optimizer_index_cost_adj 0"); break;/* ------------------------------------------------- */ case CASE_OPTIMIZER_INDEX_CACHING_ESTIMAGE: strcpy (dyn_title,"Estimate parameter optimizer_index_caching 0"); break;/* ------------------------------------------------- *//* ------------------------------------------------- */ default: strcpy (dyn_title,"Oracle Version 0"); break; } return dyn_title; }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: funciones_auxiliares.c ****** ****** ***
  • 139. ******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* Result Sets Interface */#ifndef SQL_CRSR# define SQL_CRSR struct sql_cursor { unsigned int curocn; void *ptr1; void *ptr2; unsigned int magic; }; typedef struct sql_cursor sql_cursor; typedef struct sql_cursor SQL_CURSOR;#endif /* SQL_CRSR *//* Thread Safety */typedef void * sql_context;typedef void * SQL_CONTEXT;/* Object support */struct sqltvn{ unsigned char *tvnvsn; unsigned short tvnvsnl; unsigned char *tvnnm; unsigned short tvnnml; unsigned char *tvnsnm; unsigned short tvnsnml;};typedef struct sqltvn sqltvn;struct sqladts{
  • 140. unsigned int adtvsn; unsigned short adtmode; unsigned short adtnum; sqltvn adttvn[1];};typedef struct sqladts sqladts;static struct sqladts sqladt = { 1,0,0,};/* Binding to PL/SQL Records */struct sqltdss{ unsigned int tdsvsn; unsigned short tdsnum; unsigned char *tdsval[1];};typedef struct sqltdss sqltdss;static struct sqltdss sqltds ={ 1, 0,};/* File name & Package Name */struct sqlcxp{ unsigned short fillen; char filnam[24];};static const struct sqlcxp sqlfpn ={ 23, "funciones_auxiliares.pc"};static unsigned int sqlctx = 628383107;
  • 141. static struct sqlexd { unsigned int sqlvsn; unsigned int arrsiz; unsigned int iters; unsigned int offset; unsigned short selerr; unsigned short sqlety; unsigned int occurs; const short *cud; unsigned char *sqlest; const char *stmt; sqladts *sqladtp; sqltdss *sqltdsp; void **sqphsv; unsigned int *sqphsl; int *sqphss; void **sqpind; int *sqpins; unsigned int *sqparm; unsigned int **sqparc; unsigned short *sqpadto; unsigned short *sqptdso; unsigned int sqlcmax; unsigned int sqlcmin; unsigned int sqlcincr; unsigned int sqlctimeout; unsigned int sqlcnowait; int sqfoff; unsigned int sqcmod; unsigned int sqfmod; void *sqhstv[1]; unsigned int sqhstl[1]; int sqhsts[1]; void *sqindv[1]; int sqinds[1]; unsigned int sqharm[1]; unsigned int *sqharc[1]; unsigned short sqadto[1]; unsigned short sqtdso[1];
  • 142. } sqlstm = {12,1};/* SQLLIB Prototypes */extern void sqlcxt (void **, unsigned int *, struct sqlexd *, const struct sqlcxp *);extern void sqlcx2t(void **, unsigned int *, struct sqlexd *, const struct sqlcxp *);extern void sqlbuft(void **, char *);extern void sqlgs2t(void **, char *);extern void sqlorat(void **, unsigned int *, void *);/* Forms Interface */static const int IAPSUCC = 0;static const int IAPFAIL = 1403;static const int IAPFTL = 535;extern void sqliem(char *, int *);typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;typedef struct { unsigned short len; unsigned char arr[1]; } varchar;/* cud (compilation unit data) array */static const short sqlcud0[] ={12,4242,178,1,0,};#include <stdio.h>#include <stdlib.h>#include <string.h>#include "constant_definition.h"#include "case_constant_func_def.h"#include "case_constant_sql_stmt_def.h"#include "constant_oracle_versions.h"#include <oraca.h>#include <sqlca.h>#include "extern_functions_funciones_auxiliares.h"/* EXEC SQL INCLUDE sqlca;
  • 143. *//* * $Header: sqlca.h,v 1.3 1994/12/12 19:27:27 jbasu Exp $ sqlca.h *//* Copyright (c) 1985,1986, 1998 by Oracle Corporation. *//*NAME SQLCA : SQL Communications Area.FUNCTION Contains no code. Oracle fills in the SQLCA with status info during the execution of a SQL stmt.NOTES ************************************************************** *** *** *** This file is SOSD. Porters must change the data types *** *** appropriately on their platform. See notes/pcport.doc *** *** for more information. *** *** *** ************************************************************** If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA will be defined to have this storage class. For example: #define SQLCA_STORAGE_CLASS extern will define the SQLCA as an extern. If the symbol SQLCA_INIT is defined, then the SQLCA will be statically initialized. Although this is not necessary in order to use the SQLCA, it is a good pgming practice not to have unitialized variables. However, some C compilers/OSs dont allow automatic variables to be initd in this manner. Therefore, if you are INCLUDEing the SQLCA in a place where it would be an automatic AND your C compiler/OS doesnt allow this style of initialization, then SQLCA_INIT should be left undefined -- all others can define SQLCA_INIT if they wish. If the symbol SQLCA_NONE is defined, then the SQLCA variable will
  • 144. not be defined at all. The symbol SQLCA_NONE should not be defined in source modules that have embedded SQL. However, source modules that have no embedded SQL, but need to manipulate a sqlca struct passed in as a parameter, can set the SQLCA_NONE symbol to avoid creation of an extraneous sqlca variable.MODIFIED lvbcheng 07/31/98 - long to int jbasu 12/12/94 - Bug 217878: note this is an SOSD file losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set Clare 12/06/84 - Ch SQLCA to not be an extern. Clare 10/21/85 - Add initialization. Bradbury 01/05/86 - Only initialize when SQLCA_INIT set Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.*/#ifndef SQLCA#define SQLCA 1struct sqlca { /* ub1 */ char sqlcaid[8]; /* b4 */ int sqlabc; /* b4 */ int sqlcode; struct { /* ub2 */ unsigned short sqlerrml; /* ub1 */ char sqlerrmc[70]; } sqlerrm; /* ub1 */ char sqlerrp[8]; /* b4 */ int sqlerrd[6]; /* ub1 */ char sqlwarn[8]; /* ub1 */ char sqlext[8]; };#ifndef SQLCA_NONE#ifdef SQLCA_STORAGE_CLASSSQLCA_STORAGE_CLASS struct sqlca sqlca#else struct sqlca sqlca
  • 145. #endif#ifdef SQLCA_INIT = { {S, Q, L, C, A, , , }, sizeof(struct sqlca), 0, { 0, {0}}, {N, O, T, , S, E, T, }, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} }#endif ;#endif#endif/* end SQLCA *//* EXEC SQL INCLUDE sqlda; *//* * $Header: sqlda.h 31-jul-99.19:34:41 apopat Exp $ sqlda.h *//**************************************************************** The SQLDA descriptor definition **--------------------------------------------------------------** VAX/3B Version ** ** Copyright (c) 1987, 1997, 1998, 1999 by Oracle Corporation ****************************************************************//* NOTES ************************************************************** *** *** *** This file is SOSD. Porters must change the data types *** *** appropriately on their platform. See notes/pcport.doc ***
  • 146. *** for more information. *** *** *** ***************************************************************//* MODIFIED apopat 07/31/99 - [707588] TAB to blanks for OCCS lvbcheng 10/27/98 - change long to int for sqlda lvbcheng 08/15/97 - Move sqlda protos to sqlcpr.h lvbcheng 06/25/97 - Move sqlda protos to this file jbasu 01/29/95 - correct typo jbasu 01/27/95 - correct comment - ub2->sb2 jbasu 12/12/94 - Bug 217878: note this is an SOSD file Morse 12/01/87 - undef L and S for v6 include files Richey 07/13/87 - change int defs to long Clare 09/13/84 - Port: Ch types to match SQLLIB structs Clare 10/02/86 - Add ifndef SQLDA*/#ifndef SQLDA_#define SQLDA_ 1#ifdef T# undef T#endif#ifdef F# undef F#endif#ifdef S# undef S#endif#ifdef L# undef L#endifstruct SQLDA { /* ub4 */ int N; /* Descriptor size in number of entries */ /* text** */ char **V; /* Ptr to Arr of addresses of main variables */ /* ub4* */ int *L; /* Ptr to Arr of lengths of buffers */
  • 147. /* sb2* */ short *T; /* Ptr to Arr of types of buffers */ /* sb2** */ short **I; /* Ptr to Arr of addresses of indicator vars */ /* sb4 */ int F; /* Number of variables found by DESCRIBE */ /* text** */ char **S; /* Ptr to Arr of variable name pointers */ /* ub2* */ short *M; /* Ptr to Arr of max lengths of var. names */ /* ub2* */ short *C; /* Ptr to Arr of current lengths of var. names */ /* text** */ char **X; /* Ptr to Arr of ind. var. name pointers */ /* ub2* */ short *Y; /* Ptr to Arr of max lengths of ind. var. names */ /* ub2* */ short *Z; /* Ptr to Arr of cur lengths of ind. var. names */ };typedef struct SQLDA SQLDA;#endif/* ----------------- *//* defines for sqlda *//* ----------------- */#define SQLSQLDAAlloc(arg1, arg2, arg3, arg4) sqlaldt(arg1, arg2, arg3, arg4)#define SQLSQLDAFree(arg1, arg2) sqlclut(arg1, arg2)/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int stmtsqlncmp (char *punt_cad1, char *punt_cad2, int largo) { int pos=0; int caracter1=0; int caracter2=0; int sizecad1=(int )strlen (punt_cad1); int sizecad2=(int )strlen (punt_cad2);/* printf ("A comparar [%s] = [%s] n",punt_cad1, punt_cad2); */
  • 148. for (pos=0; pos < largo; pos ++) { if (( pos > sizecad1 ) || ( pos > sizecad2) ) return 1; else { caracter1= tolower (punt_cad1[pos]); caracter2= tolower (punt_cad2[pos]);/* printf ("Carater [%c] == [%c] n",caracter1,caracter2); */ if ( caracter1 != caracter2 ) return 1; } }/* printf ("Encontrado [%s] n",punt_cad1); */ return 0; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_cadena (void *punt_cadena, int largo) { int pos; for (pos = 0; pos < largo; pos ++) ((char *) punt_cadena ) [pos] = ASCII_FIN_LINEA; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */col_size (char *puntero, int posicion) { char ascii_nro[3]; static int numero; int i; for ( i = posicion*2; i < posicion*2+2; i++) ascii_nro[i-posicion*2]=puntero[i];
  • 149. ascii_nro[2]=ASCII_FIN_LINEA; numero=atoi(ascii_nro); return numero; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int filtrar_char (int caracter) { if ( (caracter >= 32 && caracter <= 127 ) ) return caracter; else { switch (caracter) { case 164: break; case 165: break; case 168: break; case 173: break; default: caracter=32;break; } } return caracter; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *separar_dato (void *punt_cad, int opcion ) { static char cadena[MAX_LEN_CONNECT]; int posicion=0; int pos_arroba=0; int pos_slash=0; int largocad=0; int caracter=0; int contador=0;
  • 150. largocad=(int )strlen ((char *) punt_cad);vaciar_cadena (cadena,MAX_LEN_CONNECT);for ( posicion=0; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; if ( caracter == ASCII_SLASH ) pos_slash = posicion; else if (caracter == ASCII_ARROBA) pos_arroba = posicion; }switch (opcion ) { case USERNAME: for (posicion=0; posicion < pos_slash; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; case PASSWORD: for (posicion=pos_slash+1; posicion < pos_arroba; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; case CONEXION: for (posicion=pos_arroba+1; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; }cadena[contador]=ASCII_FIN_LINEA;return (cadena);
  • 151. }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_columna_funcion ( void *punt_cadena, int nro_columna, int *nro_funcion ) { char procesar[10]; char col_char[10]; char func_char[10]; int pos_col = 0; int flag_procesar = 0; int caracter = 0; int delimitador = 0; int contador = 0; int nro_col = 0; int nro_func = 0; for ( pos_col = 1; pos_col < 3; pos_col ++) { procesar [pos_col-1] = ( (char *) punt_cadena)[pos_col]; procesar [pos_col] = ASCII_FIN_LINEA; } if (strncmp (procesar,"SI",2) == 0 ) flag_procesar = SI_PROCESAR; if (strncmp (procesar,"NO",2) == 0 ) { flag_procesar = NO_PROCESAR; return (NO_PROCESAR); } vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); for ( pos_col = 3; pos_col < (int ) (strlen ( (char *) punt_cadena )); pos_col ++ ) { caracter = ( (char *) punt_cadena )[pos_col];/* printf (" ______> CHAR={%c} POS_COL=[%d] CONTADOR=[%d] LIMITADOR=[%d]n",caracter,pos_col,contador,delimitador); */ if ( caracter == ASCII_SEPARADOR )
  • 152. if ( delimitador == 0 ) delimitador++; else delimitador--; if ( ( delimitador == 1 ) && ( caracter != ASCII_SEPARADOR ) ) { if ( contador < 2 ) { col_char[contador] = caracter; col_char[contador+1] = ASCII_FIN_LINEA; } else if (contador >=2 ) { func_char [contador-2] = caracter; func_char [contador-2+1]= ASCII_FIN_LINEA; }/* printf (" ______________>>>>>> COL_CHAR [%s] FUNC_CHAR [%s] NRO_COLUMNA [%d] n",col_char,func_char,nro_columna); */ contador++; if ( contador == 4 ) { nro_col = atoi (col_char); nro_func = atoi (func_char); contador=0; vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); if ( nro_col == nro_columna ) { *nro_funcion = nro_func; return (SI_PROCESAR); } } } } return (NO_PROCESAR); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */
  • 153. char *convert_ss_to_hh_mm_ss (char *punt_cadena ) { static char dato_1[MAX_LEN_VARCHAR]; char auxiliar[12]; int hora,minuto,segundo; float numero= (float )atoi (punt_cadena); vaciar_cadena (dato_1,MAX_LEN_VARCHAR); vaciar_cadena (auxiliar,12); hora = (int )(numero/60/60); minuto = (int ) ((numero/60/60 - (int )(numero/60/60))*60); segundo = (int ) ((numero/60 - (int )(numero/60))*60); if (hora < 10) sprintf (auxiliar,"00%d:",hora); else if ((hora > 9) && (hora < 100)) sprintf (auxiliar,"0%d:",hora); else sprintf (auxiliar,"%d:",hora); strcat (dato_1,auxiliar); if (minuto < 10) sprintf (auxiliar,"0%d:",minuto); else sprintf (auxiliar,"%2d:",minuto); strcat (dato_1,auxiliar); if (segundo < 10) sprintf (auxiliar,"0%dn0",segundo); else sprintf (auxiliar,"%2dn0",segundo); strcat (dato_1,auxiliar); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_estructura ( void *punt_sqlda )
  • 154. { int pos_k, pos_j; int limite_k = ((SQLDA *) punt_sqlda ) ->F; int limite_j; for ( pos_k = 0; pos_k < limite_k ; pos_k++ ) { limite_j = ((SQLDA *) punt_sqlda ) ->L[ pos_k ]; for ( pos_j = 0; pos_j < limite_j ; pos_j++) (char ) (((SQLDA *) punt_sqlda )->V[pos_k])[pos_j] = ASCII_FIN_LINEA; } }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_encabe (int tamano, int posicion, char *puntero_char) { int pos_col=0; int pos_cad=0; int columna=-1; int caracter=0; int salto=0; for ( pos_col = 0; pos_col < (int )strlen(puntero_char); pos_col ++) { if ( puntero_char[pos_col] == ASCII_SEPARADOR ) columna++; if ( columna == posicion ) break; } for ( pos_cad = pos_col+1; pos_cad < tamano+pos_col+1; pos_cad++ ) { if ( puntero_char[pos_cad]==ASCII_SEPARADOR) salto++; if (salto==0) { caracter = filtrar_char ( puntero_char[pos_cad] ); printf ("%c",caracter); } else printf (" "); }
  • 155. return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_cadena (int nrocolum, char *puntero_char) { int pos, caracter; for ( pos=0; pos < nrocolum; pos++ ) { caracter=filtrar_char(puntero_char[pos]); printf ("%c",caracter); } fflush(stdout); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *pasar_amayus (char *cadena ) { int pos=0; /* printf ("Iniciando conversion n"); */ for (pos =0; pos < (int ) strlen (cadena); pos ++) cadena[pos]=toupper(cadena[pos]); return cadena; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *funcion_columna (int nro_bytes, void *punt_cadena, int nro_funcion)
  • 156. {static char dato_1 [1024];long valor_salida;long valor_entrada;vaciar_cadena (dato_1,1024);switch (nro_funcion) { case FUNC_DB_BLOCK_SIZE: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1000,dato_1,10); break; case FUNC_COMMAND_SQL: /* Decodifico el nro de la Columna y lo relaciono con el nombre del COMANDO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_command_oracle ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_MODE: /* Decodifico el nro de la Columna y lo relaciono con el tipo de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_lock_mode ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_NAME_MODE: /* Decodifico el nro de la Columna y lo relaciono con el nombre de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_name_lock ( (char *) punt_cadena) ); break; case FUNC_DB_BLOCK_SIZE0: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1024,dato_1,10); break; case FUNC_DB_OBJECT_TYPE: /* Busco el OBJECT_TYPE dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_object_type ( atoi ( (char *) punt_cadena ) ) ); break; case FUNC_DB_OBJECT_OWNER_NAME:
  • 157. /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_object_owner_name ( atoi ( (char *) punt_cadena ) ) ); /* printf ("[%s] n",dato_1); */ break; case FUNC_DB_SESSION_SID: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ *//* printf ("Cons[%s]n",((char *) punt_cadena)); */ strcpy (dato_1,db_session_sid_locked ((char *) punt_cadena )); /* printf ("[%s] n",dato_1);*/ break; case FUNC_CONVERT_HH_MM_SS: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,convert_ss_to_hh_mm_ss ((char *) punt_cadena )); break; case FUNC_DB_COMP_TBLSPC_INI_EXT: /* Busco el INIT_EXTENT de un TABLESPACE, y lo comparo en el valor */ /* --------------------------------------------------------------- */ valor_entrada = atoi ((char *) punt_cadena); valor_salida = db_tablspace_ini_ext_size ((char *) punt_cadena); if (valor_entrada == 0) strcpy (dato_1,"FREEn"); else if (valor_entrada != valor_salida ) strcpy (dato_1,"CHANGEDn"); else strcpy (dato_1,"INITIALn"); break; default: break; } return (dato_1); }--- ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  • 158. ---------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: funciones_auxiliares.pc ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>#include <stdlib.h>#include <string.h>#include "constant_definition.h"#include "case_constant_func_def.h"#include "case_constant_sql_stmt_def.h"#include "constant_oracle_versions.h"#include <oraca.h>#include <sqlca.h>#include "extern_functions_funciones_auxiliares.h" EXEC SQL INCLUDE sqlca; EXEC SQL INCLUDE sqlda;/* ----****----****----****----****----****----****----****----****----****----**** */
  • 159. /* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int stmtsqlncmp (char *punt_cad1, char *punt_cad2, int largo) { int pos=0; int caracter1=0; int caracter2=0; int sizecad1=(int )strlen (punt_cad1); int sizecad2=(int )strlen (punt_cad2);/* printf ("A comparar [%s] = [%s] n",punt_cad1, punt_cad2); */ for (pos=0; pos < largo; pos ++) { if (( pos > sizecad1 ) || ( pos > sizecad2) ) return 1; else { caracter1= tolower (punt_cad1[pos]); caracter2= tolower (punt_cad2[pos]);/* printf ("Carater [%c] == [%c] n",caracter1,caracter2); */ if ( caracter1 != caracter2 ) return 1; } }/* printf ("Encontrado [%s] n",punt_cad1); */ return 0; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_cadena (void *punt_cadena, int largo) { int pos; for (pos = 0; pos < largo; pos ++) ((char *) punt_cadena ) [pos] = ASCII_FIN_LINEA; }
  • 160. /* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */col_size (char *puntero, int posicion) { char ascii_nro[3]; static int numero; int i; for ( i = posicion*2; i < posicion*2+2; i++) ascii_nro[i-posicion*2]=puntero[i]; ascii_nro[2]=ASCII_FIN_LINEA; numero=atoi(ascii_nro); return numero; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int filtrar_char (int caracter) { if ( (caracter >= 32 && caracter <= 127 ) ) return caracter; else { switch (caracter) { case 164: break; case 165: break; case 168: break; case 173: break; default: caracter=32;break; } } return caracter; }/* ----****----****----****----****----****----****----****----****----****----**** */
  • 161. /* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *separar_dato (void *punt_cad, int opcion ) { static char cadena[MAX_LEN_CONNECT]; int posicion=0; int pos_arroba=0; int pos_slash=0; int largocad=0; int caracter=0; int contador=0; largocad=(int )strlen ((char *) punt_cad); vaciar_cadena (cadena,MAX_LEN_CONNECT); for ( posicion=0; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; if ( caracter == ASCII_SLASH ) pos_slash = posicion; else if (caracter == ASCII_ARROBA) pos_arroba = posicion; } switch (opcion ) { case USERNAME: for (posicion=0; posicion < pos_slash; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; case PASSWORD: for (posicion=pos_slash+1; posicion < pos_arroba; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++;
  • 162. } break; case CONEXION: for (posicion=pos_arroba+1; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; } cadena[contador]=ASCII_FIN_LINEA; return (cadena); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_columna_funcion ( void *punt_cadena, int nro_columna, int *nro_funcion ) { char procesar[10]; char col_char[10]; char func_char[10]; int pos_col = 0; int flag_procesar = 0; int caracter = 0; int delimitador = 0; int contador = 0; int nro_col = 0; int nro_func = 0; for ( pos_col = 1; pos_col < 3; pos_col ++) { procesar [pos_col-1] = ( (char *) punt_cadena)[pos_col]; procesar [pos_col] = ASCII_FIN_LINEA; } if (strncmp (procesar,"SI",2) == 0 ) flag_procesar = SI_PROCESAR;
  • 163. if (strncmp (procesar,"NO",2) == 0 ) { flag_procesar = NO_PROCESAR; return (NO_PROCESAR); } vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); for ( pos_col = 3; pos_col < (int ) (strlen ( (char *) punt_cadena )); pos_col ++ ) { caracter = ( (char *) punt_cadena )[pos_col];/* printf (" ______> CHAR={%c} POS_COL=[%d] CONTADOR=[%d] LIMITADOR=[%d]n",caracter,pos_col,contador,delimitador); */ if ( caracter == ASCII_SEPARADOR ) if ( delimitador == 0 ) delimitador++; else delimitador--; if ( ( delimitador == 1 ) && ( caracter != ASCII_SEPARADOR ) ) { if ( contador < 2 ) { col_char[contador] = caracter; col_char[contador+1] = ASCII_FIN_LINEA; } else if (contador >=2 ) { func_char [contador-2] = caracter; func_char [contador-2+1]= ASCII_FIN_LINEA; }/* printf (" ______________>>>>>> COL_CHAR [%s] FUNC_CHAR [%s] NRO_COLUMNA [%d] n",col_char,func_char,nro_columna); */ contador++; if ( contador == 4 ) { nro_col = atoi (col_char); nro_func = atoi (func_char); contador=0; vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); if ( nro_col == nro_columna ) {
  • 164. *nro_funcion = nro_func; return (SI_PROCESAR); } } } } return (NO_PROCESAR); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *convert_ss_to_hh_mm_ss (char *punt_cadena ) { static char dato_1[MAX_LEN_VARCHAR]; char auxiliar[12]; int hora,minuto,segundo; float numero= (float )atoi (punt_cadena); vaciar_cadena (dato_1,MAX_LEN_VARCHAR); vaciar_cadena (auxiliar,12); hora = (int )(numero/60/60); minuto = (int ) ((numero/60/60 - (int )(numero/60/60))*60); segundo = (int ) ((numero/60 - (int )(numero/60))*60); if (hora < 10) sprintf (auxiliar,"00%d:",hora); else if ((hora > 9) && (hora < 100)) sprintf (auxiliar,"0%d:",hora); else sprintf (auxiliar,"%d:",hora); strcat (dato_1,auxiliar); if (minuto < 10) sprintf (auxiliar,"0%d:",minuto); else sprintf (auxiliar,"%2d:",minuto); strcat (dato_1,auxiliar);
  • 165. if (segundo < 10) sprintf (auxiliar,"0%dn0",segundo); else sprintf (auxiliar,"%2dn0",segundo); strcat (dato_1,auxiliar); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_estructura ( void *punt_sqlda ) { int pos_k, pos_j; int limite_k = ((SQLDA *) punt_sqlda ) ->F; int limite_j; for ( pos_k = 0; pos_k < limite_k ; pos_k++ ) { limite_j = ((SQLDA *) punt_sqlda ) ->L[ pos_k ]; for ( pos_j = 0; pos_j < limite_j ; pos_j++) (char ) (((SQLDA *) punt_sqlda )->V[pos_k])[pos_j] = ASCII_FIN_LINEA; } }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_encabe (int tamano, int posicion, char *puntero_char) { int pos_col=0; int pos_cad=0; int columna=-1; int caracter=0; int salto=0; for ( pos_col = 0; pos_col < (int )strlen(puntero_char); pos_col ++) {
  • 166. if ( puntero_char[pos_col] == ASCII_SEPARADOR ) columna++; if ( columna == posicion ) break; } for ( pos_cad = pos_col+1; pos_cad < tamano+pos_col+1; pos_cad++ ) { if ( puntero_char[pos_cad]==ASCII_SEPARADOR) salto++; if (salto==0) { caracter = filtrar_char ( puntero_char[pos_cad] ); printf ("%c",caracter); } else printf (" "); } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_cadena (int nrocolum, char *puntero_char) { int pos, caracter; for ( pos=0; pos < nrocolum; pos++ ) { caracter=filtrar_char(puntero_char[pos]); printf ("%c",caracter); } fflush(stdout); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *pasar_amayus (char *cadena ) { int pos=0;
  • 167. /* printf ("Iniciando conversion n"); */ for (pos =0; pos < (int ) strlen (cadena); pos ++) cadena[pos]=toupper(cadena[pos]); return cadena; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *funcion_columna (int nro_bytes, void *punt_cadena, int nro_funcion) { static char dato_1 [1024]; long valor_salida; long valor_entrada; vaciar_cadena (dato_1,1024); switch (nro_funcion) { case FUNC_DB_BLOCK_SIZE: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1000,dato_1,10); break; case FUNC_COMMAND_SQL: /* Decodifico el nro de la Columna y lo relaciono con el nombre del COMANDO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_command_oracle ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_MODE: /* Decodifico el nro de la Columna y lo relaciono con el tipo de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_lock_mode ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_NAME_MODE: /* Decodifico el nro de la Columna y lo relaciono con el nombre de LOCKEO */ /* ------------------------------------------------------------------------ */
  • 168. strcpy ( dato_1, decode_name_lock ( (char *) punt_cadena) ); break; case FUNC_DB_BLOCK_SIZE0: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1024,dato_1,10); break; case FUNC_DB_OBJECT_TYPE: /* Busco el OBJECT_TYPE dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_object_type ( atoi ( (char *) punt_cadena ) ) ); break; case FUNC_DB_OBJECT_OWNER_NAME: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_object_owner_name ( atoi ( (char *) punt_cadena ) ) ); /* printf ("[%s] n",dato_1); */ break; case FUNC_DB_SESSION_SID: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ *//* printf ("Cons[%s]n",((char *) punt_cadena)); */ strcpy (dato_1,db_session_sid_locked ((char *) punt_cadena )); /* printf ("[%s] n",dato_1);*/ break; case FUNC_CONVERT_HH_MM_SS: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,convert_ss_to_hh_mm_ss ((char *) punt_cadena )); break; case FUNC_DB_COMP_TBLSPC_INI_EXT: /* Busco el INIT_EXTENT de un TABLESPACE, y lo comparo en el valor */ /* --------------------------------------------------------------- */ valor_entrada = atoi ((char *) punt_cadena); valor_salida = db_tablspace_ini_ext_size ((char *) punt_cadena); if (valor_entrada == 0) strcpy (dato_1,"FREEn"); else if (valor_entrada != valor_salida ) strcpy (dato_1,"CHANGEDn");
  • 169. else strcpy (dato_1,"INITIALn"); break; default: break; } return (dato_1); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: funciones.cpp ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***--- ------ -----------------------------------------------------------------------------------------------------------------------------------------------------
  • 170. ----------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_menu_mostrar.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"#include "extern_functions_orastat_principal.h"#include "local_functions_preceded_calls.h"int func_menu_mostrar (int version, int nro_opcion) { int conta_opcion; if ( ( nro_opcion < 0 ) || ( nro_opcion > MAX_NRO_OPCION ) )
  • 171. { printf ("---------------------------------------------------n"); for ( conta_opcion=0; conta_opcion <= MAX_NRO_OPCION; conta_opcion++) { printf ("[ %2d ] ",conta_opcion); printf ("[ %s ] n",func_dyn_title_set (version,conta_opcion) ); } printf ("...................................................n"); } return 0; }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: funct_format_sql_statement.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>
  • 172. #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 ();extern stmtsqlncmp ();char *formatear_sql_statement ( void *punt_cadena ) { static char order_stmt [MAX_STMT_SIZE]; static char auxi_stmt [MAX_STMT_SIZE]; static char auxiliar [MAX_WORD_STMT]; int profu_parent =0; int profu_comita =0; int profu_comilla =0; int contador_blanco =0; int largo_cadena=0; int posicion1=0; int posicion2=0; int posicion3=0; int caracter=0; largo_cadena = (int )strlen ((char *) punt_cadena); vaciar_cadena (order_stmt, MAX_STMT_SIZE); vaciar_cadena (auxi_stmt, MAX_STMT_SIZE); posicion2=0; /* ************ Quitando espacios en blanco ************* */ for (posicion1=0; posicion1 <= largo_cadena; posicion1++) { caracter = ((char *) punt_cadena )[posicion1]; if ( caracter == ASCII_SPACE )
  • 173. if ( contador_blanco == 0 ) { contador_blanco++; auxi_stmt [posicion2]=caracter; posicion2++; } if ( caracter != ASCII_SPACE) { contador_blanco=0; auxi_stmt[posicion2]=caracter; posicion2++; } } auxi_stmt[posicion2]=ASCII_FIN_LINEA; /* ************ ||||||||||||||||||||||||||| ************* */ largo_cadena=(int )strlen(auxi_stmt); posicion2=0; posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); for (posicion1=0; posicion1 <= largo_cadena; posicion1++) { caracter = auxi_stmt [posicion1];/* printf ("C [%c=%d] ",caracter,caracter); */ if ( caracter != ASCII_SPACE ) { auxiliar[posicion3] = caracter;/* order_stmt[posicion2] = caracter; posicion2++; order_stmt[posicion2] = ASCII_FIN_LINEA;*/ posicion3++; auxiliar[posicion3] = ASCII_FIN_LINEA; } else if (caracter == ASCII_SPACE ) { if ( ( stmtsqlncmp (auxiliar,"select",6)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar);
  • 174. strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); }else if ( (stmtsqlncmp (auxiliar,"from",4)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); }else if ( (stmtsqlncmp (auxiliar,"where",5)==0 ) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); }else if ( (stmtsqlncmp (auxiliar,"group",5)==0) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); }else if ( (stmtsqlncmp (auxiliar,"order",5)==0) ) { strcat (order_stmt," n"); strcat (order_stmt,auxiliar); strcat (order_stmt," n"); posicion3=0; vaciar_cadena (auxiliar,MAX_WORD_STMT); }strcat (order_stmt,auxiliar);strcat (order_stmt," ");posicion3=0;vaciar_cadena (auxiliar,MAX_WORD_STMT);
  • 175. } } return (order_stmt); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_time_sleep.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***#include <stdio.h>#include <stdlib.h>#include <time.h>#include <windows.h>#include "extern_functions_funciones_auxiliares.h"void esperar_seg( int numero_seg )
  • 176. { printf( "Esperando [%d] segs n",numero_seg ); Sleep( (clock_t) numero_seg * 1000L );}--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: func_time_sleep.cpp ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ---
  • 177. --- ------ ---******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ****** ARCHIVO: LOCAL_FUNCTIONS_PRECEDED_CALLS.h ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****---- FUNCIONES DECLARADAS INTERNAS ****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */ /* ----****----****---- FUNCIONES QUERY SQL ORACLE ****----****----**** */ int version_oracle(); int db_block_size (); char *db_object_type (); char *db_session_sid_locked (); char *db_object_owner_name (); int db_tablspace_ini_ext_size (); /* ----****----****---- FUNCIONES PRIMITIVAS ORACLE ****----****----**** */ int oracle_connect_original(); int oracle_connect_new(); int alloc_descriptors(); int set_bind_variables(); int process_select_list(); int liberar_memoria(); int cargar_sentencia (); sql_error();--- ---
  • 178. --- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: menu_orastat.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 func_dyn_title_set ();int mostrar_menu_orastat (int version, int opciones) {
  • 179. int nro_opcion=0; printf ("---------------------------------------------------n"); for ( nro_opcion=0; nro_opcion <= MAX_NRO_OPCION; nro_opcion++) { printf (".[%d]. [%s] n",func_dyn_title_set (version,nro_opcion)); } printf ("...................................................n"); return 0; }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: orasta1000.pc ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** */#include <oraca.h>
  • 180. #include <sqlca.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <setjmp.h>/* ----****----****----****----****----****----****----****----****----****----**** */#define MAX_ITEMS 512#define MAX_VNAME_LEN 512#define MAX_INAME_LEN 512#define MAX_BUFFER 512#define MAX_LINE 512#define MAX_STMT 16384#define MAX_BIND_VARIABLE 512#define MAX_VAR_SIZE 512#define MAX_VERSION_LEN 256#define MAX_LEN_ARG 512#define MAX_LEN_CONNECT 512#define SI_PROCESAR 1#define NO_PROCESAR 0#define SI_ERROR 1#define NO_ERROR 0#define SEPARADOR 124#define FIN_LINEA 0/* ----****----****----****----****----****----****----****----****----****----**** */#define VERSION_ORACLE_734 734#define VERSION_ORACLE_816 816#define VERSION_ORACLE_817 817#define VERSION_ORACLE_901 901#define VERSION_ORACLE_902 902#define VERSION_ORACLE_910 910#define VERSION_ORACLE_920 920#define VERSION_ORACLE_UNK 000
  • 181. /* ----****----****----****----****----****----****----****----****----****----**** */#define FUNC_DB_BLOCK_SIZE 1#define FUNC_COMMAND_SQL 2#define FUNC_LOCK_MODE 3#define FUNC_LOCK_NAME_MODE 4/* ----****----****----****----****----****----****----****----****----****----**** */#ifndef NULL#define NULL 0#endif/* ----****----****----****----****----****----****----****----****----****----**** */ char *dml_commands[] = {"SELECT", "select", "INSERT", "insert","UPDATE", "update", "DELETE", "delete"}; char dyn_size [MAX_VAR_SIZE]; char dyn_title [MAX_VAR_SIZE]; char dyn_column [MAX_VAR_SIZE]; char dyn_proc_func [MAX_VAR_SIZE]; EXEC SQL BEGIN DECLARE SECTION; char dyn_sts[16384]; EXEC SQL VAR dyn_sts IS STRING(16384); EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca; EXEC SQL INCLUDE sqlda; SQLDA *bind_dp; SQLDA *select_dp; jmp_buf jmp_continue; int parse_flag = 0;/* ----****----****----****----****----****----****----****----****----****----**** */ extern SQLDA *sqlald(); extern void sqlnul(); int version_oracle();
  • 182. int oracle_connect(); int alloc_descriptors(); int set_bind_variables(); int process_select_list(); int liberar_memoria(); int filtrar_char (); int col_size (); int cargar_sentencia (); int procesar_cadena (); int procesar_encabe (); int filtrar_char (); char *pasar_amayus (); sql_error(); void vaciar_estructura (); void vaciar_cadena (); int db_block_size (); int funcion_columna (); int procesar_columna_funcion (); char *decode_command_oracle (); char *decode_lock_mode (); char *decode_name_lock (); int ver_menu ();/* ----****----****----****----****----****----****----****----****----****----**** */main( int argc , char *argv[]) { int i=0; int opcion_nro=0; int version=0; char opcion_uno [MAX_LEN_ARG]; char opcion_dos [MAX_LEN_ARG]; char opcion_tres [MAX_LEN_ARG]; char datos_conexion [MAX_LEN_CONNECT]; opcion_uno[0]=FIN_LINEA; opcion_dos[0]=FIN_LINEA; opcion_tres[0]=FIN_LINEA; datos_conexion[0]=FIN_LINEA;
  • 183. if (argc <3 ) { printf ("Insuficientes argumentos n"); exit (1); }strcpy (datos_conexion,argv[1]);if (argc >= 3 ) opcion_nro=atoi(argv[2]);if (argc >= 4 ) strcpy (opcion_uno,pasar_amayus(argv[3]));if (argc >= 5 ) strcpy (opcion_dos,pasar_amayus(argv[4]));if (argc >= 6 ) strcpy (opcion_tres,argv[5]);if (oracle_connect(datos_conexion) != 0) { printf ("No es posible conectarse ...n"); exit(1); }version = version_oracle();printf ("Oracle Version [%d] n",version);if (alloc_descriptors(MAX_ITEMS,MAX_VNAME_LEN, MAX_INAME_LEN) != 0) exit(1);i = setjmp(jmp_continue);cargar_sentencia (version, opcion_nro, opcion_uno, opcion_dos, opcion_tres);EXEC SQL WHENEVER SQLERROR DO sql_error();parse_flag = 1;EXEC SQL PREPARE S FROM :dyn_sts;parse_flag = 0;EXEC SQL DECLARE C CURSOR FOR S;set_bind_variables();EXEC SQL OPEN C USING DESCRIPTOR bind_dp;process_select_list();liberar_memoria();return NO_ERROR;}
  • 184. /* ----****----****----****----****----****----****----****----****----****----**** */char *pasar_amayus (char *cadena ) { int pos=0; /* printf ("Iniciando conversion n"); */ for (pos =0; pos < (int ) strlen (cadena); pos ++) cadena[pos]=toupper(cadena[pos]); return cadena; }/* ----****----****----****----****----****----****----****----****----****----**** */liberar_memoria () { int i; for (i = 0; i < MAX_ITEMS; i++) { if (bind_dp->V[i] != (char *) 0) free(bind_dp->V[i]); free(bind_dp->I[i]); if (select_dp->V[i] != (char *) 0) free(select_dp->V[i]); free(select_dp->I[i]); } EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL CLOSE C; EXEC SQL COMMIT WORK RELEASE; EXEC SQL WHENEVER SQLERROR DO sql_error(); return SI_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */oracle_connect ( char *datos_conexion )
  • 185. { EXEC SQL BEGIN DECLARE SECTION; VARCHAR connectstring[256]; EXEC SQL END DECLARE SECTION; strcpy ((char *) connectstring.arr,datos_conexion); connectstring.arr[strlen((char *) connectstring.arr)] = FIN_LINEA; connectstring.len = (unsigned short )strlen((char *) connectstring.arr); EXEC SQL WHENEVER SQLERROR GOTO connect_error; printf ("nConnecting .....n"); EXEC SQL CONNECT :connectstring; printf("nConnected to ORACLE n"); return 0; connect_error: fprintf(stderr,"Cannot connect to ORACLEn"); return -1; }/* ----****----****----****----****----****----****----****----****----****----**** */alloc_descriptors(size, max_vname_len, max_iname_len) int size; int max_vname_len; int max_iname_len; { int i; if ((bind_dp = sqlald(size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; } if ((select_dp = sqlald (size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; }
  • 186. select_dp->N = MAX_ITEMS; for (i = 0; i < MAX_ITEMS; i++) { bind_dp->I[i] = (short *) malloc(sizeof (short)); select_dp->I[i] = (short *) malloc(sizeof(short)); bind_dp->V[i] = (char *) malloc(1); select_dp->V[i] = (char *) malloc(1); } return 0; }/* ----****----****----****----****----****----****----****----****----****----**** */set_bind_variables() { int i, n; char bind_var [MAX_BIND_VARIABLE]; EXEC SQL WHENEVER SQLERROR DO sql_error(); bind_dp->N = MAX_ITEMS; EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp; if (bind_dp->F < 0) { printf ("nToo many variables to bind...n", -bind_dp->F, MAX_ITEMS); return SI_ERROR; } bind_dp->N = bind_dp->F; for (i = 0; i < bind_dp->F; i++) { printf ("nEnter value for bind variable %.*s: ",(int)bind_dp->C[i], bind_dp->S[i]); fgets (bind_var, (int )sizeof(bind_var), stdin); n = (int )strlen(bind_var) - 1; bind_dp->L[i] = n; bind_dp->V[i] = (char *) realloc(bind_dp->V[i], (bind_dp->L[i] + 1)); strncpy(bind_dp->V[i], bind_var, n);
  • 187. if ((strncmp(bind_dp->V[i], "NULL", 4) == 0) || (strncmp(bind_dp->V[i], "null", 4) == 0)) *bind_dp->I[i] = -1; else *bind_dp->I[i] = 0; bind_dp->T[i] = 1; } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */process_select_list() { int null_ok; int nro_columna=0; int column_size=0; int si_proceso=0; int nro_bytes=0; int nro_funcion=0; if ((strncmp(dyn_sts, "SELECT", 6) != 0) && (strncmp(dyn_sts, "select", 6) != 0)) { select_dp->F = 0; return NO_ERROR; } select_dp->N = MAX_ITEMS; EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp; if (select_dp->F < 0) { printf ("nToo many select-list items (%d), maximum is %dn", -(select_dp->F), MAX_ITEMS); return SI_ERROR; } select_dp->N = select_dp->F; printf ("%s n",dyn_title); for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { sqlnul ( &(select_dp->T[nro_columna]), &(select_dp->T[nro_columna]), &null_ok); column_size=col_size(dyn_size,nro_columna);
  • 188. select_dp->L[nro_columna]= column_size; select_dp->C[nro_columna]= column_size; select_dp->T[nro_columna]=1; }for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { nro_bytes = sizeof (select_dp->V[nro_columna]); select_dp->V[nro_columna] = (char *) realloc(select_dp->V[nro_columna], select_dp->L[nro_columna]); printf ("["); column_size=col_size(dyn_size,nro_columna); procesar_encabe (column_size,nro_columna,dyn_column); printf ("] "); }printf ("n");EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop; for ( ; ; ) { /* Asegurandome que la estructura de Retorno este totalmente vacia */ vaciar_estructura ( select_dp ); /* Tomando una fila (ROW) de la base de datos */ EXEC SQL FETCH C USING DESCRIPTOR select_dp; /* Procesando las "i" columnas de datos de la fila retornada */ for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { printf (" "); /* ----------------------------------------------------------------------------- */ column_size=col_size(dyn_size,nro_columna); /* ----------------------------------------------------------------------------- */ si_proceso = procesar_columna_funcion (dyn_proc_func, nro_columna, &nro_funcion); if ( si_proceso == SI_PROCESAR) funcion_columna (column_size, (char *)select_dp->V[nro_columna], nro_funcion); /* ----------------------------------------------------------------------------- */ procesar_cadena (column_size,(char *)select_dp->V[nro_columna]); /* ----------------------------------------------------------------------------- */ printf (" "); } printf ("n"); }
  • 189. end_select_loop: return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */ver_menu (int opcion_menu ) { switch ( opcion_menu ) { case 0: strcpy (dyn_title,"Oracle Version ...n"); break; case 1: strcpy (dyn_title,"Active Parameters ...n"); break; case 2: strcpy (dyn_title,"User conected...n"); break; case 3: strcpy (dyn_title,"Wait Statistics...n"); break; case 4: strcpy (dyn_title,"Datafile I-O ...n"); break; case 5: strcpy (dyn_title,"Datafile Blocks R+W ...n"); break; case 6: strcpy (dyn_title,"Wait Events ...n"); break; case 7: strcpy (dyn_title,"Instance status ...n"); break; case 8: strcpy (dyn_title,"Temporal Space by user ...n"); break; case 9: strcpy (dyn_title,"Total Freelist Wait Percentage ...n"); break;
  • 190. case 10: strcpy (dyn_title,"Last Checkpoint Time ...n"); break;case 11: strcpy (dyn_title,"List Tablespaces ...n"); break;case 12: strcpy (dyn_title,"Active Transactions ...n"); break;case 13: strcpy (dyn_title,"Latch Details ...n"); break;case 14: strcpy (dyn_title,"Resource Limits ...n"); break;case 15: strcpy (dyn_title,"List Datafiles ...n"); break;case 16: strcpy (dyn_title,"List Datafiles New 9i ...n"); break;case 17: strcpy (dyn_title,"List Tablespaces New 9i...n"); break;case 18: strcpy (dyn_title,"Active Sessions ...n"); break;case 19: strcpy (dyn_title,"Session Waits n"); break;case 20: strcpy (dyn_title,"Default Storage Settings - By Tablespace n"); break;case 21: strcpy (dyn_title,"All tables Storage (Except SYS and SYSTEM) n"); break;case 22: strcpy (dyn_title,"Non-Sys Tables n"); break;case 23:
  • 191. strcpy (dyn_title,"Non-Sys Indexes n"); break;case 24: strcpy (dyn_title,"User Defined n"); break;case 25: strcpy (dyn_title,"List Datafiles, Online Redo Logs, Control Files n"); break;case 26: strcpy (dyn_title,"List Datafiles and their Used Blocks n"); break;case 27: strcpy (dyn_title,"List sorts by user n"); break;case 28: strcpy (dyn_title,"List lock status n"); break;case 29: strcpy (dyn_title,"List Users by CPU Usage n"); break;case 30: strcpy (dyn_title,"Sql statement by this user n"); break;case 31: strcpy (dyn_title,"Redo Logs - Status "); break;case 32: strcpy (dyn_title,"Archived Logs History - by first TimeStamp "); break;case 33: strcpy (dyn_title,"Redo Log Recovery Report - CURRENT Online Redo log info "); break;case 34: strcpy (dyn_title,"Archive Log History "); break;case 35: strcpy (dyn_title,"Session Latch Waits - SQL "); break;case 36: strcpy (dyn_title,"Whoami in Oracle ");
  • 192. break; case 37: strcpy (dyn_title,"Privileges by User "); break; case 38: strcpy (dyn_title,"Detailed locking causes "); break; case 39: strcpy (dyn_title,"Current Activity Report "); break; case 40: strcpy (dyn_title,"Table Description del Usuario [ %USERNAME% ]"); break; case 41: strcpy (dyn_title,"Current Activity Report "); break; default: strcpy (dyn_title,"Oracle Version ...n"); break; } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */cargar_sentencia (int version, int sentencia, char *opcion_uno, char *opcion_dos, char *opcion_tres ) { strcpy (dyn_proc_func,"|NO|"); switch (sentencia) { case 0: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|ORACLE_VERSION|"); strcpy (dyn_title,"Oracle Version ...n"); strcpy (dyn_sts,"select ltrim(lpad(banner,70)) Version from v$version "); strcat (dyn_sts,"where banner like %Oracle% "); strcpy (dyn_size,"80"); break; case 1: /********** PARA TODAS LAS VERSIONES **********/
  • 193. strcpy (dyn_column,"|NOMBRE|VALOR|DESCRIPCION|"); strcpy (dyn_title,"Active Parameters ...n"); strcpy (dyn_sts,"select name,value,description from v$parameter order by 1 "); strcpy (dyn_size,"355540"); break;case 2: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|DIRECCION|SES|NOMBRE|CMD|ESTADO|PID|TERMINAL|INICIADO|"); strcpy (dyn_title,"User conected...n"); strcpy (dyn_sts,"select saddr ADDRESS,sid SES,username NOMBRE,command CMD, n"); strcat (dyn_sts,"status ESTADO,process PID,terminal TERMINAL, n"); strcat (dyn_sts,"to_char(logon_time,DD/MM/YYYY - HH24:MI:SS) INICIADO from v$session "); strcpy (dyn_size,"0804150608151122"); break;case 3: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|CANTIDAD|TIEMPO|CLASE|"); strcpy (dyn_title,"Wait Statistics...n"); strcpy (dyn_sts,"select count CANTIDAD,time TIEMPO,class CLASE from v$waitstat order by 1 "); strcpy (dyn_size,"101030"); break;case 4: strcpy (dyn_title,"Datafile I-O ...n"); switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|READPHY|READBLK|WRITPHY||WRITBLK|DATAFILE|IO_STAT|"); 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 by 2 n"); strcpy (dyn_size,"080808086010"); break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: strcpy (dyn_column,"|READPHY|READBLK|WRITPHY|WRITBLK|DATAFILE|"); strcpy (dyn_sts,"select f.phyrds, f.phyblkrd, f.phywrts, "); strcat (dyn_sts,"f.phyblkwrt, d.name ");
  • 194. strcat (dyn_sts,"from v$filestat f,v$datafile d "); strcat (dyn_sts,"where f.file# = d.file# "); strcat (dyn_sts,"order by 2 n"); strcpy (dyn_size,"0606060660"); break; default: break; } break;case 5: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|DATAFILE|BLKREAD|BLKWRITE|BLKTOT|"); strcpy (dyn_title,"Datafile Blocks R+W ...n"); strcpy (dyn_sts,"select d.name DATAFILE, f.phyblkrd BLK_READ, f.phyblkwrt BLK_WRITE, n"); strcat (dyn_sts,"f.phyblkrd+f.phyblkwrt BLK_TOTAL from v$filestat f, v$datafile d n"); strcat (dyn_sts,"where f.file# = d.file# order by 3 desc "); strcpy (dyn_size,"60060606"); break;case 6: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|USUARIO|CANTIDAD|EVENTO|"); strcpy (dyn_title,"Wait Events ...n"); strcpy (dyn_sts,"select se.username USUARIO,count(*) CANTIDAD,sw.event EVENTO n"); strcat (dyn_sts,"from v$session se, v$session_wait sw where sw.sid=se.sid and n"); strcat (dyn_sts,"se.username > A and sw.event not like SQL*Net% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Table Q Normal% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Execution Msg% and n"); strcat (dyn_sts,"sw.event not like pipe get% group by se.username, sw.event "); strcpy (dyn_size,"201030"); break;case 7: strcpy (dyn_title,"Instance status ...n"); switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|INSTNRO|INSTNAME|HOSTNAME|VERSION|INICIADO|ESTADO|PARALELO|DATAESTA|INSTROLE|ACTSTATUS|"); strcpy (dyn_title,"Instance status ...n"); strcpy (dyn_sts,"select instance_number, instance_name, host_name, version, n");
  • 195. strcat (dyn_sts,"to_char(startup_time,DD/MM/YYYY - HH24:MI:SS),status, parallel, n"); strcat (dyn_sts,"database_status, instance_role n"); strcat (dyn_sts,"from v$instance n"); strcpy (dyn_size,"03080910220503101010"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|NOMBRE DE CLAVE|ESTADO|"); strcpy (dyn_title,"Instance status ...n"); strcpy (dyn_sts,"select RESTRITED MODE,value "); strcat (dyn_sts,"from v$instance where key=RESTRICTED MODE "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select SHUTDOWN PENDING,value "); strcat (dyn_sts,"from v$instance where key=SHUTDOWN PENDING "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select STARTUP TIME - JULIAN,value "); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - JULIAN "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select STARTUP TIME - SECONDS, value "); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - SECONDS n"); strcpy (dyn_size,"4015"); break; default: break; } break;case 8: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|SES|SERIAL|USER|EXTENTS|CONTENTS|SIZEKB"); strcpy (dyn_title,"Temporal Space by user ...n"); strcpy (dyn_sts,"select se.sid, se.serial#, se.username, so.extents, so.contents, n"); strcat (dyn_sts,"sum((so.blocks)*(select value 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 by se.sid,se.serial#,se.username,so.extents,so.contents n"); strcpy (dyn_size,"101010101030"); break;
  • 196. case VERSION_ORACLE_734: strcpy(dyn_column,"|TBLSPACE|EXTSIZE|CURUSER|TOTEXT|TOTBLK|USEXT|USEBLK|FREEXT|FREEBLK|MUSESIZE|MUSEBLK|MSORTSIZE|MSORTBLK|"); strcpy (dyn_title,"Temporal Space by user ...n"); 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_segment n"); strcpy (dyn_size,"0907070606050606080808080806"); default: break; } break; case 9: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|PCTFREE|"); strcpy (dyn_title,"Total Freelist Wait Percentage ...n"); strcpy (dyn_sts,"select (a.count/sum(b.value))*100 PCT_FREELIST from v$waitstat a, n"); strcat (dyn_sts,"v$sysstat b where a.class=free list and n"); strcat (dyn_sts,"b.name in (db block gets,consistent gets) group by a.count "); strcpy (dyn_size,"12"); break; case 10: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|CHEKPOINT_VALUE|FECHA|"); strcpy (dyn_title,"Last Checkpoint Time ...n"); 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 from v$datafile_header"); strcpy (dyn_size,"1522"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|CHEKPOINT_VALUE|FECHA|"); strcpy (dyn_title,"Last Checkpoint Time ...n"); strcpy (dyn_sts,"select count(sid) Cantidad from v$session n"); strcpy (dyn_size,"15"); break;
  • 197. default: break; } break;case 11: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|TBLSPACE|CONTENT|AVAILA_KB|MAX_ID|USED_KB|FREE_KB|PCT_USED|STATUS|MANAGMENT|ALLOCTYPE|"); strcpy (dyn_title,"List Tablespaces ...n"); strcpy (dyn_sts,"select a.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB, n"); strcat (dyn_sts,"a.max_id MAX_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 (select tablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id from dba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(select tablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group by tablespace_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 1 "); strcpy (dyn_size,"151010061010070810101010"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|TBLSPACE|CONTENT|AVAILA_KB|MAX_ID|USED_KB|FREE_KB|PCT_USED|STATUS|"); strcpy (dyn_title,"List Tablespaces ...n"); strcpy (dyn_sts,"select a.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB, n"); strcat (dyn_sts,"a.max_id MAX_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 (select tablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id from dba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(select tablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group by tablespace_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 1 "); strcpy (dyn_size,"151010061010070810101010"); break; }
  • 198. break;case 12: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ADDRESS|TIMESTART|ESTADO|BLK_USED|KB_USED|USED_UREC|SESSION|SERIAL|NOMBRE|USUARIO|"); strcpy (dyn_title,"Active Transactions ...n"); strcpy (dyn_sts,"select tr.addr,to_char(tr.start_time,DD/MM/YYYY - 24HH:MM:SS) TIME_START, n"); strcat (dyn_sts,"tr.status ESTADO,tr.used_ublk BLK_USED,tr.used_ublk*(select value n"); strcat (dyn_sts,"from v$parameter where name in db_block_size)/1000 KB_USED,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.saddr order by 6"); strcpy (dyn_size,"102208080810040605101010"); break; case VERSION_ORACLE_734: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0401|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ strcpy (dyn_column,"|ADDRESS|TIMESTART|ESTADO|BLK_USED|KB_USED|USED_UREC|SESSION|SERIAL|NOMBRE|USUARIO|"); strcpy (dyn_title,"Active Transactions ...n"); 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.status ESTADO,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.saddr order by 6"); strcpy (dyn_size,"082007080810070605101010"); break; } break;case 13: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|GETS|MISS|HITRATIO|IMM_GETS|IMM_MISS|SLEEP|GETSPIN|ADDRESS|LATCH|NOMBRE|"); strcpy (dyn_title,"Latch Details ...n");
  • 199. strcpy (dyn_sts,"select gets GETS,misses MISS,round((gets-misses)*100/gets,2) HITRATIO, n"); strcat (dyn_sts,"immediate_gets IMM_GETS,immediate_misses IMM_MISS,sleeps SLEEP, n"); strcat (dyn_sts,"spin_gets GETSPIN,addr ADDR,latch#,name NOMBRE from v$latch n"); strcat (dyn_sts,"where misses > 0 and gets > 0 order by round(((gets-misses)/gets),2) desc"); strcpy (dyn_size,"10040808080507080825"); break;case 14: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|NOMBRE|INIT_ALLOC|CURR_UTILIZA|MAX_UTILIZA|LIMITE|"); strcpy (dyn_title,"Resource Limits ...n"); strcpy (dyn_sts,"select resource_name NOMBRE,initial_allocation INIT_ALLOC, n"); strcat (dyn_sts,"current_utilization CURR_UTILIZA,max_utilization MAX_UTILIZA, n"); strcat (dyn_sts,"limit_value LIMITE from v$resource_limit order by 1"); strcpy (dyn_size,"3010101010"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|NOMBRE|LIMITE|"); strcpy (dyn_title,"Resource Limits ...n"); strcpy (dyn_sts,"select resource_name, limit n"); strcat (dyn_sts,"from user_resource_limits order by 1"); strcpy (dyn_size,"5010"); break; } break;case 15: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|DATAFILE|MBYTES|ESTADO|"); strcpy (dyn_title,"List Datafiles ...n"); strcpy (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n"); strcpy (dyn_size,"701008");
  • 200. break; case VERSION_ORACLE_734: strcpy (dyn_column,"|DATAFILE|MBYTES|ESTADO|"); strcpy (dyn_title,"List Datafiles ...n"); strcpy (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n");/* FALTARIA VER COMO HACEMOS PARA BUSCAR LA PARTE TEMPORAL EN VERSIONES 7.3.4 strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n");*/ strcpy (dyn_size,"701008"); break; } break; case 16: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ESTADO|DATAFILE|TBLSPACE|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Datafiles New 9i ...n"); 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_files d, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_space group by file_id) s n"); strcat (dyn_sts,"where s.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_files d, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"where t.file_id(+)=d.file_id and d.file_id=v.file# n"); strcpy (dyn_size,"066018121208"); break; case VERSION_ORACLE_734:
  • 201. strcpy (dyn_column,"|ESTADO|DATAFILE|TBLSPACE|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Datafiles New 9i ...n"); 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"); strcat (dyn_sts,"from sys.dba_data_files d, v$datafile v, (select file_id,sum(bytes) bytes n"); strcat (dyn_sts,"from sys.dba_free_space group by file_id) s n"); strcat (dyn_sts,"where s.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_files d, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"where t.file_id(+)=d.file_id and d.file_id=v.file# n");*/ strcpy (dyn_size,"066018121208"); break; } break; case 17: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|ESTADO|TBLSPACE|TIPO|EXTENT_MGM|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Tablespaces New 9i...n"); strcpy (dyn_sts,"select d.status ESTADO, d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat (dyn_sts,"d.extent_management EXTENT_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,"from sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_space group by tablespace_name ) f n"); strcat (dyn_sts,"where d.tablespace_name=a.tablespace_name(+) and n"); strcat (dyn_sts,"d.tablespace_name = f.tablespace_name(+) and n");
  • 202. 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_management EXTENT_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 from sys.dba_tablespaces d, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group by tablespace_name) t where d.tablespace_name=a.tablespace_name (+) and n"); strcat (dyn_sts,"d.tablespace_name=t.tablespace_name (+) and d.extent_management like LOCAL and n"); strcat (dyn_sts,"d.contents like TEMPORARY "); strcpy (dyn_size,"06251012121212121212121010101010"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|ESTADO|TBLSPACE|TIPO|EXTENT_MGM|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Tablespaces New 9i...n"); 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,"from sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_space group by tablespace_name ) f n"); strcat (dyn_sts,"where d.tablespace_name=a.tablespace_name(+) and n"); strcat (dyn_sts,"d.tablespace_name = f.tablespace_name(+) and n"); strcat (dyn_sts,"not 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,"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 from sys.dba_tablespaces d, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group by tablespace_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 like TEMPORARY ");
  • 203. */ strcpy (dyn_size,"06251012121212121212121010101010"); break; } break;case 18: strcpy (dyn_column,"|SES|SERIAL|TIPO|OS_USER|LOGON|ESTADO|PROCESO|MAQUINA|NOMBRE|PID|PROGRAMA|"); strcpy (dyn_title,"Active Sessions ...n"); 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.program PROGRAMA n"); strcat (dyn_sts,"from v$session s, v$process p n"); strcat (dyn_sts,"where osuser is not null and p.addr=s.paddr n"); strcpy (dyn_size,"0404101022100915100930"); break;case 19: strcpy (dyn_column,"|SES|SEQ|W_T|S_W_T|USUARIO|ESTADO|EVENT|STATE|P1TEXT|P1|P1RAW|P2TEXT|P2|P2RAW|P3TEXT|P3|P3RAW|"); strcpy (dyn_title,"Session Waits n"); 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 se n"); strcat (dyn_sts,"where sw.sid = se.sid order by 2 n"); strcpy (dyn_size,"0404050506062020101010101010101010101010101010"); break;case 20: strcpy (dyn_column,"|TBLSPACE|INI_EXT|NEX_EXT|MIN_EXT|MAX_EXT|PCT_INC|"); strcpy (dyn_title,"Default Storage Settings - By Tablespace n"); strcpy (dyn_sts,"select tablespace_name TBLNAME, initial_extent INI_EXT, next_extent NEX_EXT, n"); strcat (dyn_sts,"min_extents MIN_EXT, max_extents MAX_EXT, pct_increase PCT_INC n"); strcat (dyn_sts,"from dba_tablespaces n"); strcat (dyn_sts,"order by tablespace_name n"); strcpy (dyn_size,"201212121207"); break;case 21: strcpy (dyn_column,"|OWNER_TABLE|SEG_NAME|TBLSPACE|BLOCKS|SIZE_KB|MAX_EXT|"); strcpy (dyn_title,"All tables Storage (Except SYS and SYSTEM) n"); strcpy (dyn_sts,"select owner OWNER_TABLE,segment_name SEG_NAME,tablespace_name TBL_NAME, blocks BLKS, n");
  • 204. strcat (dyn_sts,"(select value from v$parameter where name in db_block_size)*blocks/1024 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,2 n"); strcpy (dyn_size,"12402005060510"); break;case 22: strcpy (dyn_column,"|OWNER|TABLNAME|TBLSPACE|BLOCK|NROWS|BUFF_POOL|LAST_ANALIZE|SIZE_KB"); strcpy (dyn_title,"Non-Sys Tables n"); 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) * (select value from v$parameter where name in (db_block_size)))/1000 n"); strcat (dyn_sts,"from dba_tables n"); strcat (dyn_sts,"group by owner,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"); strcpy (dyn_size,"1225200808101808"); break;case 23: strcpy (dyn_column,"|OWNER|INDEXNAME|TBLSPACE|LEAFBLK|NROROWS|BUFFPOOL|LASTANALIZ|SIZE_KB|"); strcpy (dyn_title,"Non-Sys Indexes n"); strcpy (dyn_sts,"select owner,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) * (select value from v$parameter n"); strcat (dyn_sts,"where name in (db_block_size)))/1000 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"); strcpy (dyn_size,"1225200808101808"); break;case 24: strcpy (dyn_column,"|USUA|ACCSTAT|EXPIRYDATE|DFLTBLNAME|TMPTBLNAME|PROFILE|CREATED|"); strcpy (dyn_title,"User Defined n"); strcpy (dyn_sts,"select * from (select distinct 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), , , , to_char(to_date(null), n");
  • 205. strcat (dyn_sts,"DD/MM/YYYY - HH24:MI) from dual) n"); strcat (dyn_sts,"order by initcap(username) n"); strcpy (dyn_size,"25090820203018101010"); break;case 25: strcpy (dyn_column,"|FILENAME|TBLSPACE|ESTADO|"); strcpy (dyn_title,"List Datafiles, Online Redo Logs, Control Files n"); 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 from v$logfile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name, CONTROL FILE, status from v$controlfile n"); strcat (dyn_sts,"order by 1,2 n"); strcpy (dyn_size,"702010"); break;case 26: strcpy (dyn_column,"|TBLSPACE|FILENAME|BYTES|HIGHWATER|"); strcpy (dyn_title,"List Datafiles and their Used Blocks n"); 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) maximum n"); 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 from v$parameter where name=db_block_size) d n"); strcat (dyn_sts,"where a.file_id = b.file_id n"); 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.tablespace_name, a.file_name n"); strcpy (dyn_size,"256012121212"); break;case 27: strcpy (dyn_column,"|VALOR|TYPESORT|OS_USER|DB_USER|"); strcpy (dyn_title,"List sorts by user n"); strcpy (dyn_sts,"select vss.value VALOR, substr(vsn.name,1,20) TYPE_SORT, 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");
  • 206. 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"); strcpy (dyn_size,"141820251010"); break; case 28: strcpy (dyn_column,"|ADDRESS|KADDRESS|SES|TIPO|OBJ_ID|ID2|LOCKTY|REQT|"); strcpy (dyn_title,"List lock status n"); strcpy (dyn_sts,"select lo.addr, lo.kaddr, lo.sid SES, lo.type TIP, lo.id1 OBJID, lo.id2, n"); strcat (dyn_sts,"decode(lo.lmode,0,None,1,Null,2,Row-S (ss),3,Row-X (sx),4,Share,5,S/Row-X (ssx),6,Exclu )LOCTYP, n"); strcat (dyn_sts,"lo.request REQT, n"); strcat (dyn_sts,"(select ltrim(object_type) n"); strcat (dyn_sts,"from all_objects where object_id=lo.id1) OBJ_TYP, n"); strcat (dyn_sts,"(select ltrim(owner)||.||ltrim(object_name) n"); strcat (dyn_sts,"from all_objects where object_id=lo.id1) OWN_OBJ, n"); strcat (dyn_sts,"(select sid SES n"); strcat (dyn_sts,"from v$session where lockwait=lo.kaddr) LOC_SID n"); strcat (dyn_sts,"from v$lock lo n"); strcat (dyn_sts,"order by lo.id1, lo.lmode desc n"); strcpy (dyn_size,"0909050405041105083509"); break; case 29: strcpy (dyn_column,"|SES|SERIAL|TYPE|OSUSER|LOGON|PROCESS|MACHINE|USER|VALUE|PROGRAM|"); strcpy (dyn_title,"List Users by CPU Usage n"); strcpy (dyn_sts,"select vs.sid, vs.serial#, vs.type, vs.osuser, n"); 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 session n"); strcat (dyn_sts,"and vss.value <> 0 n"); strcat (dyn_sts,"order by 10 n"); strcpy (dyn_size,"10101010101010101010101010101010101010101010"); break; case 30: strcpy (dyn_column,"|TEXT_SQL|"); strcpy (dyn_title,"Sql statement by this user n");
  • 207. strcpy (dyn_sts,"select sql_text n"); strcat (dyn_sts,"from v$sqltext n"); strcat (dyn_sts,"where address = ( select sql_address n"); strcat (dyn_sts,"from v$session n"); strcat (dyn_sts,"where sid="); strcat (dyn_sts,opcion_uno); strcat (dyn_sts,") order by piece n"); strcpy (dyn_size,"70"); break;case 31: strcpy (dyn_column,"|GRUPO|THREAD|SEQUENCE|BYTES|MEMBER|ARCHIVED|ESTADO|FSTCHANGE|FSTTIME|"); strcpy (dyn_title,"Redo Logs - Status "); 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"); strcpy (dyn_size,"070710101010101220"); break;case 32: strcpy (dyn_column,"|THREAD|SEQUENCE|NAME|FSTCHANGE|FSTTIME|BLOCKS|BLKSIZE|COMPTIME|"); strcpy (dyn_title,"Archived Logs History - by first TimeStamp "); 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_log order by 6 n"); strcpy (dyn_size,"1010101020101020101020"); break;case 33: strcpy (dyn_column,"|GROUP|FSTCHANGE|MEMBER|SEQUENCE|"); strcpy (dyn_title,"Redo Log Recovery Report - CURRENT Online Redo log info "); 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"); strcpy (dyn_size,"06125208"); break;case 34: strcpy (dyn_column,"|THREAD|SEQUENCE|FSTCHANGE|SWICHANGE|FSTTIME|"); strcpy (dyn_title,"Archive Log History ");
  • 208. 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"); strcpy (dyn_size,"0810171722"); break;case 35: strcpy (dyn_column,"|SES|USER|STATUS|SQLTEXT|"); strcpy (dyn_title,"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 and n"); strcat (dyn_sts,"sw.event = latch_free n"); strcat (dyn_sts,"order by 1 n"); strcpy (dyn_size,"0530303030"); break;case 36: strcpy (dyn_column,"|SES|USER|STATUS|SQLTEXT|"); strcpy (dyn_title,"Whoami in Oracle "); strcpy (dyn_sts,"select substr(v2.sid,1,5), substr(v2.username,1,8), 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 and n"); strcat (dyn_sts,"v1.hash_value = v2.sql_hash_value n"); strcpy (dyn_size,"10202030"); break;case 37: strcpy (dyn_column,"|fadsdf|asdfasd|"); strcpy (dyn_title,"Privileges by User "); strcpy (dyn_sts,"select decode (sa1.grantee#1, 1, PUBLIC, u1.name), n"); strcat (dyn_sts,"substr (u2.name,1,20), substr(spm.name,1,27) n"); strcat (dyn_sts,"from sys.sysauth$ sa1, sys.sysauth# sa2, sys.user$ u1, n"); strcat (dyn_sts,"sys.user$ u2, sys.system_privilege_map spm n"); strcat (dyn_sts,"where sa1.grantee# = u1.user# and n"); strcat (dyn_sts,"sa1.privilege# = u2.user# and n");
  • 209. 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,27) 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"); strcpy (dyn_size,"1010101010101010"); break; case 38: /* FORMATO |<SI PROCESO>|<NRO COLUMNA -1><NRO FUNCION>| */ /* LAS COLUMNAS EMPIEZAN A ENUMERARSE A PARTIR DE LA CERO (0) */ strcpy (dyn_proc_func,"|SI|0402|0503|0603|0804|"); /* PROCESANDO ESTA PARTE DEL NUEVO SELECT */ strcpy (dyn_column,"|USERNAME|SID|TERMINAL|TAB|COMMAND|LMODE|REQUEST|LADDR|LOCKT|LOCKTYPE|"); strcpy (dyn_title,"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 || - ||, n"); strcat (dyn_sts,"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,2,5"); strcpy (dyn_size,"101010101010101020"); break; case 39: strcpy (dyn_column,"|VALOR|NOMBRE|"); strcpy (dyn_title,"Current Activity Report "); strcpy (dyn_sts,"select name,value from v$sysstat n"); strcat (dyn_sts,"where name like %user%; n"); strcpy (dyn_size,"2512"); break; case 40: strcpy (dyn_column,"|TBLSPACE|TABLENAME|NROWS|LASTANALIZED|INIEXT|NEXEXT|MINEXT|MAXEXT|PCTINC|BUFPOL|BLOCKS|FREELST|PCTFREE|INITRANS|MAXTRANS|FREEGRP");
  • 210. strcpy (dyn_title,"Table Description del Usuario [ "); strcat (dyn_title,opcion_uno); strcat (dyn_title," ] "); strcpy (dyn_sts,"select tablespace_name, 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"); strcat (dyn_sts,"where owner = "); strcat (dyn_sts,opcion_uno); strcat (dyn_sts," "); if ( strlen (opcion_dos) > 0 ) { strcat (dyn_sts,"and table_name = "); strcat (dyn_sts,opcion_dos); strcat (dyn_sts," n"); } else strcat (dyn_sts,"n"); strcpy (dyn_size,"15300719050505050508060606060606"); break;case 41: strcpy (dyn_column,"|DIRECCION|BUF_GETS|NRO_EXEC|AVG_EXEC|SQL_TEXT|"); strcpy (dyn_title,"Current Activity Report by Select Statements"); strcat (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 4 desc, 3 desc n"); strcpy (dyn_size,"0909080999"); break;default: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|ORACLE_VERSION|"); strcpy (dyn_title,"Oracle Version ...n"); strcpy (dyn_sts,"select ltrim(lpad(banner,70)) Version from v$version "); strcpy (dyn_size,"80"); break;
  • 211. } /********************************************************//* printf ("Statement [%s] n",dyn_sts); */ /********************************************************//* printf ("Funcion [%s] n",dyn_proc_func); */ /********************************************************/ if (strlen (dyn_sts) >= MAX_STMT) printf ("Max Statement large [%d] | Actual Statement large [%d] n",MAX_STMT,strlen(dyn_sts)); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */sql_error() { /* int i; */ printf ("nn%.70sn",sqlca.sqlerrm.sqlerrmc); if (parse_flag) printf("n Error de Oracle... n",sqlca.sqlerrd[4]); EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK WORK; liberar_memoria(); exit(1); }/* ----****----****----****----****----****----****----****----****----****----**** */col_size (char *puntero, int posicion) { char ascii_nro[3]; int numero, i; for ( i = posicion*2; i < posicion*2+2; i++) ascii_nro[i-posicion*2]=puntero[i]; ascii_nro[2]=FIN_LINEA; numero=atoi(ascii_nro); return numero; }
  • 212. /* ----****----****----****----****----****----****----****----****----****----**** */int filtrar_char (int caracter) { if ( (caracter >= 32 && caracter <= 127 ) ) return caracter; else { switch (caracter) { case 164: break; case 165: break; case 168: break; case 173: break; default: caracter=32;break; } } return caracter; }/* ----****----****----****----****----****----****----****----****----****----**** */procesar_cadena (int nrocolum, char *puntero_char) { int pos, caracter; for ( pos=0; pos < nrocolum; pos++ ) { caracter=filtrar_char(puntero_char[pos]); printf ("%c",caracter); } fflush(stdout); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */procesar_encabe (int tamano, int posicion, char *puntero_char) { int pos_col=0;
  • 213. int pos_cad=0; int columna=-1; int caracter=0; int salto=0; for ( pos_col = 0; pos_col < (int )strlen(puntero_char); pos_col ++) { if ( puntero_char[pos_col] == SEPARADOR ) columna++; if ( columna == posicion ) break; } for ( pos_cad = pos_col+1; pos_cad < tamano+pos_col+1; pos_cad++ ) { if ( puntero_char[pos_cad]==SEPARADOR) salto++; if (salto==0) { caracter = filtrar_char ( puntero_char[pos_cad] ); printf ("%c",caracter); } else printf (" "); } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_estructura ( void *punt_sqlda ) { int pos_k, pos_j; int limite_k = ((SQLDA *) punt_sqlda ) ->F; int limite_j; for ( pos_k = 0; pos_k < limite_k ; pos_k++ ) { limite_j = ((SQLDA *) punt_sqlda ) ->L[ pos_k ]; for ( pos_j = 0; pos_j < limite_j ; pos_j++) (char ) (((SQLDA *) punt_sqlda )->V[pos_k])[pos_j] = FIN_LINEA; } }/* ----****----****----****----****----****----****----****----****----****----**** */
  • 214. void vaciar_cadena (void *punt_cadena, int largo) { int pos; for (pos = 0; pos < largo; pos ++) ((char *) punt_cadena ) [pos] = FIN_LINEA; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int version_oracle () { char Version[10]; int conta=0; int pos=0; int caracter=0; int nro_puntos=0; EXEC SQL BEGIN DECLARE SECTION; VARCHAR version [256]; EXEC SQL END DECLARE SECTION; vaciar_cadena (version.arr,MAX_VERSION_LEN); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT ltrim(lpad(banner,70)) INTO :version FROM V$VERSION WHERE banner like %Oracle%; break; /* SOLO ME INTERESA UN REGISTRO */ } for ( pos =0; pos < version.len; pos ++) { caracter = version.arr[pos]; Version[conta]=FIN_LINEA; if ( nro_puntos < 3 )
  • 215. { switch (caracter) { case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: Version[conta]=caracter; conta++; Version[conta]=FIN_LINEA; break; case 46: /* Version[conta]=caracter; conta++; */ nro_puntos++; Version[conta]=FIN_LINEA; break; default: conta=0; } } } return (atoi (Version)); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int db_block_size () { int block_size=0; EXEC SQL BEGIN DECLARE SECTION; VARCHAR data_block_size [20];
  • 216. EXEC SQL END DECLARE SECTION; vaciar_cadena (data_block_size.arr,20); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT value INTO :data_block_size FROM V$PARAMETER WHERE NAME IN (db_block_size); break; /* SOLO ME INTERESA UN REGISTRO */ } block_size = atoi (data_block_size.arr); return (block_size); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *decode_command_oracle (int nro_decodificar) { static char dato_1[64]; vaciar_cadena (dato_1,64); switch (nro_decodificar) { case 0: strcpy (dato_1,"BACKGROUND"); break; case 1: strcpy (dato_1,"CREATE TABLE"); break; case 2: strcpy (dato_1,"INSERT"); break; case 3: strcpy (dato_1,"SELECT"); break; case 4: strcpy (dato_1,"CREATE CLUSTER"); break; case 5: strcpy (dato_1,"ALTER CLUSTER"); break; case 6: strcpy (dato_1,"UPDATE"); break; case 7: strcpy (dato_1,"DELETE"); break; case 8: strcpy (dato_1,"DROP"); break; case 9: strcpy (dato_1,"CREATE INDEX"); break; case 10: strcpy (dato_1,"DROP INDEX"); break; case 11: strcpy (dato_1,"ALTER INDEX"); break; case 12: strcpy (dato_1,"DROP TABLE"); break;
  • 217. case 13: strcpy (dato_1,"CREATE SEQUENCE"); break;case 14: strcpy (dato_1,"ALTER SEQUENCE"); break;case 15: strcpy (dato_1,"ALTER TABLE"); break;case 16: strcpy (dato_1,"DROP SEQUENCE"); break;case 17: strcpy (dato_1,"GRANT"); break;case 18: strcpy (dato_1,"REVOKE"); break;case 19: strcpy (dato_1,"CREATE SYNONYM"); break;case 20: strcpy (dato_1,"DROP SYNONYM"); break;case 21: strcpy (dato_1,"CREATE VIEW"); break;case 22: strcpy (dato_1,"DROP VIEW"); break;case 23: strcpy (dato_1,"VALIDATE INDEX"); break;case 24: strcpy (dato_1,"CREATE PROCEDURE"); break;case 25: strcpy (dato_1,"ALTER PROCEDURE"); break;case 26: strcpy (dato_1,"LOCK TABLE"); break;case 27: strcpy (dato_1,"NO OPERATION"); break;case 28: strcpy (dato_1,"RENAME"); break;case 29: strcpy (dato_1,"COMMENT"); break;case 30: strcpy (dato_1,"AUDIT"); break;case 31: strcpy (dato_1,"NOAUDIT"); break;case 32: strcpy (dato_1,"CREATE EXTERNAL DATABASE"); break;case 33: strcpy (dato_1,"DROP EXTERNAL DATABASE"); break;case 34: strcpy (dato_1,"CREATE DATABASE"); break;case 35: strcpy (dato_1,"ALTER DATABASE"); break;case 36: strcpy (dato_1,"CREATE ROLLBACK SEGMENT"); break;case 37: strcpy (dato_1,"ALTER ROLLBACK SEGMENT"); break;case 38: strcpy (dato_1,"DROP ROLLBACK SEGMENT"); break;case 39: strcpy (dato_1,"CREATE TABLESPACE"); break;case 40: strcpy (dato_1,"ALTER TABLESPACE"); break;case 41: strcpy (dato_1,"DROP TABLESPACE"); break;case 42: strcpy (dato_1,"ALTER SESSION"); break;case 43: strcpy (dato_1,"ALTER USER"); break;case 44: strcpy (dato_1,"COMMIT"); break;case 45: strcpy (dato_1,"ROLLBACK"); break;case 46: strcpy (dato_1,"SAVEPOINT"); break;case 47: strcpy (dato_1,"PL/SQL EXECUTE"); break;case 48: strcpy (dato_1,"SET TRANSACTION"); break;case 49: strcpy (dato_1,"ALTER SYSTEM SWITCH LOG"); break;case 50: strcpy (dato_1,"EXPLAIN"); break;case 51: strcpy (dato_1,"CREATE USER"); break;case 52: strcpy (dato_1,"CREATE ROLE"); break;
  • 218. case 53: strcpy (dato_1,"DROP USER"); break; case 54: strcpy (dato_1,"DROP ROLE"); break; case 55: strcpy (dato_1,"SET ROLE"); break; case 56: strcpy (dato_1,"CREATE SCHEMA"); break; case 57: strcpy (dato_1,"CREATE CONTROL FILE"); break; case 58: strcpy (dato_1,"ALTER TRACING"); break; case 59: strcpy (dato_1,"CREATE TRIGGER"); break; case 60: strcpy (dato_1,"ALTER TRIGGER"); break; case 61: strcpy (dato_1,"DROP TRIGGER"); break; case 62: strcpy (dato_1,"ANALYZE TABLE"); break; case 63: strcpy (dato_1,"ANALYZE INDEX"); break; case 64: strcpy (dato_1,"ANALYZE CLUSTER"); break; case 65: strcpy (dato_1,"CREATE PROFILE"); break; case 66: strcpy (dato_1,"DROP PROFILE"); break; case 67: strcpy (dato_1,"ALTER PROFILE"); break; case 68: strcpy (dato_1,"DROP PROCEDURE"); break; case 69: strcpy (dato_1,"DROP PROCEDURE"); break; case 70: strcpy (dato_1,"ALTER RESOURCE COST"); break; case 71: strcpy (dato_1,"CREATE SNAPSHOT LOG"); break; case 72: strcpy (dato_1,"ALTER SNAPSHOT LOG"); break; case 73: strcpy (dato_1,"DROP SNAPSHOT LOG"); break; case 74: strcpy (dato_1,"CREATE SNAPSHOT"); break; case 75: strcpy (dato_1,"ALTER SNAPSHOT"); break; case 76: strcpy (dato_1,"DROP SNAPSHOT"); break; case 79: strcpy (dato_1,"ALTER ROLE"); break; case 85: strcpy (dato_1,"TRUNCATE TABLE"); break; case 86: strcpy (dato_1,"TRUNCATE CLUSTER"); break;/* case 87: strcpy (dato_1,"-"); break; */ case 88: strcpy (dato_1,"ALTER VIEW"); break;/* case 89: strcpy (dato_1,"-"); break; *//* case 90: strcpy (dato_1,"-"); break; */ case 91: strcpy (dato_1,"CREATE FUNCTION"); break; case 92: strcpy (dato_1,"ALTER FUNCTION"); break; case 93: strcpy (dato_1,"DROP FUNCTION"); break; case 94: strcpy (dato_1,"CREATE PACKAGE"); break; case 95: strcpy (dato_1,"ALTER PACKAGE"); break; case 96: strcpy (dato_1,"DROP PACKAGE"); break; case 97: strcpy (dato_1,"CREATE PACKAGE BODY"); break; case 98: strcpy (dato_1,"ALTER PACKAGE BODY"); break; case 99: strcpy (dato_1,"DROP PACKAGE BODY"); break;
  • 219. default: strcpy (dato_1,"-"); break; } return dato_1; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *decode_lock_mode (int nro_decodificar) { static char dato_1[64]; vaciar_cadena (dato_1,64); switch (nro_decodificar) { case 1: strcpy (dato_1,"No Lock"); break; case 2: strcpy (dato_1,"Row Share"); break; case 3: strcpy (dato_1,"Row Exclusive"); break; case 4: strcpy (dato_1,"Share"); break; case 5: strcpy (dato_1,"Share Row Exclusive"); break; case 6: strcpy (dato_1,"Exclusive"); break; default: strcpy (dato_1,"NONE"); break; } return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *decode_name_lock (char *cad_decodificar) { static char dato_1[256]; vaciar_cadena (dato_1,256); if ( strncmp (cad_decodificar,"BL",2) == 0) strcpy (dato_1,"Buffer hash table instance lock"); else if ( strncmp (cad_decodificar,"CF",2) == 0) strcpy (dato_1," Control file schema global enqueue lock"); else if ( strncmp (cad_decodificar,"CI",2) == 0) strcpy (dato_1,"Cross-instance function invocation instance lock"); else
  • 220. if ( strncmp (cad_decodificar,"CS",2) == 0) strcpy (dato_1,"Control file schema global enqueue lock"); elseif ( strncmp (cad_decodificar,"CU",2) == 0) strcpy (dato_1,"Cursor bind lock"); elseif ( strncmp (cad_decodificar,"DF",2) == 0) strcpy (dato_1,"Data file instance lock"); elseif ( strncmp (cad_decodificar,"DL",2) == 0) strcpy (dato_1,"Direct loader parallel index create"); elseif ( strncmp (cad_decodificar,"DM",2) == 0) strcpy (dato_1,"Mount/startup db primary/secondary instance lock"); elseif ( strncmp (cad_decodificar,"DR",2) == 0) strcpy (dato_1,"Distributed recovery process lock"); elseif ( strncmp (cad_decodificar,"DX",2) == 0) strcpy (dato_1,"Distributed transaction entry lock"); elseif ( strncmp (cad_decodificar,"FI",2) == 0) strcpy (dato_1,"SGA open-file information lock"); elseif ( strncmp (cad_decodificar,"FS",2) == 0) strcpy (dato_1,"File set lock"); elseif ( strncmp (cad_decodificar,"HW",2) == 0) strcpy (dato_1,"Space management operations on a specific segment lock"); elseif ( strncmp (cad_decodificar,"IN",2) == 0) strcpy (dato_1,"Instance number lock"); elseif ( strncmp (cad_decodificar,"IR",2) == 0) strcpy (dato_1,"Instance recovery serialization global enqueue lock"); elseif ( strncmp (cad_decodificar,"IS",2) == 0) strcpy (dato_1,"Instance state lock"); elseif ( strncmp (cad_decodificar,"IV",2) == 0) strcpy (dato_1,"Library cache invalidation instance lock"); elseif ( strncmp (cad_decodificar,"JQ",2) == 0) strcpy (dato_1,"Job queue lock"); elseif ( strncmp (cad_decodificar,"KK",2) == 0) strcpy (dato_1,"Thread kick lock"); elseif ( strncmp (cad_decodificar,"MB",2) == 0) strcpy (dato_1,"Master buffer hash table instance lock"); elseif ( strncmp (cad_decodificar,"MM",2) == 0) strcpy (dato_1,"Mount definition gloabal enqueue lock"); elseif ( strncmp (cad_decodificar,"MR",2) == 0) strcpy (dato_1,"Media recovery lock"); elseif ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Password file lock"); elseif ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Process startup lock"); elseif ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Parallel operation lock"); elseif ( strncmp (cad_decodificar,"RE",2) == 0) strcpy (dato_1,"USE_ROW_ENQUEUE enforcement lock"); elseif ( strncmp (cad_decodificar,"RT",2) == 0) strcpy (dato_1,"Redo thread global enqueue lock"); elseif ( strncmp (cad_decodificar,"RW",2) == 0) strcpy (dato_1,"Row wait enqueue lock"); elseif ( strncmp (cad_decodificar,"SC",2) == 0) strcpy (dato_1,"System commit number instance lock"); elseif ( strncmp (cad_decodificar,"SH",2) == 0) strcpy (dato_1,"System commit number high water mark enqueue lock"); elseif ( strncmp (cad_decodificar,"SM",2) == 0) strcpy (dato_1,"SMON lock"); elseif ( strncmp (cad_decodificar,"SN",2) == 0) strcpy (dato_1,"Sequence number instance lock"); elseif ( strncmp (cad_decodificar,"SQ",2) == 0) strcpy (dato_1,"Sequence number enqueue lock"); elseif ( strncmp (cad_decodificar,"SS",2) == 0) strcpy (dato_1,"Sort segment lock"); elseif ( strncmp (cad_decodificar,"ST",2) == 0) strcpy (dato_1,"Space transaction enqueue lock"); elseif ( strncmp (cad_decodificar,"SV",2) == 0) strcpy (dato_1,"Sequence number value lock"); elseif ( strncmp (cad_decodificar,"TA",2) == 0) strcpy (dato_1,"Generic enqueue lock"); elseif ( strncmp (cad_decodificar,"TD",2) == 0) strcpy (dato_1,"DDL enqueue lock"); elseif ( strncmp (cad_decodificar,"TE",2) == 0) strcpy (dato_1,"Extend-segment enqueue lock"); elseif ( strncmp (cad_decodificar,"TM",2) == 0) strcpy (dato_1,"DML enqueue lock"); elseif ( strncmp (cad_decodificar,"TT",2) == 0) strcpy (dato_1,"Temporary table enqueue lock"); elseif ( strncmp (cad_decodificar,"TX",2) == 0) strcpy (dato_1,"Transaction enqueue lock"); else
  • 221. if ( strncmp (cad_decodificar,"UL",2) == 0) strcpy (dato_1,"User supplied lock"); else if ( strncmp (cad_decodificar,"UN",2) == 0) strcpy (dato_1,"User name lock"); else if ( strncmp (cad_decodificar,"US",2) == 0) strcpy (dato_1,"Undo segment DDL lock"); else if ( strncmp (cad_decodificar,"WL",2) == 0) strcpy (dato_1,"Being-written redo log instance lock"); else if ( strncmp (cad_decodificar,"WS",2) == 0) strcpy (dato_1,"Write-atomic-log-switch global enqueue lock"); else if ( strncmp (cad_decodificar,"TS",2) == 0) strcpy (dato_1,"Temporary segment enqueue lock (ID2=0) New block allocation enqueue lock(ID2=1)"); else if ( strncmp (cad_decodificar,"LA",2) == 0) strcpy (dato_1,"Library cache lock instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"LB",2) == 0) strcpy (dato_1,"Library cache lock instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"LC",2) == 0) strcpy (dato_1,"Library cache lock instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"LD",2) == 0) strcpy (dato_1,"Library cache lock instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"LE",2) == 0) strcpy (dato_1,"Library cache lock instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"LF",2) == 0) strcpy (dato_1,"Library cache lock instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"LG",2) == 0) strcpy (dato_1,"Library cache lock instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"LH",2) == 0) strcpy (dato_1,"Library cache lock instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"LI",2) == 0) strcpy (dato_1,"Library cache lock instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"LJ",2) == 0) strcpy (dato_1,"Library cache lock instance lock (J=namespace)"); else if ( strncmp (cad_decodificar,"LK",2) == 0) strcpy (dato_1,"Library cache lock instance lock (K=namespace)"); else if ( strncmp (cad_decodificar,"LL",2) == 0) strcpy (dato_1,"Library cache lock instance lock (L=namespace)"); else if ( strncmp (cad_decodificar,"LM",2) == 0) strcpy (dato_1,"Library cache lock instance lock (M=namespace)"); else if ( strncmp (cad_decodificar,"LN",2) == 0) strcpy (dato_1,"Library cache lock instance lock (N=namespace)"); else if ( strncmp (cad_decodificar,"LO",2) == 0) strcpy (dato_1,"Library cache lock instance lock (O=namespace)"); else if ( strncmp (cad_decodificar,"LP",2) == 0) strcpy (dato_1,"Library cache lock instance lock (P=namespace)"); else if ( strncmp (cad_decodificar,"LS",2) == 0) strcpy (dato_1,"Log start/log switch enqueue lock"); else if ( strncmp (cad_decodificar,"PA",2) == 0) strcpy (dato_1,"Library cache pin instance lock (A=namespace)"); else if ( strncmp (cad_decodificar,"PB",2) == 0) strcpy (dato_1,"Library cache pin instance lock (B=namespace)"); else if ( strncmp (cad_decodificar,"PC",2) == 0) strcpy (dato_1,"Library cache pin instance lock (C=namespace)"); else if ( strncmp (cad_decodificar,"PD",2) == 0) strcpy (dato_1,"Library cache pin instance lock (D=namespace)"); else if ( strncmp (cad_decodificar,"PE",2) == 0) strcpy (dato_1,"Library cache pin instance lock (E=namespace)"); else if ( strncmp (cad_decodificar,"PF",2) == 0) strcpy (dato_1,"Library cache pin instance lock (F=namespace)"); else if ( strncmp (cad_decodificar,"PG",2) == 0) strcpy (dato_1,"Library cache pin instance lock (G=namespace)"); else if ( strncmp (cad_decodificar,"PH",2) == 0) strcpy (dato_1,"Library cache pin instance lock (H=namespace)"); else if ( strncmp (cad_decodificar,"PI",2) == 0) strcpy (dato_1,"Library cache pin instance lock (I=namespace)"); else if ( strncmp (cad_decodificar,"PJ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (J=namespace)"); else if ( strncmp (cad_decodificar,"PL",2) == 0) strcpy (dato_1,"Library cache pin instance lock (K=namespace)"); else if ( strncmp (cad_decodificar,"PK",2) == 0) strcpy (dato_1,"Library cache pin instance lock (L=namespace)"); else if ( strncmp (cad_decodificar,"PM",2) == 0) strcpy (dato_1,"Library cache pin instance lock (M=namespace)"); else if ( strncmp (cad_decodificar,"PN",2) == 0) strcpy (dato_1,"Library cache pin instance lock (N=namespace)"); else if ( strncmp (cad_decodificar,"PO",2) == 0) strcpy (dato_1,"Library cache pin instance lock (O=namespace)"); else if ( strncmp (cad_decodificar,"PP",2) == 0) strcpy (dato_1,"Library cache pin instance lock (P=namespace)"); else
  • 222. if ( strncmp (cad_decodificar,"PQ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Q=namespace)"); else if ( strncmp (cad_decodificar,"PR",2) == 0) strcpy (dato_1,"Library cache pin instance lock (R=namespace)"); else if ( strncmp (cad_decodificar,"PS",2) == 0) strcpy (dato_1,"Library cache pin instance lock (S=namespace)"); else if ( strncmp (cad_decodificar,"PT",2) == 0) strcpy (dato_1,"Library cache pin instance lock (T=namespace)"); else if ( strncmp (cad_decodificar,"PU",2) == 0) strcpy (dato_1,"Library cache pin instance lock (U=namespace)"); else if ( strncmp (cad_decodificar,"PV",2) == 0) strcpy (dato_1,"Library cache pin instance lock (V=namespace)"); else if ( strncmp (cad_decodificar,"PW",2) == 0) strcpy (dato_1,"Library cache pin instance lock (W=namespace)"); else if ( strncmp (cad_decodificar,"PX",2) == 0) strcpy (dato_1,"Library cache pin instance lock (X=namespace)"); else if ( strncmp (cad_decodificar,"PY",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Y=namespace)"); else if ( strncmp (cad_decodificar,"PZ",2) == 0) strcpy (dato_1,"Library cache pin instance lock (Z=namespace)"); else if ( strncmp (cad_decodificar,"QA",2) == 0) strcpy (dato_1,"Row cache instance lock (A=cache)"); else if ( strncmp (cad_decodificar,"QB",2) == 0) strcpy (dato_1,"Row cache instance lock (B=cache)"); else if ( strncmp (cad_decodificar,"QC",2) == 0) strcpy (dato_1,"Row cache instance lock (C=cache)"); else if ( strncmp (cad_decodificar,"QD",2) == 0) strcpy (dato_1,"Row cache instance lock (D=cache)"); else if ( strncmp (cad_decodificar,"QE",2) == 0) strcpy (dato_1,"Row cache instance lock (E=cache)"); else if ( strncmp (cad_decodificar,"QF",2) == 0) strcpy (dato_1,"Row cache instance lock (F=cache)"); else if ( strncmp (cad_decodificar,"QG",2) == 0) strcpy (dato_1,"Row cache instance lock (G=cache)"); else if ( strncmp (cad_decodificar,"QH",2) == 0) strcpy (dato_1,"Row cache instance lock (H=cache)"); else if ( strncmp (cad_decodificar,"QI",2) == 0) strcpy (dato_1,"Row cache instance lock (I=cache)"); else if ( strncmp (cad_decodificar,"QJ",2) == 0) strcpy (dato_1,"Row cache instance lock (J=cache)"); else if ( strncmp (cad_decodificar,"QL",2) == 0) strcpy (dato_1,"Row cache instance lock (K=cache)"); else if ( strncmp (cad_decodificar,"QK",2) == 0) strcpy (dato_1,"Row cache instance lock (L=cache)"); else if ( strncmp (cad_decodificar,"QM",2) == 0) strcpy (dato_1,"Row cache instance lock (M=cache)"); else if ( strncmp (cad_decodificar,"QN",2) == 0) strcpy (dato_1,"Row cache instance lock (N=cache)"); else if ( strncmp (cad_decodificar,"QO",2) == 0) strcpy (dato_1,"Row cache instance lock (O=cache)"); else if ( strncmp (cad_decodificar,"QP",2) == 0) strcpy (dato_1,"Row cache instance lock (P=cache)"); else if ( strncmp (cad_decodificar,"QQ",2) == 0) strcpy (dato_1,"Row cache instance lock (Q=cache)"); else if ( strncmp (cad_decodificar,"QR",2) == 0) strcpy (dato_1,"Row cache instance lock (R=cache)"); else if ( strncmp (cad_decodificar,"QS",2) == 0) strcpy (dato_1,"Row cache instance lock (S=cache)"); else if ( strncmp (cad_decodificar,"QT",2) == 0) strcpy (dato_1,"Row cache instance lock (T=cache)"); else if ( strncmp (cad_decodificar,"QU",2) == 0) strcpy (dato_1,"Row cache instance lock (U=cache)"); else if ( strncmp (cad_decodificar,"QV",2) == 0) strcpy (dato_1,"Row cache instance lock (V=cache)"); else if ( strncmp (cad_decodificar,"QW",2) == 0) strcpy (dato_1,"Row cache instance lock (W=cache)"); else if ( strncmp (cad_decodificar,"QX",2) == 0) strcpy (dato_1,"Row cache instance lock (X=cache)"); else if ( strncmp (cad_decodificar,"QY",2) == 0) strcpy (dato_1,"Row cache instance lock (Y=cache)"); else if ( strncmp (cad_decodificar,"QZ",2) == 0) strcpy (dato_1,"Row cache instance lock (Z=cache)"); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** */
  • 223. /* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */funcion_columna (int column_size, void *punt_cadena, int nro_funcion) { char dato_1 [1024]; switch (nro_funcion) { case FUNC_DB_BLOCK_SIZE: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1000,dato_1,10); break; case FUNC_COMMAND_SQL: /* Decodifico el nro de la Columna y lo relaciono con el nombre del COMANDO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_command_oracle ( atoi ( (char *) punt_cadena) ) ); case FUNC_LOCK_MODE: /* Decodifico el nro de la Columna y lo relaciono con el tipo de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_lock_mode ( atoi ( (char *) punt_cadena) ) ); case FUNC_LOCK_NAME_MODE: /* Decodifico el nro de la Columna y lo relaciono con el nombre de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_name_lock ( (char *) punt_cadena) ); default: break; } /* ------------------------------------------------------------------------ */ strncpy ( (char *) punt_cadena, dato_1, column_size); /* ------------------------------------------------------------------------ */ return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_columna_funcion ( void *punt_cadena, int nro_columna, int *nro_funcion )
  • 224. {char procesar[10];char col_char[10];char func_char[10];int pos_col = 0;int flag_procesar = 0;int caracter = 0;int delimitador = 0;int contador = 0;int nro_col = 0;int nro_func = 0;for ( pos_col = 1; pos_col < 3; pos_col ++) { procesar [pos_col-1] = ( (char *) punt_cadena)[pos_col]; procesar [pos_col] = FIN_LINEA; }if (strncmp (procesar,"SI",2) == 0 ) flag_procesar = SI_PROCESAR;if (strncmp (procesar,"NO",2) == 0 ) flag_procesar = NO_PROCESAR;for ( pos_col = 3; pos_col < (int ) (strlen ( (char *) punt_cadena )); pos_col ++ ) { caracter = ( (char *) punt_cadena )[pos_col]; if ( caracter == SEPARADOR ) if ( delimitador == 0 ) delimitador++; else delimitador--; if ( ( delimitador == 1 ) && ( caracter != SEPARADOR ) ) { if ( contador < 2 ) { col_char[contador] = caracter; col_char[contador+1] = FIN_LINEA; } else {
  • 225. func_char[contador - 2] = caracter; func_char[contador -2+1]= FIN_LINEA; } contador++; if ( contador == 4 ) { nro_col = atoi (col_char); nro_func = atoi (func_char); contador=0; /* printf ("Colu [%d] Func [%d] n",nro_col, nro_func); */ if ( nro_col == nro_columna ) { *nro_funcion = nro_func; return (SI_PROCESAR); } } } } return (NO_PROCESAR); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
  • 226. *** ****** ****** ARCHIVO: orasta2000.pc ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#include <oraca.h>#include <sqlca.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <setjmp.h>#include "constant_definition.h"/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */#ifndef NULL#define NULL 0#endif/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */ char *dml_commands[] = {"SELECT", "select", "INSERT", "insert","UPDATE", "update", "DELETE", "delete"}; char dyn_size [MAX_VAR_SIZE]; char dyn_title [MAX_VAR_SIZE]; char dyn_column [MAX_VAR_SIZE];
  • 227. char dyn_proc_func [MAX_VAR_SIZE]; EXEC SQL BEGIN DECLARE SECTION; char dyn_sts[16384]; EXEC SQL VAR dyn_sts IS STRING(16384); EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca; EXEC SQL INCLUDE sqlda; SQLDA *bind_dp; SQLDA *select_dp; jmp_buf jmp_continue; int parse_flag = 0;/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****---- FUNCIONES DECLARADAS INTERNAS ****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */ /* ----****----****---- FUNCIONES QUERY SQL ORACLE ****----****----**** */ int version_oracle(); int db_block_size (); char *db_object_type (); char *db_session_sid (); char *db_object_owner_name (); /* ----****----****---- FUNCIONES PRIMITIVAS ORACLE ****----****----**** */ int oracle_connect_original(); int oracle_connect_new(); int alloc_descriptors(); int set_bind_variables(); int process_select_list(); int liberar_memoria(); int cargar_sentencia (); int procesar_cadena (); int procesar_encabe (); sql_error();
  • 228. /* ----****----****---- FUNCIONES PROCESAMIENTO CHAR ****----****----**** */ int filtrar_char (); int col_size (); int filtrar_char (); char *pasar_amayus (); void vaciar_estructura (); void vaciar_cadena (); char *funcion_columna (); int procesar_columna_funcion (); char *convert_ss_to_hh_mm_ss (); char *separar_dato ();/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****---- FUNCIONES DECLARADAS EXTERNAS ****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */ extern SQLDA *sqlald(); extern void sqlnul(); extern char *decode_name_lock (); extern char *decode_command_oracle (); extern char *decode_lock_mode (); extern char *ver_menu_opcion(); extern char *func_dyn_column_set (); extern char *func_dyn_title_set(); extern char *func_dyn_size_set(); extern char *func_dyn_statement_set(); extern char *func_dyn_proc_func_set();/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */main( int argc , char *argv[]) { int i=0; int opcion_nro=0;
  • 229. int version=0;char opcion_uno [MAX_LEN_ARG];char opcion_dos [MAX_LEN_ARG];char opcion_tres [MAX_LEN_ARG];char datos_conexion [MAX_LEN_CONNECT];char username [MAX_LEN_CONNECT];char password [MAX_LEN_CONNECT];char conexion [MAX_LEN_CONNECT];char nomcon_001 [MAX_LEN_CONNECT];char nomcon_002 [MAX_LEN_CONNECT];opcion_uno[0]=FIN_LINEA;opcion_dos[0]=FIN_LINEA;opcion_tres[0]=FIN_LINEA;datos_conexion[0]=FIN_LINEA;if (argc <3 ) { printf ("Insuficientes argumentos n"); exit (1); }strcpy (datos_conexion,argv[1]);strcpy (nomcon_001,"CONEX001");vaciar_cadena (username,MAX_LEN_CONNECT);vaciar_cadena (password,MAX_LEN_CONNECT);vaciar_cadena (conexion,MAX_LEN_CONNECT);strcpy (username,separar_dato (datos_conexion,USERNAME));strcpy (password,separar_dato (datos_conexion,PASSWORD));strcpy (conexion,separar_dato (datos_conexion,CONEXION));printf ("User [%s] - Pass [%s] - Cone [%s] - DbAl [%s] n",username,password,conexion,nomcon_001);if (argc >= 3 ) opcion_nro=atoi(argv[2]);if (argc >= 4 ) strcpy (opcion_uno,pasar_amayus(argv[3]));if (argc >= 5 ) strcpy (opcion_dos,pasar_amayus(argv[4]));
  • 230. if (argc >= 6 ) strcpy (opcion_tres,argv[5]);/* ********************************************************* *//* if (oracle_connect_new (datos_conexion,username,password,conexion,nomcon_001) != 0) { printf ("No es posible conectarse ...n"); exit(1); }*//* ********************************************************* */ if (oracle_connect_original(datos_conexion) != 0) { printf ("No es posible conectarse ...n"); exit(1); } version = version_oracle(); printf ("Oracle Version [%d] n",version); if (alloc_descriptors(MAX_ITEMS,MAX_VNAME_LEN, MAX_INAME_LEN) != 0) exit(1); i = setjmp(jmp_continue); cargar_sentencia (version, opcion_nro, opcion_uno, opcion_dos, opcion_tres); EXEC SQL WHENEVER SQLERROR DO sql_error(); parse_flag = 1; EXEC SQL PREPARE S FROM :dyn_sts; parse_flag = 0; EXEC SQL DECLARE C CURSOR FOR S; set_bind_variables(); EXEC SQL OPEN C USING DESCRIPTOR bind_dp; process_select_list(); liberar_memoria(); return NO_ERROR; }
  • 231. /* ----****----****----****----****----****----****----****----****----****----**** */char *pasar_amayus (char *cadena ) { int pos=0; /* printf ("Iniciando conversion n"); */ for (pos =0; pos < (int ) strlen (cadena); pos ++) cadena[pos]=toupper(cadena[pos]); return cadena; }/* ----****----****----****----****----****----****----****----****----****----**** */liberar_memoria () { int i; for (i = 0; i < MAX_ITEMS; i++) { if (bind_dp->V[i] != (char *) 0) free(bind_dp->V[i]); free(bind_dp->I[i]); if (select_dp->V[i] != (char *) 0) free(select_dp->V[i]); free(select_dp->I[i]); } EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL CLOSE C; EXEC SQL COMMIT WORK RELEASE; EXEC SQL WHENEVER SQLERROR DO sql_error(); return SI_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */oracle_connect_original ( char *datos_conexion )
  • 232. { EXEC SQL BEGIN DECLARE SECTION; VARCHAR connectstring[256]; EXEC SQL END DECLARE SECTION; strcpy ((char *) connectstring.arr,datos_conexion); connectstring.arr[strlen((char *) connectstring.arr)] = FIN_LINEA; connectstring.len = (unsigned short )strlen((char *) connectstring.arr); EXEC SQL WHENEVER SQLERROR GOTO connect_error; printf ("nConnecting .....n"); EXEC SQL CONNECT :connectstring; printf("nConnected to ORACLE n"); return 0; connect_error: fprintf(stderr,"Cannot connect to ORACLEn"); return -1; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */oracle_connect_new ( char *datos_conexion, char *user_name, char *pass_word, char *net_conexion, char *aliasdb) { EXEC SQL BEGIN DECLARE SECTION; VARCHAR username[256]; VARCHAR password[256]; VARCHAR connectstring[256]; VARCHAR db_net_connect[256]; VARCHAR db_alias_name[256]; EXEC SQL END DECLARE SECTION; strcpy ((char *) connectstring.arr,datos_conexion); connectstring.arr[strlen((char *) connectstring.arr)] = FIN_LINEA; connectstring.len = (unsigned short )strlen((char *) connectstring.arr);
  • 233. strcpy ((char *) username.arr,user_name); username.arr[strlen((char *) username.arr)] = FIN_LINEA; username.len = (unsigned short )strlen((char *) username.arr); strcpy ((char *) password.arr,pass_word); password.arr[strlen((char *) password.arr)] = FIN_LINEA; password.len = (unsigned short )strlen((char *) password.arr); strcpy ((char *) db_net_connect.arr,net_conexion); db_net_connect.arr[strlen((char *) db_net_connect.arr)] = FIN_LINEA; db_net_connect.len = (unsigned short )strlen((char *) db_net_connect.arr); strcpy ((char *) db_alias_name.arr,aliasdb); db_alias_name.arr[strlen((char *) db_alias_name.arr)] = FIN_LINEA; db_alias_name.len = (unsigned short )strlen((char *) db_alias_name.arr); EXEC SQL WHENEVER SQLERROR GOTO connect_error; printf ("nConnecting .....n"); /* printf ("User [%s] - Pass [%s] - Cone [%s] n",username.arr,password.arr,db_net_connect.arr); */ EXEC SQL CONNECT :username IDENTIFIED BY :password AT :db_alias_name USING :db_net_connect; printf("nConnected to ORACLE n"); return 0; connect_error: fprintf(stderr,"Cannot connect to ORACLEn"); return -1; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */alloc_descriptors(size, max_vname_len, max_iname_len) int size;
  • 234. int max_vname_len; int max_iname_len; { int i; if ((bind_dp = sqlald(size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; } if ((select_dp = sqlald (size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; } select_dp->N = MAX_ITEMS; for (i = 0; i < MAX_ITEMS; i++) { bind_dp->I[i] = (short *) malloc(sizeof (short)); select_dp->I[i] = (short *) malloc(sizeof(short)); bind_dp->V[i] = (char *) malloc(1); select_dp->V[i] = (char *) malloc(1); } return 0; }/* ----****----****----****----****----****----****----****----****----****----**** */set_bind_variables() { int i, n; char bind_var [MAX_BIND_VARIABLE]; EXEC SQL WHENEVER SQLERROR DO sql_error(); bind_dp->N = MAX_ITEMS; EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;
  • 235. if (bind_dp->F < 0) { printf ("nToo many variables to bind...n", -bind_dp->F, MAX_ITEMS); return SI_ERROR; } bind_dp->N = bind_dp->F; for (i = 0; i < bind_dp->F; i++) { printf ("nEnter value for bind variable %.*s: ",(int)bind_dp->C[i], bind_dp->S[i]); fgets (bind_var, (int )sizeof(bind_var), stdin); n = (int )strlen(bind_var) - 1; bind_dp->L[i] = n; bind_dp->V[i] = (char *) realloc(bind_dp->V[i], (bind_dp->L[i] + 1)); strncpy(bind_dp->V[i], bind_var, n); if ((strncmp(bind_dp->V[i], "NULL", 4) == 0) || (strncmp(bind_dp->V[i], "null", 4) == 0)) *bind_dp->I[i] = -1; else *bind_dp->I[i] = 0; bind_dp->T[i] = 1; } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */process_select_list() { int null_ok; int nro_columna=0; int column_size=0; int si_proceso=0; int nro_bytes=0; int nro_funcion=0; char datos_auxi[MAX_LEN_DATOS_AUXI]; vaciar_cadena (datos_auxi,MAX_LEN_DATOS_AUXI); if ((strncmp(dyn_sts, "SELECT", 6) != 0) && (strncmp(dyn_sts, "select", 6) != 0))
  • 236. { select_dp->F = 0; return NO_ERROR; }select_dp->N = MAX_ITEMS;EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;if (select_dp->F < 0) { printf ("nToo many select-list items (%d), maximum is %dn", -(select_dp->F), MAX_ITEMS); return SI_ERROR; }select_dp->N = select_dp->F;printf ("%s n",dyn_title);for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { sqlnul ( &(select_dp->T[nro_columna]), &(select_dp->T[nro_columna]), &null_ok); column_size=col_size(dyn_size,nro_columna); select_dp->L[nro_columna]= column_size; select_dp->C[nro_columna]= column_size; select_dp->T[nro_columna]=1; }for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { select_dp->V[nro_columna] = (char *) realloc(select_dp->V[nro_columna], select_dp->L[nro_columna]); printf ("["); column_size=col_size(dyn_size,nro_columna); procesar_encabe (column_size,nro_columna,dyn_column); printf ("] "); }printf ("n");EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop; for ( ; ; ) { /* Asegurandome que la estructura de Retorno este totalmente vacia */ vaciar_estructura ( select_dp ); /* Tomando una fila (ROW) de la base de datos */ EXEC SQL FETCH C USING DESCRIPTOR select_dp;
  • 237. /* Procesando las "i" columnas de datos de la fila retornada */ for (nro_columna = 0; nro_columna < select_dp->F; nro_columna++) { printf (" "); /* ----------------------------------------------------------------------------- */ column_size=col_size(dyn_size,nro_columna); /* ----------------------------------------------------------------------------- */ si_proceso = procesar_columna_funcion (dyn_proc_func, nro_columna, &nro_funcion); if ( si_proceso == SI_PROCESAR) { vaciar_cadena (datos_auxi,strlen(datos_auxi)); strcpy (datos_auxi,funcion_columna (nro_bytes, (char *)select_dp->V[nro_columna], nro_funcion)); procesar_cadena (column_size,datos_auxi); } else { /* ----------------------------------------------------------------------------- */ procesar_cadena (column_size,(char *)select_dp->V[nro_columna]); /* ----------------------------------------------------------------------------- */ } printf (" "); } printf ("n"); } end_select_loop: return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */cargar_sentencia (int version, int sentencia, char *opcion_uno, char *opcion_dos, char *opcion_tres ) { strcpy (dyn_column,func_dyn_column_set (version,sentencia)); strcpy (dyn_title,func_dyn_title_set (version,sentencia)); strcpy (dyn_sts,func_dyn_statement_set (version,sentencia,opcion_uno,opcion_dos,opcion_tres)); strcpy (dyn_size,func_dyn_size_set (version,sentencia)); strcpy (dyn_proc_func, func_dyn_proc_func_set (version,sentencia)); /* ----------------------------------------------------------------------------- */
  • 238. /* COMPROBACION DE LAS VARIABLES RETORNADAS EN LOS CASE */ /* SEGUN LA OPCION ELEGIDA Y LA VERSION DE ORACLE */ /* ----------------------------------------------------------------------------- *//* printf ("Proc Func [%s] n",dyn_proc_func); printf ("Column Set [%s] n",dyn_column); printf ("Column Size[%s] n",dyn_size); printf ("Statement [%s] n",dyn_sts);*/ if (strlen (dyn_sts) >= MAX_STMT) printf ("Max Statement large [%d] | Actual Statement large [%d] n",MAX_STMT,strlen(dyn_sts)); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */sql_error() { /* int i; */ printf ("nn%.70sn",sqlca.sqlerrm.sqlerrmc); if (parse_flag) printf("n Error de Oracle... n",sqlca.sqlerrd[4]); EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK WORK; liberar_memoria(); exit(1); }/* ----****----****----****----****----****----****----****----****----****----**** */col_size (char *puntero, int posicion) { char ascii_nro[3]; int numero, i; for ( i = posicion*2; i < posicion*2+2; i++) ascii_nro[i-posicion*2]=puntero[i]; ascii_nro[2]=FIN_LINEA; numero=atoi(ascii_nro);
  • 239. return numero; }/* ----****----****----****----****----****----****----****----****----****----**** */int filtrar_char (int caracter) { if ( (caracter >= 32 && caracter <= 127 ) ) return caracter; else { switch (caracter) { case 164: break; case 165: break; case 168: break; case 173: break; default: caracter=32;break; } } return caracter; }/* ----****----****----****----****----****----****----****----****----****----**** */procesar_cadena (int nrocolum, char *puntero_char) { int pos, caracter; for ( pos=0; pos < nrocolum; pos++ ) { caracter=filtrar_char(puntero_char[pos]); printf ("%c",caracter); } fflush(stdout); return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */procesar_encabe (int tamano, int posicion, char *puntero_char)
  • 240. { int pos_col=0; int pos_cad=0; int columna=-1; int caracter=0; int salto=0; for ( pos_col = 0; pos_col < (int )strlen(puntero_char); pos_col ++) { if ( puntero_char[pos_col] == SEPARADOR ) columna++; if ( columna == posicion ) break; } for ( pos_cad = pos_col+1; pos_cad < tamano+pos_col+1; pos_cad++ ) { if ( puntero_char[pos_cad]==SEPARADOR) salto++; if (salto==0) { caracter = filtrar_char ( puntero_char[pos_cad] ); printf ("%c",caracter); } else printf (" "); } return NO_ERROR; }/* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_estructura ( void *punt_sqlda ) { int pos_k, pos_j; int limite_k = ((SQLDA *) punt_sqlda ) ->F; int limite_j; for ( pos_k = 0; pos_k < limite_k ; pos_k++ ) { limite_j = ((SQLDA *) punt_sqlda ) ->L[ pos_k ]; for ( pos_j = 0; pos_j < limite_j ; pos_j++) (char ) (((SQLDA *) punt_sqlda )->V[pos_k])[pos_j] = FIN_LINEA; } }
  • 241. /* ----****----****----****----****----****----****----****----****----****----**** */void vaciar_cadena (void *punt_cadena, int largo) { int pos; for (pos = 0; pos < largo; pos ++) ((char *) punt_cadena ) [pos] = FIN_LINEA; }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int version_oracle () { char Version[10]; int conta=0; int pos=0; int caracter=0; int nro_puntos=0; EXEC SQL BEGIN DECLARE SECTION; VARCHAR version [256]; EXEC SQL END DECLARE SECTION; vaciar_cadena (version.arr,MAX_VERSION_LEN); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT ltrim(lpad(banner,70)) INTO :version FROM V$VERSION WHERE banner like %Oracle%; break; /* SOLO ME INTERESA UN REGISTRO */ } for ( pos =0; pos < version.len; pos ++) { caracter = version.arr[pos];
  • 242. Version[conta]=FIN_LINEA; if ( nro_puntos < 3 ) { switch (caracter) { case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: Version[conta]=caracter; conta++; Version[conta]=FIN_LINEA; break; case 46: /* Version[conta]=caracter; conta++; */ nro_puntos++; Version[conta]=FIN_LINEA; break; default: conta=0; } } } return (atoi (Version)); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */int db_block_size () { int block_size=0;
  • 243. EXEC SQL BEGIN DECLARE SECTION; VARCHAR data_block_size [20]; EXEC SQL END DECLARE SECTION; vaciar_cadena (data_block_size.arr,20); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT value INTO :data_block_size FROM V$PARAMETER WHERE NAME IN (db_block_size); break; /* SOLO ME INTERESA UN REGISTRO */ } block_size = atoi (data_block_size.arr); return (block_size); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *db_session_sid (void *punt_kaddr) { static char dato_1[MAX_LEN_VARCHAR]; EXEC SQL BEGIN DECLARE SECTION; VARCHAR sid_ses[128]; char kaddr[8]; EXEC SQL END DECLARE SECTION; vaciar_cadena (dato_1,MAX_LEN_VARCHAR); strcpy (kaddr, (char *) punt_kaddr); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT ltrim(owner)||.||ltrim(object_name) INTO :sid_ses FROM V$SESSION WHERE LOCKWAIT = :kaddr;
  • 244. break; /* SOLO ME INTERESA UN REGISTRO */ }/* printf ("Sid Ses [%s] n",sid_ses.arr); */ strcpy (dato_1,sid_ses.arr); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *db_object_owner_name (long objeto_id) { int block_size=0; static char dato_1[MAX_LEN_VARCHAR]; EXEC SQL BEGIN DECLARE SECTION; VARCHAR objeto_owner_name [128]; long numero; EXEC SQL END DECLARE SECTION; numero = objeto_id; vaciar_cadena (dato_1,MAX_LEN_VARCHAR); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT ltrim(owner)||.||ltrim(object_name) INTO :objeto_owner_name FROM V$ALL_OBJECTS WHERE OBJECT_ID= :numero; break; /* SOLO ME INTERESA UN REGISTRO */ }/* printf ("Objeto_owner_name [%s] n",objeto_owner_name.arr); */ strcpy (dato_1,objeto_owner_name.arr); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****---- FUNCIONES A DEFINIR PARA PROCESAR LAS COLUMNAS RETORNADAS ----**** *//* ----****----****----****----****----****----****----****----****----****----**** */
  • 245. char *db_object_type (long objeto_id) { int block_size=0; static char dato_1[MAX_LEN_VARCHAR]; EXEC SQL BEGIN DECLARE SECTION; VARCHAR tipo_objeto [128]; long numero; EXEC SQL END DECLARE SECTION; numero = objeto_id; vaciar_cadena (tipo_objeto.arr,128); vaciar_cadena (dato_1,MAX_LEN_VARCHAR); for ( ; ; ) { EXEC SQL WHENEVER NOT FOUND DO break; EXEC SQL SELECT ltrim(object_type) INTO :tipo_objeto FROM V$ALL_OBJECTS WHERE OBJECT_ID= :numero; break; /* SOLO ME INTERESA UN REGISTRO */ } strcpy (dato_1,tipo_objeto.arr); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *convert_ss_to_hh_mm_ss (char *punt_cadena ) { static char dato_1[MAX_LEN_VARCHAR]; int hora,minuto,segundo; float numero= (float )atoi (punt_cadena); vaciar_cadena (dato_1,MAX_LEN_VARCHAR);
  • 246. hora = (int )(numero/60/60); minuto = (int ) ((numero/60/60 - (int )(numero/60/60))*60); segundo = (int ) ((numero/60 - (int )(numero/60))*60); sprintf (dato_1,"%2d:%2d:%2dn0",hora,minuto,segundo); return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *funcion_columna (int nro_bytes, void *punt_cadena, int nro_funcion) { static char dato_1 [1024]; vaciar_cadena (dato_1,1024); switch (nro_funcion) { case FUNC_DB_BLOCK_SIZE: /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1000,dato_1,10); break; case FUNC_COMMAND_SQL: /* Decodifico el nro de la Columna y lo relaciono con el nombre del COMANDO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_command_oracle ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_MODE: /* Decodifico el nro de la Columna y lo relaciono con el tipo de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_lock_mode ( atoi ( (char *) punt_cadena) ) ); break; case FUNC_LOCK_NAME_MODE: /* Decodifico el nro de la Columna y lo relaciono con el nombre de LOCKEO */ /* ------------------------------------------------------------------------ */ strcpy ( dato_1, decode_name_lock ( (char *) punt_cadena) ); break; case FUNC_DB_BLOCK_SIZE0:
  • 247. /* Calculo DB_BLOCK_SIZE, multiplico por la COLUMNA y devuelvo el RESULTADO */ /* ------------------------------------------------------------------------ */ itoa ((atoi ( (char *) punt_cadena ) * db_block_size() ) / 1024,dato_1,10); break; case FUNC_DB_OBJECT_TYPE: /* Busco el OBJECT_TYPE dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_object_type ( atoi ( (char *) punt_cadena ) ) ); break; case FUNC_DB_OBJECT_OWNER_NAME: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ *//* printf ("parametro [%s] n",(char *) punt_cadena); */ strcpy (dato_1,db_object_owner_name ( atoi ( (char *) punt_cadena ) ) );/* printf ("[%s] n",dato_1); */ break; case FUNC_DB_SESSION_SID: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,db_session_sid ((char *) punt_cadena ));/* printf ("[%s] n",dato_1); */ break; case FUNC_CONVERT_HH_MM_SS: /* Busco el OBJECT_OWNER_NAME dentro de la tabla ALL_OBJECTS */ /* ------------------------------------------------------------------------ */ strcpy (dato_1,convert_ss_to_hh_mm_ss ((char *) punt_cadena ));/* printf ("[%s] n",dato_1); */ break; default: break; }/* printf ("[%s] n",dato_1); */ return (dato_1); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */procesar_columna_funcion ( void *punt_cadena, int nro_columna, int *nro_funcion )
  • 248. { char procesar[10]; char col_char[10]; char func_char[10]; int pos_col = 0; int flag_procesar = 0; int caracter = 0; int delimitador = 0; int contador = 0; int nro_col = 0; int nro_func = 0; for ( pos_col = 1; pos_col < 3; pos_col ++) { procesar [pos_col-1] = ( (char *) punt_cadena)[pos_col]; procesar [pos_col] = FIN_LINEA; } if (strncmp (procesar,"SI",2) == 0 ) flag_procesar = SI_PROCESAR; if (strncmp (procesar,"NO",2) == 0 ) { flag_procesar = NO_PROCESAR; return (NO_PROCESAR); } vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); for ( pos_col = 3; pos_col < (int ) (strlen ( (char *) punt_cadena )); pos_col ++ ) { caracter = ( (char *) punt_cadena )[pos_col];/* printf (" ______> CHAR={%c} POS_COL=[%d] CONTADOR=[%d] LIMITADOR=[%d]n",caracter,pos_col,contador,delimitador); */ if ( caracter == SEPARADOR ) if ( delimitador == 0 ) delimitador++; else delimitador--; if ( ( delimitador == 1 ) && ( caracter != SEPARADOR ) ) { if ( contador < 2 )
  • 249. { col_char[contador] = caracter; col_char[contador+1] = FIN_LINEA; } else if (contador >=2 ) { func_char [contador-2] = caracter; func_char [contador-2+1]= FIN_LINEA; }/* printf (" ______________>>>>>> COL_CHAR [%s] FUNC_CHAR [%s] NRO_COLUMNA [%d] n",col_char,func_char,nro_columna); */ contador++; if ( contador == 4 ) { nro_col = atoi (col_char); nro_func = atoi (func_char); contador=0; vaciar_cadena (col_char,10); vaciar_cadena (func_char,10); if ( nro_col == nro_columna ) { *nro_funcion = nro_func; return (SI_PROCESAR); } } } } return (NO_PROCESAR); }/* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** *//* ----****----****----****----****----****----****----****----****----****----**** */char *separar_dato (void *punt_cad, int opcion ) { static char cadena[MAX_LEN_CONNECT]; int posicion=0; int pos_arroba=0; int pos_slash=0; int largocad=0;
  • 250. int caracter=0;int contador=0;largocad=(int )strlen ((char *) punt_cad);vaciar_cadena (cadena,MAX_LEN_CONNECT);for ( posicion=0; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; if ( caracter == SLASH ) pos_slash = posicion; else if (caracter == ARROBA) pos_arroba = posicion; }switch (opcion ) { case USERNAME: for (posicion=0; posicion < pos_slash; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; case PASSWORD: for (posicion=pos_slash+1; posicion < pos_arroba; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break; case CONEXION: for (posicion=pos_arroba+1; posicion < largocad; posicion++) { caracter = ((char *) punt_cad )[posicion]; cadena[contador]=caracter; contador++; } break;
  • 251. } cadena[contador]=FIN_LINEA; return (cadena); }--- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------ ------ ------ ---********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************* ****** ****** ARCHIVO: orasta370.c ****** ****** *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** ****** ***/* Result Sets Interface */#ifndef SQL_CRSR# define SQL_CRSR struct sql_cursor { unsigned int curocn; void *ptr1;
  • 252. void *ptr2; unsigned long magic; }; typedef struct sql_cursor sql_cursor; typedef struct sql_cursor SQL_CURSOR;#endif /* SQL_CRSR *//* Thread Safety */typedef void * sql_context;typedef void * SQL_CONTEXT;/* Object support */struct sqltvn{ unsigned char *tvnvsn; unsigned short tvnvsnl; unsigned char *tvnnm; unsigned short tvnnml; unsigned char *tvnsnm; unsigned short tvnsnml;};typedef struct sqltvn sqltvn;struct sqladts{ unsigned int adtvsn; unsigned short adtmode; unsigned short adtnum; sqltvn adttvn[1];};typedef struct sqladts sqladts;static struct sqladts sqladt = { 1,0,0,};/* Binding to PL/SQL Records */struct sqltdss{ unsigned int tdsvsn;
  • 253. unsigned short tdsnum; unsigned char *tdsval[1];};typedef struct sqltdss sqltdss;static struct sqltdss sqltds ={ 1, 0,};/* File name & Package Name */struct sqlcxp{ unsigned short fillen; char filnam[13];};static const struct sqlcxp sqlfpn ={ 12, "orasta370.pc"};static unsigned long sqlctx = 318507;static struct sqlexd { unsigned int sqlvsn; unsigned int arrsiz; unsigned int iters; unsigned int offset; unsigned short selerr; unsigned short sqlety; unsigned int occurs; const short *cud; unsigned char *sqlest; const char *stmt; sqladts *sqladtp; sqltdss *sqltdsp; void **sqphsv;
  • 254. unsigned int *sqphsl; int *sqphss; void **sqpind; int *sqpins; unsigned int *sqparm; unsigned int **sqparc; unsigned short *sqpadto; unsigned short *sqptdso; void *sqhstv[4]; unsigned int sqhstl[4]; int sqhsts[4]; void *sqindv[4]; int sqinds[4]; unsigned int sqharm[4]; unsigned int *sqharc[4]; unsigned short sqadto[4]; unsigned short sqtdso[4];} sqlstm = {10,4};/* SQLLIB Prototypes */extern void sqlcxt (void **, unsigned long *, struct sqlexd *, const struct sqlcxp *);extern void sqlcx2t(void **, unsigned long *, struct sqlexd *, const struct sqlcxp *);extern void sqlbuft(void **, char *);extern void sqlgs2t(void **, char *);extern void sqlorat(void **, unsigned long *, void *);/* Forms Interface */static const int IAPSUCC = 0;static const int IAPFAIL = 1403;static const int IAPFTL = 535;extern void sqliem(char *, int *);typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;typedef struct { unsigned short len; unsigned char arr[1]; } varchar;/* cud (compilation unit data) array */static const short sqlcud0[] ={10,4242,0,0,0,
  • 255. 5,0,0,1,0,0,273,111,0,0,1,1,0,1,0,1,5,0,0,24,0,0,1,0,0,267,121,0,0,1,1,0,1,0,1,32,0,0,43,0,0,1,0,0,271,161,0,0,0,0,0,1,0,58,0,0,2,0,0,286,162,0,0,0,0,0,1,0,73,0,0,3,0,0,283,183,0,0,4,4,0,1,0,1,9,0,0,1,10,0,0,1,10,0,0,1,10,0,0,104,0,0,1,0,0,275,230,0,0,1,1,0,1,0,3,32,0,0,123,0,0,1,0,0,276,271,0,0,1,1,0,1,0,3,32,0,0,142,0,0,1,0,0,270,312,0,0,1,0,0,1,0,2,32,0,0,161,0,0,4,0,0,287,334,0,0,0,0,0,1,0,};#line 1 "orasta370.pc"/* ************************************************************** */#include <oraca.h>#include <sqlca.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <setjmp.h>#define MAX_ITEMS 512#define MAX_VNAME_LEN 512#define MAX_INAME_LEN 512#define MAX_BUFFER 512#define MAX_LINE 512#define MAX_STMT 16384#define MAX_BIND_VARIABLE 512#define MAX_VAR_SIZE 512#define MAX_LEN_ARG 512#define MAX_LEN_CONNECT 512#define SEPARADOR 124#define FIN_LINEA 0#define VERSION_ORACLE_734 734
  • 256. #define VERSION_ORACLE_816 816#define VERSION_ORACLE_817 817#define VERSION_ORACLE_901 901#define VERSION_ORACLE_902 902#define VERSION_ORACLE_910 910#define VERSION_ORACLE_920 920#define VERSION_ORACLE_UNK 000#ifndef NULL#define NULL 0#endif char *dml_commands[] = {"SELECT", "select", "INSERT", "insert","UPDATE", "update", "DELETE", "delete"}; char dyn_size [MAX_VAR_SIZE]; char dyn_title [MAX_VAR_SIZE]; char dyn_column [MAX_VAR_SIZE]; /* EXEC SQL BEGIN DECLARE SECTION; */#line 45 "orasta370.pc" char dyn_sts[16384]; /* EXEC SQL VAR dyn_sts IS STRING(16384); */#line 47 "orasta370.pc" /* EXEC SQL END DECLARE SECTION; */#line 48 "orasta370.pc"/* EXEC SQL INCLUDE sqlca; */#line 1 "e:OracleOra81precomppublicsqlca.h"/* * $Header: sqlca.h,v 1.3 1994/12/12 19:27:27 jbasu Exp $ sqlca.h *//* Copyright (c) 1985,1986, 1998 by Oracle Corporation. *//*NAME SQLCA : SQL Communications Area.
  • 257. FUNCTION Contains no code. Oracle fills in the SQLCA with status info during the execution of a SQL stmt.NOTES ************************************************************** *** *** *** This file is SOSD. Porters must change the data types *** *** appropriately on their platform. See notes/pcport.doc *** *** for more information. *** *** *** ************************************************************** If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA will be defined to have this storage class. For example: #define SQLCA_STORAGE_CLASS extern will define the SQLCA as an extern. If the symbol SQLCA_INIT is defined, then the SQLCA will be statically initialized. Although this is not necessary in order to use the SQLCA, it is a good pgming practice not to have unitialized variables. However, some C compilers/OSs dont allow automatic variables to be initd in this manner. Therefore, if you are INCLUDEing the SQLCA in a place where it would be an automatic AND your C compiler/OS doesnt allow this style of initialization, then SQLCA_INIT should be left undefined -- all others can define SQLCA_INIT if they wish. If the symbol SQLCA_NONE is defined, then the SQLCA variable will not be defined at all. The symbol SQLCA_NONE should not be defined in source modules that have embedded SQL. However, source modules that have no embedded SQL, but need to manipulate a sqlca struct passed in as a parameter, can set the SQLCA_NONE symbol to avoid creation of an extraneous sqlca variable.MODIFIED lvbcheng 07/31/98 - long to int jbasu 12/12/94 - Bug 217878: note this is an SOSD file losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set
  • 258. Clare 12/06/84 - Ch SQLCA to not be an extern. Clare 10/21/85 - Add initialization. Bradbury 01/05/86 - Only initialize when SQLCA_INIT set Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.*/#ifndef SQLCA#define SQLCA 1struct sqlca { /* ub1 */ char sqlcaid[8]; /* b4 */ int sqlabc; /* b4 */ int sqlcode; struct { /* ub2 */ unsigned short sqlerrml; /* ub1 */ char sqlerrmc[70]; } sqlerrm; /* ub1 */ char sqlerrp[8]; /* b4 */ int sqlerrd[6]; /* ub1 */ char sqlwarn[8]; /* ub1 */ char sqlext[8]; };#ifndef SQLCA_NONE#ifdef SQLCA_STORAGE_CLASSSQLCA_STORAGE_CLASS struct sqlca sqlca#else struct sqlca sqlca#endif#ifdef SQLCA_INIT = { {S, Q, L, C, A, , , }, sizeof(struct sqlca), 0, { 0, {0}}, {N, O, T, , S, E, T, }, {0, 0, 0, 0, 0, 0},
  • 259. {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0} }#endif ;#endif#endif/* end SQLCA *//* EXEC SQL INCLUDE sqlda; */#line 1 "e:OracleOra81precomppublicsqlda.h"/* * $Header: sqlda.h 31-jul-99.19:34:41 apopat Exp $ sqlda.h *//**************************************************************** The SQLDA descriptor definition **--------------------------------------------------------------** VAX/3B Version ** ** Copyright (c) 1987, 1997, 1998, 1999 by Oracle Corporation ****************************************************************//* NOTES ************************************************************** *** *** *** This file is SOSD. Porters must change the data types *** *** appropriately on their platform. See notes/pcport.doc *** *** for more information. *** *** *** ***************************************************************//* MODIFIED apopat 07/31/99 - [707588] TAB to blanks for OCCS lvbcheng 10/27/98 - change long to int for sqlda lvbcheng 08/15/97 - Move sqlda protos to sqlcpr.h
  • 260. lvbcheng 06/25/97 - Move sqlda protos to this file jbasu 01/29/95 - correct typo jbasu 01/27/95 - correct comment - ub2->sb2 jbasu 12/12/94 - Bug 217878: note this is an SOSD file Morse 12/01/87 - undef L and S for v6 include files Richey 07/13/87 - change int defs to long Clare 09/13/84 - Port: Ch types to match SQLLIB structs Clare 10/02/86 - Add ifndef SQLDA*/#ifndef SQLDA_#define SQLDA_ 1#ifdef T# undef T#endif#ifdef F# undef F#endif#ifdef S# undef S#endif#ifdef L# undef L#endifstruct SQLDA { /* ub4 */ int N; /* Descriptor size in number of entries */ /* text** */ char **V; /* Ptr to Arr of addresses of main variables */ /* ub4* */ int *L; /* Ptr to Arr of lengths of buffers */ /* sb2* */ short *T; /* Ptr to Arr of types of buffers */ /* sb2** */ short **I; /* Ptr to Arr of addresses of indicator vars */ /* sb4 */ int F; /* Number of variables found by DESCRIBE */ /* text** */ char **S; /* Ptr to Arr of variable name pointers */ /* ub2* */ short *M; /* Ptr to Arr of max lengths of var. names */ /* ub2* */ short *C; /* Ptr to Arr of current lengths of var. names */ /* text** */ char **X; /* Ptr to Arr of ind. var. name pointers */ /* ub2* */ short *Y; /* Ptr to Arr of max lengths of ind. var. names */ /* ub2* */ short *Z; /* Ptr to Arr of cur lengths of ind. var. names */
  • 261. };typedef struct SQLDA SQLDA;#endif/* ----------------- *//* defines for sqlda *//* ----------------- */#define SQLSQLDAAlloc(arg1, arg2, arg3, arg4) sqlaldt(arg1, arg2, arg3, arg4)#define SQLSQLDAFree(arg1, arg2) sqlclut(arg1, arg2)#line 52 "orasta370.pc" SQLDA *bind_dp; SQLDA *select_dp; extern SQLDA *sqlald(); extern void sqlnul(); jmp_buf jmp_continue; int parse_flag = 0; int oracle_connect(); int alloc_descriptors(); int set_bind_variables(); int process_select_list(); int liberar_memoria(); int filtrar_char (); int col_size (); int cargar_sentencia (); int procesar_cadena (); int procesar_encabe (); int filtrar_char (); char *pasar_amayus (); sql_error();
  • 262. void vaciar_estructura ();main( int argc , char *argv[]) { int i=0; int version = VERSION_ORACLE_734; int opcion_nro=0; char opcion_uno [MAX_LEN_ARG]; char opcion_dos [MAX_LEN_ARG]; char opcion_tres [MAX_LEN_ARG]; char datos_conexion [MAX_LEN_CONNECT]; opcion_uno[0]=FIN_LINEA; opcion_dos[0]=FIN_LINEA; opcion_tres[0]=FIN_LINEA; datos_conexion[0]=FIN_LINEA; strcpy (datos_conexion,argv[1]);/* printf ("Nro de argumentos [%d] n",argc); */ if (argc >= 3 ) opcion_nro=atoi(argv[2]); if (argc >= 4 ) strcpy (opcion_uno,pasar_amayus(argv[3])); if (argc >= 5 ) strcpy (opcion_dos,pasar_amayus(argv[4])); if (argc >= 6 ) strcpy (opcion_tres,argv[5]); if (oracle_connect(datos_conexion,version) != 0) exit(1); if (alloc_descriptors(MAX_ITEMS,MAX_VNAME_LEN, MAX_INAME_LEN) != 0) exit(1); i = setjmp(jmp_continue); cargar_sentencia (version, opcion_nro, opcion_uno, opcion_dos, opcion_tres);/* printf ("Inicializando la funcion de error ...n"); */ /* EXEC SQL WHENEVER SQLERROR DO sql_error(); */#line 107 "orasta370.pc" parse_flag = 1;/* printf ("Preparando la sentencia ...n"); */ /* EXEC SQL PREPARE S FROM :dyn_sts; */
  • 263. #line 111 "orasta370.pc"{#line 111 "orasta370.pc" struct sqlexd sqlstm;#line 111 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 111 "orasta370.pc" sqlstm.sqlvsn = 10;#line 111 "orasta370.pc" sqlstm.arrsiz = 1;#line 111 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 111 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 111 "orasta370.pc" sqlstm.stmt = "";#line 111 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 111 "orasta370.pc" sqlstm.offset = (unsigned int )5;#line 111 "orasta370.pc" sqlstm.cud = sqlcud0;#line 111 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 111 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 111 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 111 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)dyn_sts;#line 111 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )16384;#line 111 "orasta370.pc" sqlstm.sqhsts[0] = ( int )0;#line 111 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 111 "orasta370.pc" sqlstm.sqinds[0] = ( int )0;#line 111 "orasta370.pc"
  • 264. sqlstm.sqharm[0] = (unsigned int )0;#line 111 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 111 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 111 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 111 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 111 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 111 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 111 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 111 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 111 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 111 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;#line 111 "orasta370.pc" sqlstm.sqptdso = sqlstm.sqtdso;#line 111 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 111 "orasta370.pc" if (sqlca.sqlcode < 0) sql_error();#line 111 "orasta370.pc"}#line 111 "orasta370.pc" parse_flag = 0;/* printf ("Declarando el cursor ...n"); */ /* EXEC SQL DECLARE C CURSOR FOR S; */#line 115 "orasta370.pc"/* printf ("Binding Variables ...n"); */
  • 265. set_bind_variables();/* printf ("Open a cursor descriptor ...n"); */ /* EXEC SQL OPEN C USING DESCRIPTOR bind_dp; */#line 121 "orasta370.pc"{#line 121 "orasta370.pc" struct sqlexd sqlstm;#line 121 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 121 "orasta370.pc" sqlstm.sqlvsn = 10;#line 121 "orasta370.pc" sqlstm.arrsiz = 1;#line 121 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 121 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 121 "orasta370.pc" sqlstm.stmt = "";#line 121 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 121 "orasta370.pc" sqlstm.offset = (unsigned int )24;#line 121 "orasta370.pc" sqlstm.selerr = (unsigned short)1;#line 121 "orasta370.pc" sqlstm.cud = sqlcud0;#line 121 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 121 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 121 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 121 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)bind_dp;#line 121 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )0;#line 121 "orasta370.pc"
  • 266. sqlstm.sqhsts[0] = ( int )0;#line 121 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 121 "orasta370.pc" sqlstm.sqinds[0] = ( int )0;#line 121 "orasta370.pc" sqlstm.sqharm[0] = (unsigned int )0;#line 121 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 121 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 121 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 121 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 121 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 121 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 121 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 121 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 121 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 121 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;#line 121 "orasta370.pc" sqlstm.sqptdso = sqlstm.sqtdso;#line 121 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 121 "orasta370.pc" if (sqlca.sqlcode < 0) sql_error();#line 121 "orasta370.pc"}#line 121 "orasta370.pc"/* printf ("Procesando el select list ...n"); */
  • 267. process_select_list();/* printf ("Liberando memoria ...n"); */ liberar_memoria(); return 0;}char *pasar_amayus (char *cadena ) { int pos=0; printf ("Iniciando conversion n"); for (pos =0; pos < (int ) strlen (cadena); pos ++) cadena[pos]=toupper(cadena[pos]); return cadena; }liberar_memoria () { int i; for (i = 0; i < MAX_ITEMS; i++) { if (bind_dp->V[i] != (char *) 0) free(bind_dp->V[i]); free(bind_dp->I[i]); if (select_dp->V[i] != (char *) 0) free(select_dp->V[i]); free(select_dp->I[i]); }/* OJO CON ESTO *//* sqlclu(bind_dp); *//* sqlclu(select_dp); */ /* EXEC SQL WHENEVER SQLERROR CONTINUE; */#line 160 "orasta370.pc" /* EXEC SQL CLOSE C; */
  • 268. #line 161 "orasta370.pc"{#line 161 "orasta370.pc" struct sqlexd sqlstm;#line 161 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 161 "orasta370.pc" sqlstm.sqlvsn = 10;#line 161 "orasta370.pc" sqlstm.arrsiz = 1;#line 161 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 161 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 161 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 161 "orasta370.pc" sqlstm.offset = (unsigned int )43;#line 161 "orasta370.pc" sqlstm.cud = sqlcud0;#line 161 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 161 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 161 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 161 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 161 "orasta370.pc"}#line 161 "orasta370.pc" /* EXEC SQL COMMIT WORK RELEASE; */#line 162 "orasta370.pc"{#line 162 "orasta370.pc" struct sqlexd sqlstm;
  • 269. #line 162 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 162 "orasta370.pc" sqlstm.sqlvsn = 10;#line 162 "orasta370.pc" sqlstm.arrsiz = 1;#line 162 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 162 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 162 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 162 "orasta370.pc" sqlstm.offset = (unsigned int )58;#line 162 "orasta370.pc" sqlstm.cud = sqlcud0;#line 162 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 162 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 162 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 162 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 162 "orasta370.pc"}#line 162 "orasta370.pc" /* EXEC SQL WHENEVER SQLERROR DO sql_error(); */#line 163 "orasta370.pc" exit(1); }oracle_connect (char *datos_conexion, int version) { /* EXEC SQL BEGIN DECLARE SECTION; */#line 170 "orasta370.pc"
  • 270. /* VARCHAR connectstring[256]; */struct { unsigned short len; unsigned char arr[256]; } connectstring;#line 171 "orasta370.pc" /* EXEC SQL END DECLARE SECTION; */#line 172 "orasta370.pc"/* printf ("Datos de conexion %s n",datos_conexion); */ strcpy ((char *) connectstring.arr,datos_conexion); connectstring.arr[strlen((char *) connectstring.arr)] = FIN_LINEA; connectstring.len = (unsigned short )strlen((char *) connectstring.arr); /* EXEC SQL WHENEVER SQLERROR GOTO connect_error; */#line 179 "orasta370.pc" printf ("nConnecting .....n"); /* EXEC SQL CONNECT :connectstring; */#line 183 "orasta370.pc"{#line 183 "orasta370.pc" struct sqlexd sqlstm;#line 183 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 183 "orasta370.pc" sqlstm.sqlvsn = 10;#line 183 "orasta370.pc" sqlstm.arrsiz = 4;#line 183 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 183 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 183 "orasta370.pc" sqlstm.iters = (unsigned int )10;#line 183 "orasta370.pc" sqlstm.offset = (unsigned int )73;
  • 271. #line 183 "orasta370.pc" sqlstm.cud = sqlcud0;#line 183 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 183 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 183 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 183 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)&connectstring;#line 183 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )258;#line 183 "orasta370.pc" sqlstm.sqhsts[0] = ( int )258;#line 183 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 183 "orasta370.pc" sqlstm.sqinds[0] = ( int )0;#line 183 "orasta370.pc" sqlstm.sqharm[0] = (unsigned int )0;#line 183 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 183 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 183 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 183 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 183 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 183 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 183 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 183 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 183 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 183 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;
  • 272. #line 183 "orasta370.pc" sqlstm.sqptdso = sqlstm.sqtdso;#line 183 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 183 "orasta370.pc" if (sqlca.sqlcode < 0) goto connect_error;#line 183 "orasta370.pc"}#line 183 "orasta370.pc" printf("nConnected to ORACLE [%d] n",version); return 0; connect_error: fprintf(stderr,"Cannot connect to ORACLEn"); return -1; }alloc_descriptors(size, max_vname_len, max_iname_len) int size; int max_vname_len; int max_iname_len; { int i; if ((bind_dp = sqlald(size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; } if ((select_dp = sqlald (size, max_vname_len, max_iname_len)) == (SQLDA *) 0) { fprintf(stderr,"Insuficient memory..."); return -1; } select_dp->N = MAX_ITEMS; for (i = 0; i < MAX_ITEMS; i++)
  • 273. { bind_dp->I[i] = (short *) malloc(sizeof (short)); select_dp->I[i] = (short *) malloc(sizeof(short)); bind_dp->V[i] = (char *) malloc(1); select_dp->V[i] = (char *) malloc(1); } return 0; }set_bind_variables() { int i, n; char bind_var [MAX_BIND_VARIABLE]; /* EXEC SQL WHENEVER SQLERROR DO sql_error(); */#line 228 "orasta370.pc" bind_dp->N = MAX_ITEMS; /* EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp; */#line 230 "orasta370.pc"{#line 230 "orasta370.pc" struct sqlexd sqlstm;#line 230 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 230 "orasta370.pc" sqlstm.sqlvsn = 10;#line 230 "orasta370.pc" sqlstm.arrsiz = 4;#line 230 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 230 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 230 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 230 "orasta370.pc" sqlstm.offset = (unsigned int )104;#line 230 "orasta370.pc"
  • 274. sqlstm.cud = sqlcud0;#line 230 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 230 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 230 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 230 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)bind_dp;#line 230 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )0;#line 230 "orasta370.pc" sqlstm.sqhsts[0] = ( int )0;#line 230 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 230 "orasta370.pc" sqlstm.sqinds[0] = ( int )0;#line 230 "orasta370.pc" sqlstm.sqharm[0] = (unsigned int )0;#line 230 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 230 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 230 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 230 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 230 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 230 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 230 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 230 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 230 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 230 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;#line 230 "orasta370.pc"
  • 275. sqlstm.sqptdso = sqlstm.sqtdso;#line 230 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 230 "orasta370.pc" if (sqlca.sqlcode < 0) sql_error();#line 230 "orasta370.pc"}#line 230 "orasta370.pc" if (bind_dp->F < 0) { printf ("nToo many variables to bind...n", -bind_dp->F, MAX_ITEMS); return; } bind_dp->N = bind_dp->F; for (i = 0; i < bind_dp->F; i++) { printf ("nEnter value for bind variable %.*s: ",(int)bind_dp->C[i], bind_dp->S[i]); fgets (bind_var, (int )sizeof(bind_var), stdin); n = (int )strlen(bind_var) - 1; bind_dp->L[i] = n; bind_dp->V[i] = (char *) realloc(bind_dp->V[i], (bind_dp->L[i] + 1)); strncpy(bind_dp->V[i], bind_var, n); if ((strncmp(bind_dp->V[i], "NULL", 4) == 0) || (strncmp(bind_dp->V[i], "null", 4) == 0)) *bind_dp->I[i] = -1; else *bind_dp->I[i] = 0; bind_dp->T[i] = 1; } return 0; }process_select_list() { int i, j, k, null_ok, numero;
  • 276. int nro_bytes=0; if ((strncmp(dyn_sts, "SELECT", 6) != 0) && (strncmp(dyn_sts, "select", 6) != 0)) { select_dp->F = 0; return; } select_dp->N = MAX_ITEMS; /* EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp; */#line 271 "orasta370.pc"{#line 271 "orasta370.pc" struct sqlexd sqlstm;#line 271 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 271 "orasta370.pc" sqlstm.sqlvsn = 10;#line 271 "orasta370.pc" sqlstm.arrsiz = 4;#line 271 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 271 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 271 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 271 "orasta370.pc" sqlstm.offset = (unsigned int )123;#line 271 "orasta370.pc" sqlstm.cud = sqlcud0;#line 271 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 271 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 271 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 271 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)select_dp;
  • 277. #line 271 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )0;#line 271 "orasta370.pc" sqlstm.sqhsts[0] = ( int )0;#line 271 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 271 "orasta370.pc" sqlstm.sqinds[0] = ( int )0;#line 271 "orasta370.pc" sqlstm.sqharm[0] = (unsigned int )0;#line 271 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 271 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 271 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 271 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 271 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 271 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 271 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 271 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 271 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 271 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;#line 271 "orasta370.pc" sqlstm.sqptdso = sqlstm.sqtdso;#line 271 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 271 "orasta370.pc" if (sqlca.sqlcode < 0) sql_error();#line 271 "orasta370.pc"}#line 271 "orasta370.pc"
  • 278. if (select_dp->F < 0) { printf ("nToo many select-list items (%d), maximum is %dn", -(select_dp->F), MAX_ITEMS); return; } select_dp->N = select_dp->F; printf ("%s n",dyn_title); for (i = 0; i < select_dp->F; i++) { sqlnul ( &(select_dp->T[i]), &(select_dp->T[i]), &null_ok); numero=col_size(dyn_size,i); select_dp->L[i]= numero; select_dp->C[i]= numero; select_dp->T[i]=1; } for (i = 0; i < select_dp->F; i++) { nro_bytes = sizeof (select_dp->V[i]); select_dp->V[i] = (char *) realloc(select_dp->V[i], select_dp->L[i]); printf ("["); numero=col_size(dyn_size,i); procesar_encabe (numero,i,dyn_column); printf ("] "); } printf ("n"); /* EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop; */#line 299 "orasta370.pc" for ( ; ; ) { /* LIMPIANDO LA VARIABLE PARA VOLVER A UTILIZARSE *//* for (k=0; k < select_dp->F; k++) for (j=0; j < select_dp->L[k]; j++) (char )(select_dp->V[k])[j]=FIN_LINEA;*/ /* LIMPIANDO LA VARIABLE PARA VOLVER A UTILIZARSE */
  • 279. /* vaciar_estructura ( select_dp ); */ /* EXEC SQL FETCH C USING DESCRIPTOR select_dp; */#line 312 "orasta370.pc"{#line 312 "orasta370.pc" struct sqlexd sqlstm;#line 312 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 312 "orasta370.pc" sqlstm.sqlvsn = 10;#line 312 "orasta370.pc" sqlstm.arrsiz = 4;#line 312 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 312 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 312 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 312 "orasta370.pc" sqlstm.offset = (unsigned int )142;#line 312 "orasta370.pc" sqlstm.cud = sqlcud0;#line 312 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 312 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 312 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 312 "orasta370.pc" sqlstm.sqhstv[0] = ( void *)select_dp;#line 312 "orasta370.pc" sqlstm.sqhstl[0] = (unsigned int )0;#line 312 "orasta370.pc" sqlstm.sqhsts[0] = ( int )0;#line 312 "orasta370.pc" sqlstm.sqindv[0] = ( void *)0;#line 312 "orasta370.pc"
  • 280. sqlstm.sqinds[0] = ( int )0;#line 312 "orasta370.pc" sqlstm.sqharm[0] = (unsigned int )0;#line 312 "orasta370.pc" sqlstm.sqadto[0] = (unsigned short )0;#line 312 "orasta370.pc" sqlstm.sqtdso[0] = (unsigned short )0;#line 312 "orasta370.pc" sqlstm.sqphsv = sqlstm.sqhstv;#line 312 "orasta370.pc" sqlstm.sqphsl = sqlstm.sqhstl;#line 312 "orasta370.pc" sqlstm.sqphss = sqlstm.sqhsts;#line 312 "orasta370.pc" sqlstm.sqpind = sqlstm.sqindv;#line 312 "orasta370.pc" sqlstm.sqpins = sqlstm.sqinds;#line 312 "orasta370.pc" sqlstm.sqparm = sqlstm.sqharm;#line 312 "orasta370.pc" sqlstm.sqparc = sqlstm.sqharc;#line 312 "orasta370.pc" sqlstm.sqpadto = sqlstm.sqadto;#line 312 "orasta370.pc" sqlstm.sqptdso = sqlstm.sqtdso;#line 312 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 312 "orasta370.pc" if (sqlca.sqlcode == 1403) goto end_select_loop;#line 312 "orasta370.pc" if (sqlca.sqlcode < 0) sql_error();#line 312 "orasta370.pc"}#line 312 "orasta370.pc" for (i = 0; i < select_dp->F; i++) { printf (" "); numero=col_size(dyn_size,i);
  • 281. procesar_cadena (numero,(char *)select_dp->V[i]); printf (" "); } printf ("n"); } end_select_loop: return; }sql_error() { /* int i; */ printf ("nn%.70sn",sqlca.sqlerrm.sqlerrmc); if (parse_flag) printf("n Error de Oracle... n",sqlca.sqlerrd[4]); /* EXEC SQL WHENEVER SQLERROR CONTINUE; */#line 333 "orasta370.pc" /* EXEC SQL ROLLBACK WORK; */#line 334 "orasta370.pc"{#line 334 "orasta370.pc" struct sqlexd sqlstm;#line 334 "orasta370.pc" sqlorat((void **)0, &sqlctx, &oraca);#line 334 "orasta370.pc" sqlstm.sqlvsn = 10;#line 334 "orasta370.pc" sqlstm.arrsiz = 4;#line 334 "orasta370.pc" sqlstm.sqladtp = &sqladt;#line 334 "orasta370.pc" sqlstm.sqltdsp = &sqltds;#line 334 "orasta370.pc" sqlstm.iters = (unsigned int )1;#line 334 "orasta370.pc" sqlstm.offset = (unsigned int )161;#line 334 "orasta370.pc"
  • 282. sqlstm.cud = sqlcud0;#line 334 "orasta370.pc" sqlstm.sqlest = (unsigned char *)&sqlca;#line 334 "orasta370.pc" sqlstm.sqlety = (unsigned short)256;#line 334 "orasta370.pc" sqlstm.occurs = (unsigned int )0;#line 334 "orasta370.pc" sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);#line 334 "orasta370.pc"}#line 334 "orasta370.pc" liberar_memoria(); }cargar_sentencia (int version, int sentencia, char *opcion_uno, char *opcion_dos, char *opcion_tres ) { switch (sentencia) { case 0: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|ORACLE_VERSION|"); strcpy (dyn_title,"Oracle Version ...n"); strcpy (dyn_sts,"select ltrim(lpad(banner,70)) Version from v$version "); strcat (dyn_sts,"where banner like %Oracle% "); strcpy (dyn_size,"80"); break; case 1: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|NOMBRE|VALOR|DESCRIPCION|"); strcpy (dyn_title,"Active Parameters ...n"); strcpy (dyn_sts,"select name,value,description from v$parameter order by 1 "); strcpy (dyn_size,"355540"); break; case 2: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|DIRECCION|SES|NOMBRE|CMD|ESTADO|PID|TERMINAL|INICIADO|"); strcpy (dyn_title,"User conected...n");
  • 283. strcpy (dyn_sts,"select saddr ADDRESS,sid SES,username NOMBRE,command CMD, n"); strcat (dyn_sts,"status ESTADO,process PID,terminal TERMINAL, n"); strcat (dyn_sts,"to_char(logon_time,DD/MM/YYYY - HH24:MI:SS) INICIADO from v$session "); strcpy (dyn_size,"0804150608091122"); break;case 3: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|CANTIDAD|TIEMPO|CLASE|"); strcpy (dyn_title,"User conected...n"); strcpy (dyn_title,"Wait Statistics...n"); strcpy (dyn_sts,"select count CANTIDAD,time TIEMPO,class CLASE from v$waitstat order by 1 "); strcpy (dyn_size,"101030"); break;case 4: strcpy (dyn_title,"Datafile I-O ...n"); switch (version) { case VERSION_ORACLE_920: strcpy (dyn_column,"|READPHY|READBLK|WRITPHY||WRITBLK|DATAFILE|IO_STAT|"); 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 by 2 n"); strcpy (dyn_size,"080808086010"); break; case VERSION_ORACLE_817: case VERSION_ORACLE_816: case VERSION_ORACLE_734: strcpy (dyn_column,"|READPHY|READBLK|WRITPHY|WRITBLK|DATAFILE|"); strcpy (dyn_sts,"select f.phyrds, f.phyblkrd, f.phywrts, "); strcat (dyn_sts,"f.phyblkwrt, d.name "); strcat (dyn_sts,"from v$filestat f,v$datafile d "); strcat (dyn_sts,"where f.file# = d.file# "); strcat (dyn_sts,"order by 2 n"); strcpy (dyn_size,"0606060660"); break; default: break; }
  • 284. break;case 5: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|DATAFILE|BLKREAD|BLKWRITE|BLKTOT|"); strcpy (dyn_title,"Datafile Blocks R+W ...n"); strcpy (dyn_sts,"select d.name DATAFILE, f.phyblkrd BLK_READ, f.phyblkwrt BLK_WRITE, n"); strcat (dyn_sts,"f.phyblkrd+f.phyblkwrt BLK_TOTAL from v$filestat f, v$datafile d n"); strcat (dyn_sts,"where f.file# = d.file# order by 3 desc "); strcpy (dyn_size,"60060606"); break;case 6: /********** PARA TODAS LAS VERSIONES **********/ strcpy (dyn_column,"|USUARIO|CANTIDAD|EVENTO|"); strcpy (dyn_title,"Wait Events ...n"); strcpy (dyn_sts,"select se.username USUARIO,count(*) CANTIDAD,sw.event EVENTO n"); strcat (dyn_sts,"from v$session se, v$session_wait sw where sw.sid=se.sid and n"); strcat (dyn_sts,"se.username > A and sw.event not like SQL*Net% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Table Q Normal% and n"); strcat (dyn_sts,"sw.event not like PX Deq: Execution Msg% and n"); strcat (dyn_sts,"sw.event not like pipe get% group by se.username, sw.event "); strcpy (dyn_size,"201030"); break;case 7: strcpy (dyn_title,"Instance status ...n"); switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|INSTNRO|INSTNAME|HOSTNAME|VERSION|INICIADO|ESTADO|PARALELO|DATAESTA|INSTROLE|ACTSTATUS|"); strcpy (dyn_title,"Instance status ...n"); strcpy (dyn_sts,"select instance_number, instance_name, host_name, version, n"); strcat (dyn_sts,"to_char(startup_time,DD/MM/YYYY - HH24:MI:SS),status, parallel, n"); strcat (dyn_sts,"database_status, instance_role n"); strcat (dyn_sts,"from v$instance n"); strcpy (dyn_size,"03080910220503101010"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|NOMBRE DE CLAVE|ESTADO|"); strcpy (dyn_title,"Instance status ...n");
  • 285. strcpy (dyn_sts,"select RESTRITED MODE,value "); strcat (dyn_sts,"from v$instance where key=RESTRICTED MODE "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select SHUTDOWN PENDING,value "); strcat (dyn_sts,"from v$instance where key=SHUTDOWN PENDING "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select STARTUP TIME - JULIAN,value "); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - JULIAN "); strcat (dyn_sts,"union "); strcat (dyn_sts,"select STARTUP TIME - SECONDS, value "); strcat (dyn_sts,"from v$instance where key=STARTUP TIME - SECONDS n"); strcpy (dyn_size,"4015"); break; default: break; } break;case 8: switch (version) { case VERSION_ORACLE_816: case VERSION_ORACLE_817: case VERSION_ORACLE_920: strcpy (dyn_column,"|SES|SERIAL|USER|EXTENTS|CONTENTS|SIZEKB"); strcpy (dyn_title,"Temporal Space by user ...n"); strcpy (dyn_sts,"select se.sid, se.serial#, se.username, so.extents, so.contents, n"); strcat (dyn_sts,"sum((so.blocks)*(select value 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 by se.sid,se.serial#,se.username,so.extents,so.contents n"); strcpy (dyn_size,"101010101030"); break; case VERSION_ORACLE_734: strcpy (dyn_column,"|SES|SERIAL|USER|EXTENTS|CONTENTS|SIZEKB"); strcpy (dyn_title,"Temporal Space by user ...n"); strcpy (dyn_sts,"select se.sid, se.serial#, se.username, so.extents, so.contents, n"); strcat (dyn_sts,"sum((so.blocks)*(select value 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 by se.sid,se.serial#,se.username,so.extents,so.contents n");
  • 286. strcpy (dyn_size,"101010101030"); default: break; } break;case 9: strcpy (dyn_column,"|PCTFREE|"); strcpy (dyn_title,"Total Freelist Wait Percentage ...n"); strcpy (dyn_sts,"select (a.count/sum(b.value))*100 PCT_FREELIST from v$waitstat a, n"); strcat (dyn_sts,"v$sysstat b where a.class=free list and n"); strcat (dyn_sts,"b.name in (db block gets,consistent gets) group by a.count "); strcpy (dyn_size,"12"); break;case 10: strcpy (dyn_column,"|CHEKPOINT_VALUE|FECHA|"); strcpy (dyn_title,"Last Checkpoint Time ...n"); 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 from v$datafile_header"); strcpy (dyn_size,"1522"); break;case 11: strcpy (dyn_column,"|TBLSPACE|CONTENT|AVAILA_KB|MAX_ID|USED_KB|FREE_KB|PCT_USED|"); strcpy (dyn_title,"List Tablespaces ...n"); strcpy (dyn_sts,"select a.tablespace_name TBL_NAME,d.contents CONTENT,a.sum_bytes/1048576 AVAILA_KB, n"); strcat (dyn_sts,"a.max_id MAX_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 (select tablespace_name,sum(bytes) sum_bytes, n"); strcat (dyn_sts,"count(1) max_id from dba_data_files group by tablespace_name ) a, n"); strcat (dyn_sts,"(select tablespace_name,sum(bytes) sum_bytes from dba_free_space n"); strcat (dyn_sts,"group by tablespace_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 1 "); strcpy (dyn_size,"151010061010070810101010"); break;case 12: strcpy (dyn_column,"|ADDRESS|TIMESTART|ESTADO|BLK_USED|KB_USED|SES|SERIAL|NOMBRE|USUARIO|"); strcpy (dyn_title,"Active Transactions ...n"); strcpy (dyn_sts,"select tr.addr,to_char(tr.start_time,DD/MM/YYYY - 24HH:MM:SS) TIME_START, n"); strcat (dyn_sts,"tr.status ESTADO,tr.used_ublk BLK_USED,tr.used_ublk*(select value n");
  • 287. strcat (dyn_sts,"from v$parameter where name in db_block_size)/1000 KB_USED,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.saddr order by 6"); strcpy (dyn_size,"102208080810040605101010"); break; case 13: strcpy (dyn_column,"|GETS|MISS|HITRATIO|IMM_GETS|IMM_MISS|SLEEP|GETSPIN|ADDRESS|LATCH|NOMBRE|"); strcpy (dyn_title,"Latch Details ...n"); strcpy (dyn_sts,"select gets GETS,misses MISS,round((gets-misses)*100/gets,2) HITRATIO, n"); strcat (dyn_sts,"immediate_gets IMM_GETS,immediate_misses IMM_MISS,sleeps SLEEP, n"); strcat (dyn_sts,"spin_gets GETSPIN,addr ADDR,latch#,name NOMBRE from v$latch n"); strcat (dyn_sts,"where misses > 0 and gets > 0 order by round(((gets-misses)/gets),2) desc"); strcpy (dyn_size,"10040808080507080825"); break; case 14: strcpy (dyn_column,"|NOMBRE|INIT_ALLOC|CURR_UTILIZA|MAX_UTILIZA|LIMITE|"); strcpy (dyn_title,"Resource Limits ...n"); strcpy (dyn_sts,"select resource_name NOMBRE,initial_allocation INIT_ALLOC, n"); strcat (dyn_sts,"current_utilization CURR_UTILIZA,max_utilization MAX_UTILIZA, n"); strcat (dyn_sts,"limit_value LIMITE from v$resource_limit order by 1"); strcpy (dyn_size,"3010101010"); break; case 15: strcpy (dyn_column,"|DATAFILE|MBYTES|ESTADO|"); strcpy (dyn_title,"List Datafiles ...n"); strcpy (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$datafile n"); strcat (dyn_sts,"union all n"); strcat (dyn_sts,"select name DATAFILE,bytes/1048576 MBYTES, status ESTADO from v$tempfile n"); strcpy (dyn_size,"701008"); break; case 16: strcpy (dyn_column,"|ESTADO|DATAFILE|TBLSPACE|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Datafiles New 9i ...n"); 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_files d, v$datafile v, (select file_id,sum(bytes) bytes n");
  • 288. strcat (dyn_sts,"from sys.dba_free_space group by file_id) s n"); strcat (dyn_sts,"where s.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_files d, v$temp_extent_pool t, v$tempfile v n"); strcat (dyn_sts,"where t.file_id(+)=d.file_id and d.file_id=v.file# n"); strcpy (dyn_size,"036018121208"); break; case 17: strcpy (dyn_column,"|ESTADO|TBLSPACE|TIPO|EXTENT_MGM|SIZE_KB|USED_KB|USED_PCT|"); strcpy (dyn_title,"List Tablespaces New 9i...n"); strcpy (dyn_sts,"select d.status ESTADO, d.tablespace_name TBLNAME,d.contents TIPO, n"); strcat (dyn_sts,"d.extent_management EXTENT_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,"from sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes n"); strcat (dyn_sts,"from dba_data_files group by tablespace_name) a, (select tablespace_name,sum(bytes) bytes n"); strcat (dyn_sts,"from dba_free_space group by tablespace_name ) f n"); strcat (dyn_sts,"where d.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_management EXTENT_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 from sys.dba_tablespaces d, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a, n"); strcat (dyn_sts,"(select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool n"); strcat (dyn_sts,"group by tablespace_name) t where d.tablespace_name=a.tablespace_name (+) and n"); strcat (dyn_sts,"d.tablespace_name=t.tablespace_name (+) and d.extent_management like LOCAL and n"); strcat (dyn_sts,"d.contents like TEMPORARY "); strcpy (dyn_size,"06251012121212121212121010101010"); break; case 18:
  • 289. strcpy (dyn_column,"|SES|SERIAL|TIPO|OS_USER|LOGON|ESTADO|PROCESO|MAQUINA|NOMBRE|PID|PROGRAMA|"); strcpy (dyn_title,"Active Sessions ...n"); 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.program PROGRAMA n"); strcat (dyn_sts,"from v$session s, v$process p n"); strcat (dyn_sts,"where osuser is not null and p.addr=s.paddr n"); strcpy (dyn_size,"0404101022100910100930"); break;case 19: strcpy (dyn_column,"|SES|SEQ|W_T|S_W_T|USUARIO|ESTADO|EVENT|STATE|P1TEXT|P1|P1RAW|P2TEXT|P2|P2RAW|P3TEXT|P3|P3RAW|"); strcpy (dyn_title,"Session Waits n"); 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 se n"); strcat (dyn_sts,"where sw.sid = se.sid order b