Monday, July 16, 2012

ORA-00600: internal error code, arguments: [kcratr_nab_less_than_odr]

It is for instance crash for power failure/instance aborted.
so control file has been corrupted.

So solution is :-
======================


[Before trying any kind of recovery, cold backup the entire database first]


1) SQL> conn / as sysdba

2) SQL> shutdown immediate ;

3) SQL> startup mount ;

4) SQL>

SELECT a.MEMBER, a.group#, b.status
FROM v$logfile a, v$log b
WHERE a.group# = b.group# AND b.status = 'CURRENT'

5) SQL> shutdown abort ;

6) SQL> startup mount ;

7) SQL> recover database using backup controlfile until cancel ;

Enter location(a.MEMBER) of redo log what found by 4) number point.
if it is not in archivelog mode. if it is in archivelog mode please enter the asking archivelog location. then press enter

it will show.......
Log applied.
Media recovery complete.

8) SQL> Alter database open resetlogs ;

9) Take hot backup of the database immediate.







Tuesday, July 10, 2012

ORA-09817: Write to audit file failed

its because of full the Mount point where Oracle is installed .
check ..

$ df -k

and make some space where 100% is full.

for details see here
http://halimdba.blogspot.com/2011/10/ora-09945-unable-to-initialize-audit.html

How to insert image/pdf/multimedia or blob data to oracle database table from client machine without using database directory ?

steps are below..

1) first i have created a "d:/sql_ld_control_file.ctl" file for sql loader. contents are belows (no enter/line break is allowed in control file). here i am inserting four image files in t_image table.
=================================================
"d:/sql_ld_control_file.ctl"

---------------------------------

LOAD DATA
INFILE *
INTO TABLE scott.t_image
REPLACE
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
file_id INTEGER EXTERNAL(5),
fn BOUNDFILLER,
file_name "SUBSTR(:fn,INSTR(:fn,'\\',-1,1)+1,INSTR(:fn,'.')-INSTR(:fn,'\\',-1,1)-1)",
file_data LOBFILE (fn)
TERMINATED BY EOF
)
BEGINDATA
1,c:\image\Blue hills.jpg
2,c:\image\Sunset.jpg
3,c:\image\Water lilies.jpg
4,c:\image\Winter.jpg

------------------------------------
[note: file_name "SUBSTR(:fn,INSTR(:fn,'\\',-1,1)+1,INSTR(:fn,'.')-INSTR(:fn,'\\',-1,1)-1)",   will be in one line .]


2) follow the below steps
==================================
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Jul 10 12:28:53 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> conn scott@orcl251
Enter password:
Connected.
SQL>
SQL>
SQL> drop table t_image ;

Table dropped.

SQL>
SQL> CREATE TABLE t_image
  2   (file_id    NUMBER(5),
  3     file_name  VARCHAR2(30),
  4     file_data  BLOB)
  5  /

Table created.

SQL>
SQL>
SQL>
SQL> HOST SQLLDR scott/tiger@orcl251 CONTROL=d:/sql_ld_control_file.ctl

SQL*Loader: Release 10.2.0.1.0 - Production on Tue Jul 10 12:34:59 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Commit point reached - logical record count 3
Commit point reached - logical record count 4

SQL>
SQL>
SQL> SELECT file_id, file_name, DBMS_LOB.GETLENGTH (file_data) length
  2     FROM   t_image ;

   FILE_ID FILE_NAME                          LENGTH
---------- ------------------------------ ----------
         1 Blue hills                          28521
         2 Sunset                              71189
         3 Water lilies                        83794
         4 Winter                             105542

SQL>
SQL>
SQL>
SQL>
SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>

C:\Documents and Settings\Administrator>cd ..

C:\Documents and Settings>cd ..

C:\>

C:\>cd image

C:\image>dir

 Volume in drive C has no label.
 Volume Serial Number is 04B1-1B54

 Directory of C:\image

07/10/2012  12:33 PM   



          .
07/10/2012  12:33 PM              ..
04/14/2008  08:00 PM            28,521 Blue hills.jpg
04/14/2008  08:00 PM            71,189 Sunset.jpg
04/14/2008  08:00 PM            83,794 Water lilies.jpg
04/14/2008  08:00 PM           105,542 Winter.jpg
               4 File(s)        289,046 bytes
               2 Dir(s)   8,457,371,648 bytes free

C:\image>
C:\image>
C:\image>
C:\image>
C:\image>
C:\image>




Extra steps for Getting name list from command prompt (in windows)
======================================================


C:\image>
C:\image>
C:\image>
C:\image>dir *.jpg
 Volume in drive C has no label.
 Volume Serial Number is 04B1-1B54

 Directory of C:\image

04/14/2008  08:00 PM            28,521 Blue hills.jpg
04/14/2008  08:00 PM            71,189 Sunset.jpg
04/14/2008  08:00 PM            83,794 Water lilies.jpg
04/14/2008  08:00 PM           105,542 Winter.jpg
               4 File(s)        289,046 bytes
               0 Dir(s)   8,457,371,648 bytes free

C:\image>
C:\image>
C:\image>
C:\image>dir /b *.jpg > image_name_list.txt

C:\image>
C:\image>type image_name_list.txt
Blue hills.jpg
Sunset.jpg
Water lilies.jpg
Winter.jpg

C:\image>
C:\image>
C:\image>
C:\image>
C:\image>dir
 Volume in drive C has no label.
 Volume Serial Number is 04B1-1B54

 Directory of C:\image

07/10/2012  12:41 PM              .
07/10/2012  12:41 PM              ..
04/14/2008  08:00 PM            28,521 Blue hills.jpg
07/10/2012  12:41 PM                58 image_name_list.txt
04/14/2008  08:00 PM            71,189 Sunset.jpg
04/14/2008  08:00 PM            83,794 Water lilies.jpg
04/14/2008  08:00 PM           105,542 Winter.jpg
               5 File(s)        289,104 bytes
               2 Dir(s)   8,457,367,552 bytes free

C:\image>
C:\image>
C:\image>


How to insert multimedia or blob via directory see below..
http://halimdba.blogspot.com/2011/01/how-to-insert-multimedia-data-image.html

How to save blob data to disk see below..
http://halimdba.blogspot.com/2012/06/how-to-save-blob-data-to-disk-from.html


Wednesday, June 20, 2012

How to save blob data to disk from oracle table using UTL_FILE ?



How to Insert multimedia data (image, video) in oracle table


How to insert image/pdf/multimedia or blob data to oracle database table from client machine without using database directory ?


1)Create Directory Where multimedia resides.
===============================================


sql> create or replace directory temp as 'C:/dir_blob';


2)Grant read permission to the user who work with this directory.
===========================================================

sql> grant read on directory temp to test;


3)Create the Table which holds Lov object.

-- the storage table for the image file
CREATE TABLE image (
dname VARCHAR2(30), -- directory name
sname VARCHAR2(30), -- subdirectory name
fname VARCHAR2(30), -- file name
iblob BLOB); -- image file


4) insert data to table see here

http://halimdba.blogspot.com/2011/01/how-to-insert-multimedia-data-image.html



5) selecting table has multiple blob row
===========================================

SQL> select * from atmutl.image ;



DNAME SNAME FNAME IBLOB

TEMP1 This is Image Phoenix-documents.pdf (HUGEBLOB)
TEMP This is pdf1 Phoenix-documents1.pdf (HUGEBLOB)
TEMP2 This is pdf2 Phoenix-documents2.pdf (HUGEBLOB)




6) create a procedure (pass parameter directory name)
========================================================

CREATE OR REPLACE PROCEDURE atmutl.save_blob_jpg_to_disk_halim1 (
   p_directory   IN   VARCHAR2
)
IS
   v_blob        BLOB;
   v_start       NUMBER             := 1;
   v_bytelen     NUMBER             := 2000;
   v_len         NUMBER;
   v_raw         RAW (2000);
   v_x           NUMBER;
   v_output      UTL_FILE.file_type;
   v_file_name   VARCHAR2 (200);
BEGIN

   FOR i IN (SELECT DBMS_LOB.getlength (iblob) v_len, fname v_file_name,
                    iblob v_blob
               FROM atmutl.image
              WHERE ROWNUM <= 500)
  
   LOOP
      v_output :=
           UTL_FILE.fopen (p_directory, i.v_file_name || '.PDF', 'wb', 32760);
      v_x := i.v_len;
      v_start := 1;
      v_bytelen := 2000;

      WHILE v_start < i.v_len AND v_bytelen > 0
      LOOP
         DBMS_LOB.READ (i.v_blob, v_bytelen, v_start, v_raw);
         UTL_FILE.put_raw (v_output, v_raw);
         UTL_FILE.fflush (v_output);
         v_start := v_start + v_bytelen;
         v_x := v_x - v_bytelen;

         IF v_x < 2000
         THEN
            v_bytelen := v_x;
         END IF;
      END LOOP;

      UTL_FILE.fclose (v_output);
   END LOOP;
END save_blob_jpg_to_disk_halim1;
/



7) executing it   ----dirtory name is uppercase
----------------------------------------------------
EXEC atmutl.save_blob_jpg_to_disk_halim1('TEMP');










Announcing Certification of Oracle Database 11g R2 on Oracle Linux 6 and Redhat Linux 6


Oracle announce the general availability of the Oracle RDBMS Server 11gR2
Pre-Install RPM for Oracle Linux 6 x86_64 (64 Bit) architecture.

See more about

 Announcing: Oracle Database 11g R2 Certification on Oracle Linux 6
 
Public Yum Server


Oracle RDBMS Server 11gR2 Pre-Install RPM for Oracle Linux 6 x86_64 (64 Bit) architecture

Document library of oracle 11g Release 2 (11.2)