28 April 2010

Renaming an Oracle database

The following log shows how a database name was renamed from ORA9 to CAT.
SQL> select name from v$database;

19 April 2010

Oracle hash function

use of function
select dbms_utility.get_hash_value('your string', 999999, 32768) from dual

05 April 2010

Oracle read/write into file

Write to file
declare
  output utl_file.file_type;
  line   varchar2(20000);
begin
--  execute immediate 'alter session set NLS_CHARACTERSET = CL8MSWIN1251';
  output := utl_file.fopen(location => 'directory_name', filename => to_char(sysdate, 'file_name', open_mode => 'A');
  for rec in
    ()
  loop
    line := rec.field1|| '|' || rec.field2 || '|' || rec.field3 || '|' || rec.field4 || '|' || rec.field5;
    utl_file.put(output, line); 
    utl_file.new_line(file => output);
  end loop;
  utl_file.fclose(file => output);
end;