The fuction is from_tz
SELECT FROM_TZ(to_timestamp(to_char(systimestamp,'DD-MON-YYYY HH:MI:SS PM')) ,'+05:30') AT TIME ZONE '-06:00',systimestamp from dual;
and one more fn.
select LOCALTIMESTAMP AT TIME ZONE '-6:00' from dual;
Having 17 year of experince in variety of field including 14 year as IT and As a Oracle DBA Having 7 year of Experince With PT , Backup and Recovery , Database Migration (sql to ORACLE ),Creating Stand By Database. New Projects Installation. Have experice in any kind of Trouble shooting in Database. Knowledge of RAC and Dataguard. Financial prospective of projects and cost reduction
Wednesday, September 16, 2009
Monday, September 14, 2009
ORA-31626 - ORA-31650
Error is as below:-
/*****************************************************************/
-bash-3.00$ expdp "'/ as sysdba'" directory=backup dumpfile=full_expor_1.dmp
logfile=full_export_1.log schemas=scoot
Export: Release 10.2.0.1.0 - Production on Monday, 14 September, 2009 11:04:37
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-31626: job does not exist
ORA-31650: timeout waiting for master process response
/****************************************************************************/
solution :-
select Table_name from dba_tables where table_name like '%EXPORT%' and owner='SYS';
Delete all the Table Created by Export Utility while Creating the Metadata.
/*****************************************************************/
-bash-3.00$ expdp "'/ as sysdba'" directory=backup dumpfile=full_expor_1.dmp
logfile=full_export_1.log schemas=scoot
Export: Release 10.2.0.1.0 - Production on Monday, 14 September, 2009 11:04:37
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-31626: job does not exist
ORA-31650: timeout waiting for master process response
/****************************************************************************/
solution :-
select Table_name from dba_tables where table_name like '%EXPORT%' and owner='SYS';
Delete all the Table Created by Export Utility while Creating the Metadata.
Friday, September 11, 2009
Oracle Table OUTPUT to CSV
(1st Method)
set colsep ','
set pagesize 0
set feedback off
set trimspool on
set linesize 1000
spool myfile.csv
select * from mytable;
spool off
(2nd Method)
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue,
2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
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 := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
/
You would use that for example like this:
create or replace procedure test_dump_csv
as
l_rows number;
begin
l_rows := dump_csv( 'select *
from all_users
where rownum < 25',
',', '/tmp', 'test.dat' );
end;
/
set colsep ','
set pagesize 0
set feedback off
set trimspool on
set linesize 1000
spool myfile.csv
select * from mytable;
spool off
(2nd Method)
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2
default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
AUTHID CURRENT_USER
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i,
l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue,
2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
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 := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
/
You would use that for example like this:
create or replace procedure test_dump_csv
as
l_rows number;
begin
l_rows := dump_csv( 'select *
from all_users
where rownum < 25',
',', '/tmp', 'test.dat' );
end;
/
Subscribe to:
Comments (Atom)