Senior Software Developer
Oracle
Oracle minus, intersect,union , union all
13 Haz
Minus iki set arasındaki farkı vermektedir
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | SELECT 'ALİ' FROM DUAL UNION ALL SELECT 'VELİ' FROM DUAL MINUS SELECT 'ALİ' FROM DUAL; |
Intersect ise kesişimini vermektedir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | SELECT 'ALİ' FROM DUAL UNION ALL SELECT 'VELİ' FROM DUAL INTERSECT SELECT 'ALİ' FROM DUAL; |
Union ve Union All kullanımını ise yukarıdaki örneklerde olduğu gibi düşünebiliriz. Union ile Union All arasındaki en önemli farklardan birisi Union distict işlemi yapar, Union All ise yapmaz.Aşağıdaki sql’in sonucunda iki adet VELİ görünür.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | SELECT 'ALİ' FROM DUAL UNION ALL SELECT 'VELİ' FROM DUAL UNION ALL SELECT 'VELİ' FROM DUAL; |
Ve son olarakta aşağıdaki sql sonucu bir adet VELİ görünür.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | SELECT 'ALİ' FROM DUAL UNION SELECT 'VELİ' FROM DUAL UNION SELECT 'VELİ' FROM DUAL; |
Sağlıcakla…..
ORA-14551: cannot perform a DML operation inside a query hatasının çözümü
5 Nis
Select Sorgusundan DML Kullanan Fonksiyon Çağırmak
Örneğin bir fonksiyon var (ister paket(package) içinde ister tek başına bulunsun), ve fonksiyonun içindede bir DML cümlesi çalıştırıyorsunuz. (INSERT,DELETE veya UPDATE). Ve fonksiyonu çağırmak için “SELECT PakageName.FunctionName FROM Dual” yaptınız. Bu durumda hata alırsınız:ORA-14551: bir sorgu içinde bir DML işlemi gerçekleştirilemez. Bunu yapabilmek için :
PRAGMA AUTONOMOUS_TRANSACTION kullanmanız gerekmektedir.
Oracle PRAGMA AUTONOMOUS_TRANSACTION ifadesini gördüğü anda bunu tamamen bağımsız bir transaction olarak algılayacak ve fonksiyonu askıya alarak bu transactionı COMMIT yada ROLLBACK olana kadar çalıştıracaktır, bu ifadeler ile karşılaştığında fonksiyonu çalıştırmaya devam edecektir.
Örnek kod aşağıdadır
ÖRNEK 1
1 2 3 4 5 6 7 8 9 10 11 12 13 | CREATE OR REPLACE FUNCTION F_DENEME1 RETURN NUMBER IS r_n_temp NUMBER(1); PRAGMA AUTONOMOUS_TRANSACTION; BEGIN UPDATE Deneme SET TempValue = 1; --DML işlemi COMMIT; r_n_temp := 1; RETURN r_n_temp; END; |
ÖRNEK 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | FUNCTION F_DENEME RETURN NUMBER IS r_n_temp NUMBER(1); BEGIN r_n_temp := 0; P_UPDATE_TEMP; --DML kullanılacak prosedür. r_n_temp := 1; ---COMMIT; --bu fonksiyon içinde Commit yapmaya --gerek yoktur çünkü herhangibi bir DML işlemi yapmadık. --Ancak eğer çağırdığımız prosedürde --AUTONOMOUS_TRANSACTION kullanmasaydık ve orada COMMIT --yapmasaydık burada COMMIT yapabilirdik! RETURN r_n_temp; END; --Update işleminin gerçekleşeceği prosedür: --------------------------------------------------- PROCEDURE P_UPDATE_TEMP IS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN UPDATE Temp_Table SET TempVal = 1; --DML işlemi COMMIT; --Commit yapılmazsa transaction açık kalacağından hata döndürecektir. END; |
ÖRNEK 3
1 2 3 4 5 6 7 8 9 10 11 | Sonuç olarak fonksiyonda başlayan transaction PRAGMA AUTONOMOUS_TRANSACTION gördüğü anda beklemeye başlar ve AUTONOMOUS_TRANSACTION bu transaction dan tamamen bağımsız çalışır ve işi bitince (COMMIT/ROLLBACK; END;) tekrar ilk transaction devreye girer ancak AUTONOMOUS_TRANSACTION da yapılan işlemlerden tamamen habersizdir. Query: SELECT F_DENEME as Deneme FROM DUAL Result Deneme ------------ 1 1 row selected |
Sağlıcakla…
ORA-00918: column ambiguously defined hatası
25 May
ORA-00918: column ambiguously defined hatası nedir?
The Oracle docs note this on the ora-00918 error*:
ORA-00918 column ambiguously defined
Cause: A column name used in a join exists in more than one table and is thus referenced ambiguously. In a join, any column name that occurs in more than one of the tables must be prefixed by its table name when referenced. The column should be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUMN. For example, if tables EMP and DEPT are being joined and both contain the column DEPTNO, then all references to DEPTNO should be prefixed with the table name, as in EMP.DEPTNO or E.DEPTNO.
Action: Prefix references to column names that exist in multiple tables with either the table name or a table alias and a period (.), as in the examples above.
When ORA-00918 is thrown, you have a column which has been ambiguously defined. If a column name in a join is referenced ambiguously, it exists in multiple tables.
Column names which occur in multiple tables should be prefixed when it is referenced by its table name.
Columns must be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUM . Oracle documentation which reference ORA-00918 give the following example:
– If tables EMP and DEPT are being joined and both contain the column DEPTNO, then all references to DEPTNO should be prefixed with the table name, as in EMP.DEPTNO or E.DEPTNO.
To correct ORA-00918, references should be prefixed to column names existing in multiple tables (either with the table name or table alias and a period)
ORA-24813: cannot send or receive an unsupported LOB
27 Nis
Error Code – Hata Kodu:
ORA-24813:
Error Decription – Hata Tanımı:
cannot send or receive an unsupported LOB
Error Cause – Hatanın Sebebi:
An attempt was made to send a LOB across the network, but either the server does not support the LOB sent by the client, or the client does not support the LOB sent by the server. This error usually occurs when the client and server are running different versions of Oracle.
To Do -Ne Yapabilirim :
Use a version of the Oracle that supports the LOB on both the client and the server.
Oracle Türkçe Dökümanlar
26 Nis
Oracle 10g Application Server Türkçe Kurulum Rehberi – Windows
http://www.oracle.com/global/tr/appserv … _Setup.pdf
Oracle 10g Application Server Türkçe Kurulum Rehberi – Linux
http://www.oracle.com/global/tr/appserv … _Setup.pdf
Oracle 9iAS Türkçe Kullanım Klavuzu
http://www.oracle.com/global/tr/appserv … lavuzu.pdf
Oracle 10g Database Server Türkçe Kurulum Rehberi – Windows
http://www.oracle.com/global/tr/databas … indows.pdf
Oracle 10g Database Server Türkçe Kurulum Rehberi – Linux
http://www.oracle.com/global/tr/databas … BLinux.pdf
Oracle Veritabanı Yönetim Sistemleri – Giriş (Türkçe)
http://www.oracle.com/global/tr/databas … _Giris.pdf
Oracle Teknik Destek Rehberi
http://www.oracle.com/global/tr/support … i_V1.0.pdf
Teknik Destekle Etkin Çalışma
http://www.oracle.com/global/tr/support … sma_V5.pdf
Oracle Teknik Destek – Soru/Cevap
http://www.oracle.com/global/tr/support … evapV6.pdf