If you want to do update another column when execute an update on table, you can use before update trigger. If you use after update trigger, you can get some errors. if you use pragma autonomous_transaction parameter as declare in trigger you can get errors like that are “ORA-00060: deadlock detected while waiting for resource”, “ORA-06512:…
Category: Procedure
Obtain Surname, Last Name and Mid Name From Full Name in Oracle
If you have a column with full name data and you want to split this data, you can use below function to split operation. Split Name ve Surname Table : test Data1 : Emin Fatih Acar Data2 : Fatih Acar SQL> select fullname, substr(fullname,0,instr(fullname,’ ‘,Instr(fullname,’ ‘,-1))-1) name, substr(fullname,Instr(fullname,’ ‘,-1)+1) surname from test; Result: Data1 name…
Auto Increment Primary Key With Trigger in Oracle 11g
You can provide auto increment primary with trigger by appling below operations. Create Table SQL> CREATE TABLE TESTUSER.TBL_TEST (id number primary key, name varchar2(100)); Create Sequence SQL> CREATE SEQUENCE TESTUSER.SEQ_TEST_ID START WITH 1 MAXVALUE 999999999 MINVALUE 1 CYCLE NOCACHE NOORDER; Create Trigger For Auto Increment SQL> CREATE OR REPLACE TRIGGER TESTUSER.TRG_AUTO_INC_TEST_ID before insert on TESTUSER.TBL_TEST…
What is Lightweight Job in Oracle
Use lightweight jobs when you have many short-duration jobs that run frequently. Under certain circumstances, using lightweight jobs can deliver a small performance gain. Lightweight jobs have the following characteristics: Unlike regular jobs, they are not schema objects. They have a significant improvement in create and drop time over regular jobs because they do not…
Fine Grained Auditing (FGA) in Oracle
Fine Grained Auditing (FGA), introduced with Oracle9i, can be understood as ‘policy-based auditing’. As opposed to the standard auditing functionality, FGA lets you specify the conditions necessary for an audit record. FGA policies are programatically bound to the object (table, view) by using the ‘dbms_fga’ package. You have to have a valid set of Fine-Grained…
Oracle DbLink With Odbc Connection From Oracle to MsSQL Server With FreeTDS
I will use Oracle 11g R2 database and SQL Server 2008 R2 on this example. If you want to connect from Oracle to SQL Server, you can use freeTDS connection library on Oracle Linux systems. If we use Windows Server for Oracle database, we can use direct Windows ODBC Driver Manager. On the other hand,…
Random Character Generator in Oracle
Oracle dbms_random package can generate random characters in character, numeric or alphanumeric formats. dbms_random.value(Parameter, Value) U – Upper case L – Lower case A – Alphanumeric X – Alphanumeric with upper case alphabets. P – Printable characters only. Create Random Characters SQL> select dbms_random.random value from dual; Value : 531879542 SQL> select dbms_random.value from dual;…
ACL Error Solution in Oracle 11g
Oracle 11g have been used ACL procedure to send smtp e-mail. Default configuration can not send e-mail. You have to create below procedures for complete smtp configuration. I used CONNUSER as ACL connection user and 100.10.10.11 IP address as mail server IP and NOTIFYUSER as user for notification for configuration. You can change this users…
Delete Duplicate Rows Without All Records in Oracle
If you want to delete duplicate rows but not all rows in table, you can use a procedure. For example, you have 10 duplicate rows and you want to delete 9 rows, then you can use procedure to delete process. For instance, you have a table as tmp_table. tmp_table’s columns are id,name,surname,city,phone. You want to…
XML file export with stored procedure in Oracle
This example provides export xml file. You must create a directory before create procedure. After, you must give grant for user. Finally, You can create procedure and execute. Create Directory and Grant You must be sys user and can execute this queries; CREATE DIRECTORY XMLDUMP AS ‘C:\XmlDirectoryFileName’; SELECT * FROM DBA_DIRECTORIES; GRANT READ,WRITE ON DIRECTORY…