Tuesday, 12 April 2011

DECODE (SQL)


DECODE (SQL)
#############################################################################################
--
-- %Purpose: DECODE as a very effizient use of IF-THEN-ELSE   
--
-- Use:      DECODE(expr,search,result,default)
--           if expr IS equal to search, Oracle returns result,
--           if no match is found, Oracle returns default.
--
-- #############################################################################################
--
-- Quite slow is .......
--
select count(*), sum(sal)
from emp
where DEPTNO = 10
and ename like 'SMITH%';
--
select count(*), sum(sal)
from emp
where DEPTNO = 30
and ename like 'SMITH%';
--
-- .... the same result much more efficiently with DECODE
--
-- Remeber that NULL values are never included in, nor do they affect the
-- outcome of, the COUNT and SUM functions
--
SELECT COUNT(DECODE(deptno,10,'*',NULL)) D10_count,
       COUNT(DECODE(deptno,30,'*',NULL)) D30_count,
         SUM(DECODE(deptno,10,sal,NULL)) D10_sal,
         SUM(DECODE(deptno,30,sal,NULL)) D30_sal
FROM emp
WHERE ename like 'SMITH%';

Bulk Inserts with Oracle


Bulk Inserts with Oracle


The Old Fashioned Way
A quick glance at the following Code should make one point very clear: This is straightforward code; unfortunately, it takes a lot of time to run - it is "old-fashioned" code, so let's improve it using collections and bulk processing.
CREATE OR REPLACE PROCEDURE test_proc IS
BEGIN
  FOR x IN (SELECT * FROM all_objects)
  LOOP

    INSERT INTO t1
    (owner, object_name, subobject_name, object_id,
     data_object_id, object_type, created, last_ddl_time,
     timestamp, status, temporary, generated, secondary)
    VALUES
    (x.owner, x.object_name, x.subobject_name, x.object_id,
    x.data_object_id, x.object_type, x.created,
    x.last_ddl_time, x.timestamp, x.status, x.temporary,
    x.generated, x.secondary);
  END LOOP;
  COMMIT;
END test_proc;
/
CREATE TABLE t1 AS SELECT * FROM all_objects WHERE 1 = 2;
SQL> set timing on;
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:12.84
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:15.03
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:12.54
Very slow - do not use it in that way!
USING Bulk Collect
Converting to collections and bulk processing can increase the volume and complexity of your code. If you need a serious boost in performance, however, that increase is well-justified.
Collections, an evolution of PL/SQL tables that allows us to manipulate many variables at once, as a unit. Collections, coupled with two new features introduced with Oracle 8i, BULK_COLLECT and FORALL, can dramatically increase the performance of data manipulation code within PL/SQL.
CREATE OR REPLACE PROCEDURE test_proc (p_array_size IN PLS_INTEGER DEFAULT 100)
IS
TYPE ARRAY IS TABLE OF all_objects%ROWTYPE;
l_data ARRAY;

CURSOR c IS SELECT * FROM all_objects;

BEGIN
    OPEN c;
    LOOP
    FETCH c BULK COLLECT INTO l_data LIMIT p_array_size;


    FORALL i IN 1..l_data.COUNT
    INSERT INTO t1 VALUES l_data(i);


    EXIT WHEN c%NOTFOUND;
    END LOOP;
    CLOSE c;
END test_proc;
/
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:03.34
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:03.20
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:03.90
Eliminate CURSOR LOOP at all
You may eliminate the CURSOR Loop at all, the resulting Procedure is compacter and the performance is more or less the same.
CREATE OR REPLACE PROCEDURE test_proc
IS
TYPE TObjectTable IS TABLE OF ALL_OBJECTS%ROWTYPE;
ObjectTable$ TObjectTable;


BEGIN
   SELECT * BULK COLLECT INTO ObjectTable$
     FROM ALL_OBJECTS;


     FORALL x in ObjectTable$.First..ObjectTable$.Last
     INSERT INTO t1 VALUES ObjectTable$(x) ;

END;
/
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:03.51
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:03.35
SQL> exec test_proc;

PL/SQL procedure successfully completed.

Elapsed: 00:00:04.46

Retrieves all PO transaction quantities



Retrieves all PO transaction quantities:-
----------------------------------------------

Following Query would get all the PO Numbers, Item ID, Quantity Order, Received, Canceled etc. The same information can be found in the PO order form from the Front end Application.

SELECT
POL.ITEM_ID "Inventory Item ID",
POLL.SHIP_TO_LOCATION_ID "Ship to Location ID",
poll.quantity "Quantity",
poll.Quantity_received "Quantity Received",
poll.QUANTITY_cancelled "Quantity Canceled",
POH.SEGMENT1 "PO Order Number"
FROM po_headers_all poh
, po_lines_all pol
, po_line_locations_all poll
WHERE poh.po_header_id=pol.po_header_id
AND pol.po_line_id=poll.po_line_id
AND poll.po_header_id=pol.po_header_id
AND poh.authorization_status='APPROVED'
AND poh.type_lookup_code='STANDARD'
AND NVL(poh.cancel_flag,'N') ='N'
AND POL.ITEM_ID IS NOT NULL
AND NVL (poll.quantity, 0) > (NVL (Quantity_received,0) + NVL (Quantity_cancelled,0))

Duplicate rows in the table



Duplicate rows in the table:-
--------------------------------

The following query can be used to get the duplicate records from table.

SELECT * FROM 'Your table name' WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM 'Your Table Name' GROUP BY'Your duplicate values field name');

Example:-

SELECT * FROM emp WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM emp GROUP BY ename);

To eliminate/delete the duplicate rows from the table, you can use the following query.

DELETE 'Your table name' WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM 'Your Table Name' GROUP BY 'Your duplicate values field name');

Example:-

DELETE emp WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM emp GROUP BY
ename);

To know the Application version before upgrade and current version



To know the Application version before upgrade and current version:-
---------------------------------------------------------------------------------

If there is some oracle Aplication Instance say (11.5.8) got upgrade to R12. After upgarding the Instance/Application, If I want to know the older version. Then use the following select statement.

SELECT SUBSTR(snapshot_name,12,8)
FROM ad_snapshots
WHERE comments = 'Preseeded'
AND REPLACE(SUBSTR(snapshot_name,12,8),'.') =
(
SELECT max(to_number(replace(SUBSTR(snapshot_name,12,8),'.')))
FROM ad_snapshots
WHERE comments = 'Preseeded'
);

Use the following to know the current Oracle Apps Version.
---------------------------------------------------------------------

SELECT release_name FROM fnd_product_groups;

PRAGMA(Pragma Autonomous_transaction)



PRAGMASignifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They do not affect the meaning of a program; they simply convey information to the compiler.

1) Autonomous Transaction

Autonomous Transactions is the child transaction, which are Independent of Parent transactions. In Our Example, p1 is child transaction, which is used in the Parent transaction. 


Example
: -
CREATE or REPLACE Procedure p1 IS
Pragma Autonomous_transaction;
BEGIN
INSERT INTO TEST_T VALUES (1111,’PHANI1’);
COMMIT;
END;
In the Declaration section, you will declare this Transaction as the Autonomous Transaction.
DECLARE
A NUMBER;
BEGIN
INSERT INTO TEST_T VALUES (2222,’JACK’);
P1;
ROLLBACK;
END;
NOW Table has (1111,’PHANI’) Record. COMMIT in the PROCEDURE P1 have not commit the Outside (p1) DML operations. It will just commit p1 transactions.
The ROLLBACK will not rollback PHANI record, it will just rollback the JACK record.
CREATE or REPLACE Procedure p1 IS
BEGIN
INSERT INTO TEST_T VALUES (1111,’PHANI1’);
COMMIT;
END;

If I remove the Pragma Autonomous_transaction From the declaration section, then this transaction will become the normal transaction. Now if you try to use the same parent transaction as given below.
>> delete from TEST_T;
DECLARE
A NUMBER;
BEGIN
INSERT INTO TEST_T VALUES (2222,’JACK’);
P1; -- This transaction has ended with the COMMIT;
ROLLBACK;
END;

After executing the above transaction, you can see BOTH records got Inserted (PHANI and JACK records). Here COMMIT in P1 will commit both transactions (PHANI and JACK Records Insert) And then Rollback. Since, there are no transactions happening between COMMIT and ROLLBACK. Our ROLLBACK is not doing any ROLLBACK.
Note: - IF COMMIT is not given in P1 then, the ROLLBACK will do the ROLLBACK both the INSERT transaction (PHANI Record which is in p1 procedure and JACK Record).
2) Pragma Restrict_references
It gives the Purity Level of the Function in the package.
CREATE OR REPLACE PACKAGE PKG12 AS FUNCTION F1 RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (F1, WNDS,
RNDS,
WNPS,
RNPS);
END PKG12;
CREATE OR REPLACE PACKAGE BODY PKG12 AS
FUNCTION F1 RETURN NUMBER IS
X NUMBER;
BEGIN
SELECT EMPNO INTO X FROM SCOTT.EMP
WHERE ENAME LIKE ‘SCOTT’;
DBMS_OUTPUT.PUT_LINE (X);
RETURN (X);
END F1;
END PKG12;
You will get the Violate It’s Associated Pragma Error. This in Purity Level, we said
It cannot read from the database. RNDS (In Our Function F1, we have SELECT STATEMENT which is reading the data from the database).
3) Pragma SERIALLY_REUSABLE


In my 5 Years of Experience in the Oracle Applications, I have never found the requirement to use this feature :). But, I found this feature is used in some standard Oracle Packages. We may use this feature for improving the performance or to meet certain requirements.
This pragma is appropriate for packages that declare large temporary work areas that are used once and not needed during subsequent database calls in the same session.
You can mark a bodiless package as serially reusable. If a package has a spec and body, you must mark both. You cannot mark only the body.
The global memory for serially reusable packages is pooled in the System Global Area (SGA), not allocated to individual users in the User Global Area (UGA). That way, the package work area can be reused. When the call to the server ends, the memory is returned to the pool. Each time the package is reused, its public variables are initialized to their default values or to NULL.
Serially reusable packages cannot be accessed from database triggers or other PL/SQL subprograms that are called from SQL statements. If you try, Oracle generates an error.

Examples
WITH PRAGMA SERIALLY_REUSABLE
The following example creates a serially reusable package:
CREATE PACKAGE pkg1 IS
PRAGMA SERIALLY_REUSABLE;
num NUMBER := 0;
PROCEDURE init_pkg_state(n NUMBER);
PROCEDURE print_pkg_state;
END pkg1;
/
CREATE PACKAGE BODY pkg1 IS
PRAGMA SERIALLY_REUSABLE;
PROCEDURE init_pkg_state (n NUMBER) IS
BEGIN
pkg1.num := n;
END;
PROCEDURE print_pkg_state IS
BEGIN
dbms_output.put_line('Num: ' || pkg1.num);
END;
END pkg1;
/
begin
pkg1.init_pkg_state(10);
pkg1.PRINT_PKG_STATE;
end;

Num: 10

begin
pkg1.PRINT_PKG_STATE;
end;

Num: 0

Note: - The first block is changing the value of the variable (num) to 10 and if I check the value in same block then it is showing the changed value that is 10. But, if I try to check the value of the (num) variable then it should the default value given to it (i.e.) “0”
WITHOUT PRAGMA SERIALLY_REUSABLE
CREATE OR REPLACE PACKAGE pkg1 IS
num NUMBER := 0;
PROCEDURE init_pkg_state(n NUMBER);
PROCEDURE print_pkg_state;
END pkg1;
CREATE PACKAGE BODY pkg1 IS
PROCEDURE init_pkg_state (n NUMBER) IS
BEGIN
pkg1.num := n;
END;
PROCEDURE print_pkg_state IS
BEGIN
dbms_output.put_line('Num: ' || pkg1.num);
END;
END pkg1;
begin
pkg1.init_pkg_state(10);
pkg1.PRINT_PKG_STATE;
end;
>>Num: 10
begin
pkg1.PRINT_PKG_STATE;
end;
>>Num: 10
Note: - Now, you may noticed the difference. The second block is giving us the changed value.
DROP PACKAGE pkg1;

User Guides for ORACLE APPLICAITONS

Download links


Download links

Oracle SQL Developer: Click Here
Reports n Forms 6i: Click here
XML Publisher: Click here
Putty: Click here
Winscp (FTP Tool): Click here
Developer suite 10g (Including reports, forms, Jdeveloper): Click here
BI Publisher: Click here
Workflow Builder: Click here
Toad Free Trail: Click here
JDeveloper n ADF Software: Click here
Warehouse Builder Software: Click here
Discoverer Desktop Software: Click here
BPEL Software: Click here
JInitiator: Click here
Oracle Database 9i: Click here
Oracle Database 10g:Click Here
Oracle Database 11g: Click Here
Oracle Linux: Click here
Oracle Virtual Machine (VM): Click here
Oracle Applications 11i and R12: Click here

Introduction of SQL LOADER


Introduction of SQL LOADER:-

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

SQL LOADER is an Oracle utility used to load data from the given data-file into table or tables created in the database. The data-file which has the records those need to be loaded.
 SQL*Loader takes data file, as well as a control file, to insert data into the table. When a Control file is executed, it may create 3 files called log file, bad file, and discard file.
Log file will be created for sure in any case (Pass or fail). Bad file would only be created if any record validation fails and Discard file would be created only WHEN condition fails (If Control file has the WHEN condition).
  • Log file tells you the number of logical records already read from the input data-file and the state of the tables and indexes. This information can be used to resume the load where it left off.
  • bad file gives you the records that were rejected because of formatting errors or because they caused Oracle/validation errors .
  • discard file specifies the records that do not meet any of the loading criteria like when any of the WHEN clauses specified in the control file. These records differ from rejected records.
CONTROL file will have the path and name of the DATA-FILE. If both the CONTROL and DATA files are present in the same directory then you do not need to give any path of the data-file (Name of the file will be enough).
SQL LOADER utility can be used from any Operating system like Windows, UNIX or Linux etc.
Types of the data file structure:
They are two different types format structure of the data-file.
1) Fixed record format
2) Variable record format.

Variable record format

Variable record format:-
-------------------------
Variable Record Format would like below where the data fields are separated by a delimiter. Note: The Delimiter can be anything you like. In this case it is "|"
NAME1|0001|9999|08-JAN-08|10
NAME1112|0033|989|08-FEB-08|20
NAME1231|0021|9999|08-SEP-08|30
NAME45601|0041|9999|08-AUG-08|40
NAME23451|0051|9999|08-JUL-08|30
NAME56541|0023|9999|08-JAN-08|40

Structure of a Control file:
Sample CONTROL/CTL file for loading a variable record data file.
OPTIONS (SKIP = 2) --The first 2 rows will be skipped in data file.
LOAD DATA -- It’s kind of the BEGIN statement in CTL file.
INFILE '$FILE' -- Specify the data file path and name
APPEND -- Type of loading (INSERT, APPEND, REPLACE, TRUNCATE
INTO TABLE ‘Your Table Name’ -- the table to be loaded into
FIELDS TERMINATED BY '|' -- Symbol (|) which used to separate the col’s
OPTIONALLY ENCLOSED BY '"' --Values of the data fields may be enclosed (")
TRAILING NULLCOLS -- columns that are not present in the record treated as null
(COL1 “TRIM (:COL1)", -- Can use all SQL functions on columns
COL2 DECIMAL EXTERNAL,
COL3 DECIMAL EXTERNAL,
COL4 "TO_CHAR(:COL,'DD-MON-YY')", --Date format can be given
COL5 CONSTANT "AOT"
-- Can specify constant value instead of getting value from data-file
)
OPTION statement precedes the LOAD DATA statement. The OPTIONS parameter allows you to specify runtime arguments in the control file, rather than on the command line. The following arguments can be specified using the OPTIONS parameter.
SKIP = n -- Number of logical records to skip (Default 0)
LOAD = n -- Number of logical records to load (Default all)
ERRORS = n -- Number of errors to allow (Default 50)
ROWS = n -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional Path 64, direct path all)
BINDSIZE = n -- Size of conventional path bind array in bytes (System-dependent default)
SILENT = {FEEDBACK | ERRORS | DISCARDS | ALL} -- Suppress messages during run (header, feedback, errors, discards, partitions, all)
DIRECT = {TRUE | FALSE} --Use direct path (Default FALSE)
PARALLEL = {TRUE | FALSE} -- Perform parallel load (Default FALSE)
LOAD DATA statement is required at the beginning of the control file.
INFILE: INFILE keyword is used to specify location and name of the data-file.
INFILE * specifies that the data is found in the control file and not in an external file. You will find the data in the same CONTROL file.
INFILE '$FILE', can be used to send the file path and filename as a parameter when registered as a concurrent program in the Oracle Application.
INFILE '/home/demo/phani/file01.txt' specifies the file-path and the filename.


Example: - For the data-file is an external file.
LOAD DATA
INFILE ' /home/demo/phani/file01.txt'
INTO TABLE XX_EMP
FIELDS TERMINATED BY ","
(NAME, ENUM, SAL, JDATE, DEPTNO)
Example: - For the data-file is in the Control file.
LOAD DATA
INFILE *
INTO TABLE xx_emp
FIELDS TERMINATED BY "|"
( NAME, ENUM, SAL, JDATE,DEPTNO )
BEGINDATA
PHANI|0001|9999|08-JAN-08|10
REDDY|0033|989|08-FEB-08|20
RAHUL|0021|9999|08-SEP-08|30
MANOJ|0041|9999|08-AUG-08|40
RANA|0051|9999|08-JUL-08|30
Example: - For the file name and path is sent as a parameter when registered as a concurrent program
LOAD DATA
INFILE '$FILE'
INTO TABLE SCOTT.XX_EMP
FIELDS TERMINATED BY ","
(NAME, ENUM, SAL, JDATE, DEPTNO)
TYPE OF LOADING:
INSERT -- If the table you are loading is empty, INSERT can be used.
APPEND -- If data already exists in the table, SQL*Loader appends the new rows to it. If data doesn't already exist, the new rows are simply loaded.
REPLACE -- All rows in the table are deleted and the new data is loaded
TRUNCATE -- SQL*Loader uses the SQL TRUNCATE command.
INTO TABLE is required to identify the table to be loaded and in the above example INTO TABLE "SCOTT"."XX_EMP", SCOTT refers to the Schema and XX_EMP is the Table name.
Note: - The Schema name is not the mandatory. Since, when we run the command to run the CTL file, we will provide the login information. So, what ever the username we give in the command It will look for the object in that schema. (Schema name is nothing but the Username you are using to login into the database).
FIELDS TERMINATED BY specifies how the data fields are terminated in the data-file. (If the file is Comma delimited or Pipe delimited etc)
OPTIONALLY ENCLOSED BY '"' specifies that data fields may also be enclosed by quotation marks.
TRAILING NULLCOLS clause tells SQL*Loader to treat any relatively positioned columns that are not present in the record as null columns.
Command to run the SQL*Loader:-
sqlldr USERID='User_name'/'Password' CONTROL='Your control filename' LOG='Log file name'

Example:- sqlldr USERID=scott/tiger CONTROL=aottest.ctl

1) You provide the Username and password to connect to the database.
2) Control file name should be given which you want to run. In the above Example aottest.ctl control file name.
3) Log file name can be given. So that when log file is create by the command would create with same name as given. But this is not the default parameter. If log name is not given then by default name would be given by the system.

Fixed record format

Fixed record format:-
-------------------------

Fixed Record Format would look like the below. In this case you give a specific position where the Control file can expect a data field.

1001 PHANI CLERK
1002 REDDY SALESMAN
1003 USER1 SALESMAN
1004 USER2 MANAGER
1005 USER3 SALESMAN
1006 USER4 MANAGER
1007 USER5 MANAGER
1008 USER6 ANALYST
1009 USER7 PRESIDENT
2010 USER8 SALESMAN
1011 USER9 CLERK
Structure of a Control file: 

Sample CONTROL/CTL file for loading a 
Fixed record data file.
OPTIONS (SKIP = 2) --The first 2 rows will be skipped in data file.
LOAD DATA -- It’s kind of the BEGIN statement in CTL file.
INFILE '$FILE' -- Specify the data file path and name
APPEND -- Type of loading (INSERT, APPEND, REPLACE, TRUNCATE
INTO TABLE ‘Your Table Name’ -- the table to be loaded into
( COL1 POSITION(01:04) INTEGER EXTERNAL, 
COL2 POSITION(06:10) CHAR,
COL3 POSITION(16:24) CHAR
)
OPTION statement precedes the LOAD DATA statement. The OPTIONS parameter allows you to specify runtime arguments in the control file, rather than on the command line. The following arguments can be specified using the OPTIONS parameter.
SKIP = n -- Number of logical records to skip (Default 0)
LOAD = n -- Number of logical records to load (Default all)
ERRORS = n -- Number of errors to allow (Default 50)
ROWS = n -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional Path 64, direct path all)
BINDSIZE = n -- Size of conventional path bind array in bytes (System-dependent default)
SILENT = {FEEDBACK | ERRORS | DISCARDS | ALL} -- Suppress messages during run (header, feedback, errors, discards, partitions, all)
DIRECT = {TRUE | FALSE} --Use direct path (Default FALSE)
PARALLEL = {TRUE | FALSE} -- Perform parallel load (Default FALSE)
LOAD DATA statement is required at the beginning of the control file.
INFILE: INFILE keyword is used to specify location and name of the data-file.
INFILE * specifies that the data is found in the control file and not in an external file. You will find the data in the same CONTROL file.
INFILE '$FILE', can be used to send the file path and filename as a parameter when registered as a concurrent program in the Oracle Application.
INFILE '/home/demo/phani/file01.txt' specifies the file-path and the filename.
TYPE OF LOADING:
INSERT -- If the table you are loading is empty, INSERT can be used.
APPEND -- If data already exists in the table, SQL*Loader appends the new rows to it. If data doesn't already exist, the new rows are simply loaded.
REPLACE -- All rows in the table are deleted and the new data is loaded
TRUNCATE -- SQL*Loader uses the SQL TRUNCATE command.
INTO TABLE is required to identify the table to be loaded.
Command to run the SQL*Loader:-
sqlldr USERID='User_name'/'Password' CONTROL='Your control filename' LOG='Log file name'

Example:- sqlldr USERID=scott/tiger CONTROL=aottest.ctl

1) You provide the Username and password to connect to the database.
2) Control file name should be given which you want to run. In the above Example aottest.ctl control file name.
3) Log file name can be given. So that when log file is create by the command would create with same name as given. But this is not the default parameter. If log name is not given then by default name would be given by the system.

Demo fixed script

Demo Fixed script:-
----------------------
It is always good to run some script successfully and tries to learn more about it, features etc. This page is design for the SQL*LOADER scripts for the Fixed format data-file.

Follow the steps given below to run the fixed format data-file script.
1) Create one Folder in your Operating System. Let the folder name ‘XYZ’
2) Download the Data-File in the XYZ folder.
Click on the link given to download the Data-File: Click Here
3) Download the CONTROL in the XYZ folder.
Click on the Link given to download the CONTROL file: Click Here
4) Download the CREATE Table script in the XYZ Folder.
Click on the Link given to Download the create table script: Click Here
5) Execute/Run the Create Table script in your database to create the table.
6) Run the command to run the Control file.
sqlldr USERID=scott/tiger CONTROL=aottest.ctl
7) Verify the log file created and also check if there is any bad or discard file created.
8) Query the table in database where you have INSERTED the records.

Demo Variable script
Demo Variable script:-
-------------------------
It is always good to run some script successfully and tries to learn more about it, features etc. This page is design for the SQL*LOADER scripts for the variable format data-file.

Follow the steps given below to run the variable format datafile script.
1) Create one Folder in your Operating System. Let the folder name ‘XYZ’
2) Download the Data-File in the XYZ folder.
Click on the link given to download the Data-File
Demo Variable script:-
-------------------------
It is always good to run some script successfully and tries to learn more about it, features etc. This page is design for the SQL*LOADER scripts for the variable format data-file.

Follow the steps given below to run the variable format datafile script.
1) Create one Folder in your Operating System. Let the folder name ‘XYZ’
2) Download the Data-File in the XYZ folder.
Click on the link given to download the Data-File : Click Here
3) Download the CONTROL in the XYZ folder.
Click on the Link given to download the CONTROL file : Click Here
4) Download the CREATE Table script in the XYZ Folder.
Click on the Link given to Download the create table script : Click Here
5) Execute/Run the Create Table script in your database to create the table.
6) Run the command to run the Control file.
sqlldr USERID=scott/tiger CONTROL=AOTDF01.ctl
7) Verify the log file created and also check if there is any bad or discard file created.
8) Query the table in database where you have INSERTED the records.