Skip to main content

Posts

Showing posts from December, 2011

Only native data types are supported in PLSQL programming

create or replace package check1 is procedure p1(a1 integer); procedure p1(a1 number); end check1; / create or replace package body check1 is procedure p1(a1 integer) as begin dbms_output.put_line('Using Integer'); end p1; procedure p1(a1 number) as begin dbms_output.put_line('Using Number'); end p1; end; / --The above code gets compiled successfully. --But when you try to execute it .. begin check1.p1(8779); end; --See what happens.............. This concludes ONLY different native datatypes can be used in PLSQL OO implementation. Happy learning!!!!!

PLSQL Tips & Tricks for today

Tips In Oracle, A primary key cannot contain a NULL value. But try the below.. Create table t1 ( col1 varchar2(30) null, col2 varchar2(40), add constraint col1_pk PRIMARY KEY ( col1 ) ); --The above is created successfully TRICK To copy a large table , use Oracle hint APPEND with Insert statement as below. Consider the table TABLE1 having huge set of records ( > 10M rows ).. Create table TABLE1_copy as Select * from TABLE1 where 1=2; Insert /*+append*/ into table1_copy select * from table1; commit;

How to remove duplicate rows without using DISTINCT or ROWID or GROUP BY methods in Oracle?

Make use of SET operators and CTAS (Create Table AS) method.. Example: Create table tmp_tb1 as Select * from table1 intersect Select * from table1; truncate table table1; insert into table1 select * from tmp_tb1; -- This will now have removed all duplicates in the table... commit; *** You can use UNION operator in place of INTERSECT