Friday, April 4, 2014

PL/SQL Update Next Value of a Sequence

declare
    deger number:=0;
begin
    select SCHEMA_NAME.SEQ_ENG_ENG_BILGILERI_ID.nextval
    into deger
    from dual;
   
     dbms_output.put_line(deger);
end;

ALTER SEQUENCE PROBBYS.SEQ_ENG_ENG_BILGILERI_ID INCREMENT BY 1000;
SELECT PROBBYS.SEQ_ENG_ENG_BILGILERI_ID.NEXTVAL FROM dual;
ALTER SEQUENCE PROBBYS.SEQ_ENG_ENG_BILGILERI_ID INCREMENT BY 1;

Wednesday, April 2, 2014

C# Generics

//Main Program - Calling the GetResults Method
string mesaiBitisSaati = CommonClass.GetResults<string>(SystemCodes.MZB, 1);

//CommonClass - GetOneResult Method
public static T GetResults<T>(SystemCodes sistemKodu, decimal parametreKodu)
{
            try
            {
                object param = GetOneResult(sistemKodu, parametreKodu);
                return (T)Convert.ChangeType(param, typeof(T));
            }
            catch
            {
                return default(T);
            }
}

//CommonClass - GetOneResult Method 
public static string GetOneResult(SystemCodes sistemKodu, decimal parametreKodu)
{
            try
            {
                using (ProbelTESTEntities context = EntityProvider<ProbelTESTEntities>.NewContainer())
                {
                    TEST_TABLE param = context.TEST_TABLE.Where(x => x.SISTEM_ID == (decimal)sistemKodu &&
                                                                                        x.DEPARTMENT_ID == CommonInfos.ActiveUser.Department.Id &&
                                                                                        x.KODU == parametreKodu)
                                                                                        .SingleOrDefault();
                    return param.Assigned() ? param.DEGERI.ToUpper() : null;
                }
            }
            catch
            {
                return null;

            }

}

Thursday, March 6, 2014

PL/SQL Update Table Where id in Select Another Table

update schema_name.table_name
set tur_id=24
where id in(select id
            from schema_name.table_name
            where tur_id not in (1,24,3,4,5,7,23,21));

PL/SQL Insert Into Select From Multiple Tables

insert into schema_1.table_1
(
  id,
  kurum_id,
  adi,
  kayit_kullanici_id,
  kayit_tarihi
)
select
  id,
  1,
  nls_upper (aciklama, 'nls_sort=xturkish'),
  user_id,
  user_date
from schema_1.table_2;

Friday, February 21, 2014

Tuesday, February 18, 2014

PL/SQL Connect By Prior

select * from test_table_name connect by prior id=root_id start with root_id=211;

declare
  cursor c_birim
  is
  select *
  from test_table_name
  connect by prior id=root_id
  start with root_id=211;
begin
  for r_birim in c_birim loop
      update test_table
      set tur_id=1
      where id=r_birim.id;
    end loop;
end;



Friday, February 7, 2014

PL/SQL Not Exists

    select     user.id, user.name
     from     schema.table_users user
   where not exists ( select dept.kullanici_id
                  from schema.table_departments dept
                  where dept.user_id=user.id)
 order by user.id;