Monday, December 30, 2013

Oracle Cursor With Basic Loop.

Using oracle cursor with basic loop.

DECLARE
CURSOR C1 IS
SELECT EMPLOYEE_ID, LAST_NAME
FROM EMPLOYEES
WHERE DEPARTMENT_ID=90;

V_EMPID VARCHAR2(100);
V_NAME  VARCHAR2(300);

BEGIN

OPEN C1;

LOOP

FETCH C1 INTO V_EMPID, V_NAME;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(V_EMPID ||' '||V_NAME);

END LOOP;

END;

Sunday, December 15, 2013

Oracle External Table

Oracle External Table:- Oracle External Table are use for the purpose of load data  from external sources such as spreadsheet data (csv format) , text file or any others. 

Limitations of  External Tables  
There are some limitations  to using external table

DML Operation are not support. Oracle external tables are read-only, but the base data can be edited in any text editor. Poor response for high-volume queries.

CREATE OR REPLACE DIRECTORY
DATA_FILE  AS
'D:\app\';


CREATE TABLE ext_table(
emp_id    VARCHAR2(20),
emp_name  VARCHAR2(150),
COMMENTS       VARCHAR2(300)
)
ORGANIZATION EXTERNAL (
TYPE oracle_loader
DEFAULT DIRECTORY DATA_FILE
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
LOGFILE 'data.log'
BADFILE 'data.txt'
FIELDS TERMINATED BY ','
MISSING FIELD VALUES ARE NULL
)
LOCATION('Data.csv')
)
REJECT LIMIT UNLIMITED;

Wednesday, December 11, 2013

Password Strength Check In Oracle APEX

Step 1: - Create a page and go to Header Text of the page and past the following ..

<style>
#passwordStrength
{
        height:10px;
        display:block;
        float:left;
}
.strength0
{
        width:190px;
        background:#cccccc;
}
.strength1
{
        width:45px;
        background:#ff0000;
}
.strength2
{
        width:90px;  
        background:#ff5f5f;
}
.strength3
{
        width:135px;
        background:#56e500;
}
.strength4
{
        background:#4dcd00;
        width:160px;
}
.strength5
{
        background:#399800;
        width:190px;
}
</style>

Step 2. Create an password item named (P2_PASSWORD)

Go to the HTML Form Element Attributes Of  P2_PASSWORD Item and past the following onkeyup="return passwordStrength();"

Go to the Pre Element Text Of  P2_PASSWORD Item and past the following

    <script language="javascript">
    function passwordStrength(){
    var pwd = document.getElementById('P2_PASSWORD');
    var password = document.getElementById("P2_PASSWORD").value;
    var desc = new Array();
            desc[0] = "Very Weak";
            desc[1] = "Weak";
            desc[2] = "Better";
            desc[3] = "Medium";
            desc[4] = "Strong";
            desc[5] = "Strongest";
            var score   = 0;
            if (password.length > 6) score++;
            if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;
            if (password.match(/\d+/)) score++;
            if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;
            if (password.length > 12) score++;
            document.getElementById("passwordDescription").innerHTML = desc[score];
            if (password.length==0) {
                 document.getElementById("passwordDescription").innerHTML  = 'Password not entered';
           }

          document.getElementById("passwordStrength").className = "strength" + score;

    }
    </script>

Go to the Post Element Text Of  P2_PASSWORD Item and past the following 

    <div id="passwordDescription">Password not entered</div>

    <div id="passwordStrength" class="strength0">
    </div>

Now run your page and check



Monday, December 9, 2013

ORA-02429: cannot drop index used for enforcement

Cause : It is an unique index that enforces unique constraint. It can not drop

DROP INDEX SY_CURRENT_USERCOMP_UNIQUE;

Action : You need to drop unique constraint BY

ALTER TABLE TABLE_NAME DROP CONSTRAINT CONSTRAINT_NAME

ALTER TABLE SY_CURRENT_USER DROP CONSTRAINT SY_CURRENT_USERCOMP_UNIQUE;