Kayıtlar

Eylül, 2012 tarihine ait yayınlar gösteriliyor

Temel Oracle Fonksiyonları

Oracle'da en çok kullanacağınız temel oracle fonksiyonlarını aşağıda açıkl ama ve örnekleri ile bulabilrsiniz. Umarım işinize yarar; PLSQL Numeric Functions ROUND(N , x) : Return the number N rounded to x decimal places. If x <0 it rounds N to x places to the left. Example: ROUND(1234.468,2)  returns 1234.5      ROUND(1234.468,-2)  returns 1200 Example: TRUNC(123.456,2) returns 123.45                 TRUNC(123.456,-2) returns 100 Example:  SIGN(-234) returns -1       SIGN(452) returns 1 Example: ABS(-541) returns 541. Example: MOD(10,4) returns 2. MOD(5,2) returns 1 Example: CEIL(123.456) returns 124. CEIL(-123.456) returns -123 Example: FLOOR (123.456) returns 123. FLOOR (-123.456) returns -124 TRUNC(N , x): Return the number with the specified x decimal places. If x<0 it zeroed the number at X positions to the left. SIGN (N): Return 1 if N is p

Türkçe Upper

Oracle'ın büyük harfe çevir (upper), küçük harfe çevir (lower), ilk harfleri büyük yap (initcap) fonksiyonları bildiğiniz ya da deneyip görebileceğiniz gibi İngilizce kurallarına göre çalışmaktadır. Örneğin elinizde "ismail" ismi, "bilir" soyadı olsun. Bu değerleri ismi initcap, soyadı ise upper ile çevirirseniz aşağıdaki sonuçla karşılaşırsınız: select initcap('ismail') || ' ' || upper('bilir') "Ad Soyad"from dual; Ad Soyad   ------------ Ismail BILIR 1 row selected. Elde ettiğimiz çıktı "Ismail BILIR" oldu. Bizim istediğimiz çıktı ise "İsmail BİLİR" olacaktı. Bu durumda oracle'ın nls_ ile başlayan functionları devreye giriyor: select nls_lower('İSİM: ', 'NLS_SORT = XTURKISH') || nls_initcap('ismail', 'NLS_SORT = XTURKISH') || ' ' || nls_upper('bilir', 'NLS_SORT = XTURKISH') "Ad Soyad"from dual; Ad Soyad         --------

Generating random numbers and strings in Oracle

Do you know how to auto generate random numbers or strings in Oracle? Generating random numbers is required when there is a need to create a lot of data for testing purposes, or when we simply need to use a number to temporarily tag a process. It may also be necessary to generate random password strings of a fixed size--a very common requirement for websites that create and maintain logins for users. Whatever the need, the fact is that Oracle provides us with a random number generator. This option is faster than writing your own random generation logic in PL/SQL as Oracle's internal processing logic is used. In addition, it can also be used to generate both character and alphanumeric strings. DBMS_RANDOM package The DBMS_RANDOM package will generate random data in character, numeric or alphanumeric formats. The size and the range from which to pickup the random values can also be specified. This package is created by the script dbmsrand.sql available in the <OR