Pruebas parámetro commit_write desde Oracle-base
http://www.oracle-base.com/articles/10g/Commit_10gR2.php
create table commit_test (id number, description varchar2(100));
SET SERVEROUTPUT ON
DECLARE
PROCEDURE do_loop (p_type IN VARCHAR2) AS
l_start NUMBER;
l_loops NUMBER := 10000;
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE commit_test';
l_start := DBMS_UTILITY.get_time;
FOR i IN 1 .. l_loops LOOP
INSERT INTO commit_test (id, description)
VALUES (i, 'Description for ' || i);
CASE p_type
WHEN 'NORMAL' THEN COMMIT;
WHEN 'WAIT' THEN COMMIT WRITE WAIT;
WHEN 'NOWAIT' THEN COMMIT WRITE NOWAIT;
WHEN 'BATCH' THEN COMMIT WRITE BATCH NOWAIT;
WHEN 'IMMEDIATE' THEN COMMIT WRITE IMMEDIATE;
END CASE;
END LOOP;
DBMS_OUTPUT.put_line(RPAD('COMMIT WRITE ' || p_type, 30) || ': ' || (DBMS_UTILITY.get_time - l_start));
END;
BEGIN
DO_LOOP('NORMAL');
--do_loop('WAIT');
--do_loop('NOWAIT');
--do_loop('BATCH');
--do_loop('IMMEDIATE');
END;
/
jueves, 23 de diciembre de 2010
jueves, 2 de diciembre de 2010
Script - Get_csv.sql
Script para generar ficheros csv, xls directamente a partir de una consulta dada, se pasa como parámetros la consulta, el fichero a generar y la ubicación en el cliente para generar el fichero.
set wrap on
REM SET TERMOUT OFF
set serveroutput on size 1000000
set verify off
set linesize 434
set trimspool on
SET ECHO OFF
SET DOCUMENT OFF
SET FEEDBACK OFF
SET HEADING OFF
SET PAGESIZE 0
SET NEWPAGE 0
Set pages 999;
SET LINESIZE 15000 PAGESIZE 0 FEEDBACK off VERIFY off TRIMSPOOL on LONG 1000000
PROMPT Introduzca la consulta para generar la salida: (select * from user_tables, ...)
accept cons
PROMPT
PROMPT Introduzca el nombre del fichero a generar: (Listado_20101202.csv, Indicadores_20101202.csv, ...)
accept nom
PROMPT
PROMPT Introduzca la ubicación de la salida: (c:\frank25\marzo\06\, <vacio> para generar en dir. SQL)
accept ubi
spool &&ubi&&nom
declare
procedure genera_subs_dump_to_csv( l_query in varchar2)
is
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(4000);
l_status integer;
l_colCnt number := 0;
l_separator varchar2(1);
l_descTbl dbms_sql.desc_tab;
begin
execute immediate 'alter session set nls_date_format=''dd/mm/yyyy hh24:mi:ss'' ';
dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
for i in 1 .. l_colCnt loop
dbms_output.put(l_separator || '"' || l_descTbl(i).col_name || '"' );
dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
l_separator := ';';
end loop;
dbms_output.new_line;
l_status := dbms_sql.execute(l_theCursor);
while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i, l_columnValue );
dbms_output.put(l_separator || l_columnValue );
l_separator := ';';
end loop;
dbms_output.new_line;
end loop;
dbms_sql.close_cursor(l_theCursor);
exception
when others then
raise;
end;
begin
genera_subs_dump_to_csv( '&&cons');
end;
/
spool off;
set wrap on
REM SET TERMOUT OFF
set serveroutput on size 1000000
set verify off
set linesize 434
set trimspool on
SET ECHO OFF
SET DOCUMENT OFF
SET FEEDBACK OFF
SET HEADING OFF
SET PAGESIZE 0
SET NEWPAGE 0
Set pages 999;
SET LINESIZE 15000 PAGESIZE 0 FEEDBACK off VERIFY off TRIMSPOOL on LONG 1000000
PROMPT Introduzca la consulta para generar la salida: (select * from user_tables, ...)
accept cons
PROMPT
PROMPT Introduzca el nombre del fichero a generar: (Listado_20101202.csv, Indicadores_20101202.csv, ...)
accept nom
PROMPT
PROMPT Introduzca la ubicación de la salida: (c:\frank25\marzo\06\, <vacio> para generar en dir. SQL)
accept ubi
spool &&ubi&&nom
declare
procedure genera_subs_dump_to_csv( l_query in varchar2)
is
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(4000);
l_status integer;
l_colCnt number := 0;
l_separator varchar2(1);
l_descTbl dbms_sql.desc_tab;
begin
execute immediate 'alter session set nls_date_format=''dd/mm/yyyy hh24:mi:ss'' ';
dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
for i in 1 .. l_colCnt loop
dbms_output.put(l_separator || '"' || l_descTbl(i).col_name || '"' );
dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
l_separator := ';';
end loop;
dbms_output.new_line;
l_status := dbms_sql.execute(l_theCursor);
while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i, l_columnValue );
dbms_output.put(l_separator || l_columnValue );
l_separator := ';';
end loop;
dbms_output.new_line;
end loop;
dbms_sql.close_cursor(l_theCursor);
exception
when others then
raise;
end;
begin
genera_subs_dump_to_csv( '&&cons');
end;
/
spool off;
Suscribirse a:
Entradas (Atom)