Wednesday, January 13, 2010

How to create TNS_ADMIN environment variable?

01. First, you have to create a directory whose name is "0_library", which is on a "C" disk.

02. Then you'll have to copy one of TNSNAMES.ORA files into that directory

03. Now it makes sense to point the TNS_ADMIN environment variable to the "c:\0_library" directory             because, if it doesn't exist or if it is empty, the whole TNS_ADMIN story doesn't make any sense

04. When necessary, maintain this TNSNAMES.ORA file; the rest of them (which are in their \network\admin           directories) should be renamed into, for example, TNSNAMES_OLD.ORA.

For furthure more
http://www.orafaq.com/forum/m/376523/72104/?srch=lengthy#msg_376523

Tuesday, December 29, 2009

Compress Blob Data

CREATE OR REPLACE FUNCTION  Fnc_Compress_Blob_Data
                                                               (pData in blob ,
                                                                pQuality in number default 6 )
                                                            -- pQuality value may be 1 to 9, but 6 is standard.
RETURN blob
IS

BEGIN

Return utl_compress.lz_compress(pData,pQuality);

END Fnc_Compress_Blob_Data;
/

Tuesday, December 22, 2009

Create an Img file from flat file image(multiple image)

CREATE USER TEST_USER IDENTIFIED BY TEST_USER;

GRANT DBA TO TEST_USER;

CONN TEST_USER/TEST_USER;

CREATE OR REPLACE DIRECTORY MY_DIR AS 'C:\temp\';
-- Img file will be create into "C:\temp\" directory.

CREATE OR REPLACE DIRECTORY IMAGE_DIR AS 'C:\image\';
-- Assume that your image into "C:\image\" directory.

CREATE OR REPLACE Procedure Img_File_Gen_From_Flat_File
                                (p_Source_Dir in varchar2 default 'IMAGE_DIR',
                                 p_Image_Name in varchar2,  -- Perticular Image_Name only.
                                Out_Img_Name in varchar2)   -- A File Name without space
is
v_blob blob;
v_data_length number;
v_chunk constant number := 32766; -- maximum chunk size
v_offset number:=1;
OutPutFile utl_file.file_type;
vFile_name varchar2(1000):= Out_Img_Name||'.img';
vData raw(32767);


begin

OutPutFile := utl_file.fopen ('MY_DIR', vFile_name, 'ab', v_chunk);
-- 'ab' value for Write append, u can change as ur required.


--"Dpr_fileToBlob" is User defined procedure  for this procedure Click Here
 Dpr_fileToBlob(Fname => p_Image_Name,
                          Fdir => p_Source_Dir,
                          OutBlob => v_blob);

v_offset := 1;
v_data_length := DBMS_LOB.getlength (v_blob);

Loop
Exit When v_offset > v_data_length;

vData := DBMS_LOB.SUBSTR (v_blob, v_chunk, v_offset);
utl_file.put_raw (OutPutFile,vData , true);
v_offset := v_offset + v_chunk;

End Loop;

--End loop;

utl_file.fflush(OutPutFile);
utl_file.fclose_all;



Exception
when others then

utl_file.fflush(OutPutFile);
utl_file.fclose_all;

End Img_File_Gen_From_Flat_File;
/

Thursday, December 17, 2009

How to Create a DB Link between two Databases(ORACLE)

TNS_NAME must be create between DataBase_1(Loacl) and DataBase_2(Remote) (If already have then no need)

Conn : DataBase_1

create database link "MY_DB_LINK.REGRESS.RDBMS.DEV.US.ORACLE.COM"
connect to User_Name -- User_Name of DataBase_2
identified by Password  -- Password of DataBase_2
using 'DataBase_2';      -- TNS Name Alias or TNS Name


select *
from table_name@MY_DB_LINK

NB: The following syntax is not supported for LOBs:

SELECT lobcol FROM table1@MY_DB_LINK;

INSERT INTO lobtable
SELECT type1.lobattr
FROM table1@MY_DB_LINK;

SELECT DBMS_LOB.getlength(lobcol) FROM table1@MY_DB_LINK;

(This statement produces error: ORA-22992 cannot use LOB locators selected from remote tables.)

==========================================================================
========================================================================== 

However, the following statement is not supported:

  • CREATE TABLE AS SELECT dbms_lob.substr(clob_col) from tab@dbs2;
  •  Clusters cannot contain LOBs, either as key or non-key columns. This produces error, ORA-02335: invalid datatype for cluster column.
  • You cannot create a VARRAY of LOBs. This produces error, ORA-02348: cannot create VARRAY column with embedded LOB.
  • You cannot specify LOB columns in the ORDER BY clause of a query, or in the GROUP BY clause of a query or in an aggregate function. This produces error, ORA-00932: inconsistent datatypes.
  • You cannot specify a LOB column in a SELECT... DISTINCT or SELECT... UNIQUE statement or in a join. However, you can specify a LOB attribute of an object type column in a SELECT... DISTINCT statement or in a query that uses the UNION or MINUS set operator if the column's object type has a MAP or ORDER function defined on it.
  • You cannot specify an NCLOB as an attribute of an object type when creating a table. However, you can specify NCLOB parameters in methods.
  • You cannot specify LOB columns in ANALYZE... COMPUTE or ANALYZE... ESTIMATE statements.
  • You cannot define an UPDATE DML trigger on a LOB column.
  • You cannot specify a LOB as a primary key column.
  • You cannot specify a LOB column as part of an index key. However, you can specify a LOB column in the function of a function-based index or in the indextype specification of a domain index. In addition, Oracle Text lets you define an index on a CLOB column.

    Tuesday, December 15, 2009

    Create a Calander with sql

    CREATE OR REPLACE Procedure Prc_Calander ( p_month in   varchar2 default to_char(sysdate,'MM'),
                                                                                     p_year    in   varchar2 default to_char(sysdate,'YYYY'),
                                                                                     p_Data   out varchar2
                                                                                    ) IS
    v_Line varchar2(2000);

    Begin

    For i in (select Nop, Line
    from (
    With
    -- days: 1 line per week day
    days as ( select level day from dual connect by level <= 7 ),
    -- weeks: 1 line per possible week in a month
    weeks as ( select level-1 week from dual connect by level <= 6 ),
    -- mdays: each day of the month within each week
    mdays as (
    select week, weekday,
    case
    when day > to_char(last_day(to_date(p_month||'/'||p_year,'MM/YYYY')),'DD')
    then ' '
    when day <= 0 then ' '
    else to_char(day,'99')
    end monthday
    from ( select week, day weekday,
    7*week+day-to_char(to_date(p_month||'/'||p_year,'MM/YYYY'),'D')+1 day
    from weeks, days
    )
    )
    -- Display blank line
    select 0 nop, null line from dual
    union all
    -- Display Month title
    select 1 nop,
    to_char(to_date(p_month||'/'||p_year,'MM/YYYY'),' FMMonth YYYY') line
    from dual
    union all
    -- Display blank line
    select 2 nop, null line from dual
    union all
    -- Display week day name
    select 3 nop,
    sys_connect_by_path(substr(to_char(trunc(sysdate,'D')+day-1,'Day'),
    1,3),' ') line
    from days
    where day = 7
    connect by prior day = day-1
    start with day = 1
    union all
    -- Display each week
    select 4+week nop, replace(sys_connect_by_path(monthday,'/'), '/', ' ') line
    from mdays
    where weekday = 7
    connect by prior week = week and prior weekday = weekday-1
    start with weekday = 1)
    )
    Loop

    v_Line := v_Line||chr(10)||i.Line;

    End Loop;

    p_Data := v_Line;

    Exception
    When others then null;
    End Prc_Calander;
    /

    Saturday, December 5, 2009

    Create a img file from multiple tif/jpg/bmp or any other file

    CREATE OR REPLACE Procedure Img_File_Generation
    is
    v_blob                                           blob;
    v_data_length                                Number;
    v_chunk                                        CONSTANT NUMBER := 32767; -- maximum chunk size
    v_offset                                         Number:=1;
    OutPutFile                                     utl_file.file_type;

    begin

    OutPutFile := utl_file.fopen ('MY_DIR', 'test.img', 'ab', v_chunk);

    For i in (select image_Name
    From Table_Name
    )
    Loop

    v_offset := 1;
    v_blob := i.image_name;
    v_data_length := DBMS_LOB.getlength (v_blob);

    Loop
    Exit When v_offset > v_data_length;

    utl_file.put_raw (OutPutFile, DBMS_LOB.SUBSTR (v_blob, v_chunk, v_offset), true);
    v_offset := v_offset + v_chunk;

    End Loop;


    End loop;

    utl_file.fflush(OutPutFile);
    utl_file.fclose_all;


    Exception
    when others then

    utl_file.fflush(OutPutFile);
    utl_file.fclose_all;

    End Img_File_Generation;
    /

    Tuesday, November 24, 2009

    Create or Delete a Mapp Network Drive

    01. For Create a Mapp Network Drive:

      Command  
      net use drive_letter: \\domain_name\share_folder /user:domain_user_name password 
      Example   :
      net use x: \\10.11.201.105\xml /user:hasan 123

    02. For Delete A Mapp Network Drive:

     Command :  net use drive_letter: /delete
     Example   :  net use x: /delete

    For Details Net Use Command : Click Here
    All DOS Command                    : Click Here
    Dos Command Link in PDF      : Click Here 

    Monday, November 23, 2009

    AutoFTP is an automated ftp client software for transferring files over the Internet.

    AutoFTP is an automated ftp client software for transferring files over the Internet.

    Benefits, Features
    • Auto-Transfers: You can schedule auto-recurring transfers for any future date/time;
    • Transfer Sets: You can select any number of files from any FTP site or your local computer, from different directories, to download or upload. You can schedule the upload/download for any future date/time.
    • Flexible Templates: Results of time consuming tasks or repetitive processes can be saved into templates. You can save the following settings to templates: transfer sets (files for download or upload from any FTP site or Local computer), transfer sessions.
    • AutoFTP can automatically dial, connect to the Internet, upload and/or download files and finally disconnect;
    • You can specify in the Preferences that auto-transfers should be aborted if the connection is too slow (auto-transfer will be rescheduled automatically); This can save you connect time and money;
    • AutoFTP uses a Windows File Explorer-like user interface with popup menus and drag-and-drop support so you will feel at home;
    • AutoFTP can remain invisible while transferring files so it will not disturb your other work;
    • AutoFTP Assistant will guide you through the process of uploading, downloading and scheduling auto-transfers;

    Requirements
    PC 286 CPU or better; 2 MB RAM; Color monitor; Windows 95, 98, Me, NT; Requires only 400 Kbytes of disk space.

    Click Here to Download Auto Ftp.

    Sunday, November 22, 2009

    Create an FTP Folder with Read Access but Not List Access

    Create the FTP Folder
    01.  Create a folder that you want the FTP service to point to.
    02.  Right-click the folder, click Properties, and then click the Security tab. Grant Full Control permissions to only the Administrators group.

    [NOTE: Remove the Everyone group if it is present.]

    03.  Click Advanced, and then click Add to add a new rule.
    04.  In the account selection list, double-click the Anonymous User account or the group that is used for FTP access.
    05.  In the Apply Onto drop-down list, select Files Only.
    06.  Click to select Allow for the following permissions:
    Ø      List Folder/Read Data
    Ø      Read Attributes
    Ø      Read Extended Attributes
    Ø      Read Permissions

    07.  Click OK.
    08.  Click Add to add another rule.
    09.  Select the account that you selected in step 4.
    10.  In the Apply Onto list, click to select This Folder only.
    11.  Click to select Allow for the following permissions
    (note that List permissions are not listed):
    Ø      Create Files/Write Data
    Ø      Create Folders/Append Data
    Ø      Write Attributes
    Ø      Write Extended Attributes
    Ø      Read Permissions

    12.  Click OK until you have closed all of the property windows.


    Note If you apply these permissions to an existing folder or to existing files, you click to select the Reset permissions on all child objects and enable propagation of inheritable permissions check box before you click OK.

    Wednesday, November 4, 2009

    Bangla Font Configuration With Oracle

    First Collect SolaimanLipi.ttf (Click here for download) Font from a Reliable Sourse.Install this font and follow below steps:

    *** It will be better if u use Developer10g Rel-2 ( Version 10.1.2.0.2 - 32 Bit )
    *** During database installation must be change Product Language by AL32UTF8

    [Remember that, u must have configure JRE in Webutil Configuration
    For JRE, must be incldue the followinng code into Formsweb.cfg file
    (Path: DevHome\forms\server\)

    ###########################################################################
       # Page displayed to users to allow them to download Sun's Java Plugin.
       # Sun's Java Plugin is typically used for non-Windows clients.
       # (NOTE: you should check this page and possibly change the settings)
       jpi_download_page=/forms/java/jre-6u17-windows-i586-S.exe
       # Parameter related to the version of the Java Plugin
       jpi_classid=clsid:CAFEEFAC-0016-0017-FFFF-ABCDEFFEDCBA
       # Parameter related to the version of the Java Plugin
       jpi_codebase=/forms/java/jre-6u17-windows-i586-S.exe
       # Parameter related to the version of the Java Plugin
       jpi_mimetype=application/x-java-applet;jpi-version=1.6.0_17
       # EM config parameter
       # Set this to "1" to enable Enterprise Manager to track Forms processes
       em_mode=0
     #######################################################################
      
    In the Key Configuration of formsweb.cfg file 
     replace baseHTMLjinitiator=webutiljini.htm by baseHTMLJInitiator=webutiljpi.htm

       archive=frmall.jar
       webUtilArchive=frmwebutil.jar,jacob.jar
       baseHTMLJInitiator=webutiljpi.htm

    #######################################################################

    For Download JRE(jre-6u17-windows-i586-s.exe) Click Here  
    Classid : CAFEEFAC-0016-0017-FFFF-ABCDEFFEDCBA ]

    1. Start>>Run>>regedit>>Database Home>> Edit NLS_LANG file by double click

    Replace AMERICAN_AMERICA.WE8MSWIN1252 by AMERICAN_AMERICA.UTF8

    2. Start>>Run>>regedit>>DeveloperSuit Home>> Edit NLS_LANG file by docuble click

    Replace AMERICAN_AMERICA.WE8MSWIN1252 by AMERICAN_AMERICA.UTF8


    3. For showing in report go to the path

    ..\...\DevSuiteHome\tools\common\uifont.ali

    Write "SolaimanLipi" = "SolaimanLipi.ttf"
    between [ PDF:Embed ] and [ PDF Subset ]


    4. Developmnent machine and for app

    ..\...\DevSuiteHome\forms\java\oracle\forms\registry.dat

    Go to default.fontMap.appFontnames line and append SolaimanLipi font name by the following.

    default.fontMap.appFontnames=SolaimanLipi,.....



    If you want to show default font with SolaimanLipi.(Not Mandatory) then

    Find the lines default.fontMap.defaultFontname=Dialog
    and replace by default.fontMap.defaultFontname=SolaimanLipi



    5. Shutdown OC4J Instance once then again Start OC4J Instance.

    [N.B: 01. Use Avro Keyboard (version: avrokeyboard_4.1.0) and Install SolaimanLipi font into your operating system's FONTS folder.

    02. Go Start Menu >> Settings >> Control Panel >> Regional & Language Options >>
    Then Select Languages Tab and Check Install files for complex script & right-to-left languages(Including Thai)
    >> Ok(You have need Operating Systems CD & your system must be restart.)]

    Download Avro Keyboard From The Following Link:
    http://www.omicronlab.com/news/avro-keyboard-4.1.0-released.html