I will show how to round up a number by protecting 2 decimal. When I use round or ceil function, I can not have correct result. I want to round a number upwards with calculate 2 decimal. I want result like below examples. 1.2445 > 1.25 1.21 > 1.21 1.521 > 1.53 1.1 > 1.1…
Tag: Oracle SQL Query
Update Another Column On The Same Table With Trigger While Updating Table in Oracle
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:…
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…
Add Time Zone Offset To Timestamp in Oracle
If you have to add or remove offset to timezone, you can use below sql syntax. I will use for Istanbul timezone. Database stamp timezone as UTC and not add Istanbul timezone offset when insert operation. If you have to show on reports as Istanbul time zone, you can use below SQL. SQL> select to_char(…
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…