Tuesday, July 15, 2014

PL/SQL START WITH & LEVEL & SIBLINGS

select  b.id,
        b.root_id,
        lpad ( ' ', 5 * ((decode(level,1,0,level))) ) || b.name dept_name,
        decode(b.active ,1,'X',' ') active
from schema_name.table_name b
connect by prior b.id=b.root_id
start with b.id=:p_id
order siblings by b.name;

Monday, July 14, 2014

PL/SQL GROUP BY inside a SUBQUERY

select   d.dname ,
           t.job,
           t.cnt
 from   dept d,
          (select  deptno,
                      job,
                      count(empno) cnt
             from  emp
      group by  deptno,job ) t
where  t.deptno = d.deptno;

Tuesday, July 8, 2014

PL/SQL Select 1 & Not Exists

 CREATE OR REPLACE VIEW "SCHEMA_NAME"."VEW_TEST_VIEW"
AS
  SELECT hayvankabul.id,
    hayvankabul.MEZBAHA_ID,
    hayvankabul.SAGLIK_RAPOR_NO,
    kentli.adi_soyadi yetistiren_adi_soyadi
  FROM mzb_hayvan_kabul_bilgileri hayvankabul,
    vew_ort_kentli kentli
  WHERE hayvankabul.id IN
    (SELECT kabul.id
    FROM mzb_hayvan_kabul_bilgileri kabul,
      mzb_hayvan_bilgileri hayvan
    WHERE kabul.id = hayvan.hayvan_kabul_id
    AND NOT EXISTS
      (SELECT 1
      FROM mzb_ante_mortem_hay_bilgileri antehayvan
      WHERE antehayvan.hayvan_id=hayvan.id
      )
    )
  AND hayvankabul.YETISTIRICI_KENTLI_ID=kentli.ID
  ORDER BY hayvankabul.id DESC;

Saturday, July 5, 2014

JavaScript-Remove everything after a certain character and string compare

function myFunction() {
    var str1 = "15.09.2012 19:30";
    var str2 = new Date().format("dd.mm.yyyy");
    var result = "";

    var str3 = str1.substring(0, str1.indexOf(' ')); //str3= "15.09.2012"

    var isEqual = str2.localeCompare(str3);
    if (isEqual == 0)
        result = str3 + ' and ' + str2 + ' are same!';
    else
        result = str3 + ' and ' + str2 + ' are different!';
}

Wednesday, July 2, 2014

Solution for "ora-12638 credential retrieval failed" Problem

This is an Oracle database connection problem and it might occur when you try to connect an Oracle database by using an Oracle client.

Here is the solution for this problem;

  • Go to sqlnet.ora file which is normally under this folder:  C:\..\client\network\admin
  • Open it with something like Notepad ++
  • Change SQLNET.AUTHENTICATION_SERVICES=(NTS) to SQLNET.AUTHENTICATION_SERVICES=(NONE) 
  • Save the changes, that is all.
Error Message:
ORA-12638: Credential retrieval failed


Happy coding.

Tuesday, July 1, 2014

Solution for "Can not obtain Oracle client information from registry"

This problem occurs when you have installed a 32-bit Devart driver together with a 32-bit OraClient on a 64-bit operating system.

All you need to do is;

  • Go to your iis settings. 
  • Go to your web site's application pool.
  • Go to advanced settings of the application pool and set "Enable 32-Bit Applications" option to true.
  • Save the settings, that is all.

Error Message:
Can not obtain Oracle client information from registry. Make sure that Oracle Client Software is installed, or use Direct mode of connecting to server.

Happy coding.

Wednesday, June 25, 2014

C# LINQ Grouping Data

var tureGoreHayvanBilgileri = from p in hayvanBilgileri
                              group p by p.TURU into g
                              select new { TURU = g.Key, HAYVANLAR = g };