Denis Carraro
22 anni fa
Ciao a Tutti,
ho costruito una procedura che mi fa il Dump di una tabella in un file CSV e
funziona al 90%, mentre con alcune tabelle ho questo errore:
ERRORE alla riga 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 103
ORA-06512: at "SYS.UTL_FILE", line 120
ORA-06512: at "SYS.UTL_FILE", line 287
ORA-06512: at "CAPCARTASI1_O.DUMP_TABLE_TO_CSV_TKT", line 64
ORA-06512: at line 1
e non riesco a capire il xkè?
vi giro anche il codice:
PROCEDURE dump_table_to_csv_tkt( p_tname IN varchar2,p_dir IN varchar2,
p_filename IN varchar2 )
IS
/* *******************************************************************
** ------------------------------------------------------------------
** Copyright The Knowledge Team S.P.A 2003 - Denis Carraro
** ------------------------------------------------------------------
** NAME: dump_table_to_csv_tkt
**
** Scopo:
** Questa Procedura server per esportare una tabella passata come parametro
** tramite "p_tname" nel directory "p_dir" sul file "p_filename "
**
**
** Called by:
** Schedulata una volta al mese.
**
** Application Errors:
**
** Results SET:
** <none>
**
**
****************************************************************************
**
** Change History
**
****************************************************************************
**
** Rev DATE NAME Description
** 01 25/06/2003 Denis Carraro Original Implementation
**
****************************************************************************
**
*/
l_output utl_file.file_type;
l_theCursor INTEGER DEFAULT dbms_sql.open_cursor;
l_columnValue varchar2(4000);
l_status INTEGER;
l_query varchar2(1000)
DEFAULT 'select * from ' || p_tname;
l_colCnt NUMBER := 0;
l_separator varchar2(1);
l_descTbl dbms_sql.desc_tab;
BEGIN
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mon-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
utl_file.put( l_output, l_separator || '"' || l_descTbl(i).col_name ||
'"' );
dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
l_separator := ',';
-- dbms_output.put_line(l_descTbl(i).col_name);
END loop;
utl_file.new_line( l_output );
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 );
utl_file.put( l_output, l_separator || l_columnValue );
l_separator := ',';
END loop;
utl_file.new_line( l_output );
END loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
-- EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy'' ';
-- EXCEPTION
-- WHEN others THEN
-- EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy''';
-- raise;
END;
Aiutatemi :''''''''''''''''''''(
ho costruito una procedura che mi fa il Dump di una tabella in un file CSV e
funziona al 90%, mentre con alcune tabelle ho questo errore:
ERRORE alla riga 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 103
ORA-06512: at "SYS.UTL_FILE", line 120
ORA-06512: at "SYS.UTL_FILE", line 287
ORA-06512: at "CAPCARTASI1_O.DUMP_TABLE_TO_CSV_TKT", line 64
ORA-06512: at line 1
e non riesco a capire il xkè?
vi giro anche il codice:
PROCEDURE dump_table_to_csv_tkt( p_tname IN varchar2,p_dir IN varchar2,
p_filename IN varchar2 )
IS
/* *******************************************************************
** ------------------------------------------------------------------
** Copyright The Knowledge Team S.P.A 2003 - Denis Carraro
** ------------------------------------------------------------------
** NAME: dump_table_to_csv_tkt
**
** Scopo:
** Questa Procedura server per esportare una tabella passata come parametro
** tramite "p_tname" nel directory "p_dir" sul file "p_filename "
**
**
** Called by:
** Schedulata una volta al mese.
**
** Application Errors:
**
** Results SET:
** <none>
**
**
****************************************************************************
**
** Change History
**
****************************************************************************
**
** Rev DATE NAME Description
** 01 25/06/2003 Denis Carraro Original Implementation
**
****************************************************************************
**
*/
l_output utl_file.file_type;
l_theCursor INTEGER DEFAULT dbms_sql.open_cursor;
l_columnValue varchar2(4000);
l_status INTEGER;
l_query varchar2(1000)
DEFAULT 'select * from ' || p_tname;
l_colCnt NUMBER := 0;
l_separator varchar2(1);
l_descTbl dbms_sql.desc_tab;
BEGIN
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mon-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
utl_file.put( l_output, l_separator || '"' || l_descTbl(i).col_name ||
'"' );
dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
l_separator := ',';
-- dbms_output.put_line(l_descTbl(i).col_name);
END loop;
utl_file.new_line( l_output );
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 );
utl_file.put( l_output, l_separator || l_columnValue );
l_separator := ',';
END loop;
utl_file.new_line( l_output );
END loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
-- EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy'' ';
-- EXCEPTION
-- WHEN others THEN
-- EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-MON-yy''';
-- raise;
END;
Aiutatemi :''''''''''''''''''''(