Posts

Showing posts from February, 2013

PL/SQL Working with Date Value

select * from table_name where id=181
and column_date=to_date('28.02.2013 10:39:15', 'dd.mm.yyyy hh24:mi:ss');

select to_char(current_date, 'DD-MM-YYYY HH:MI:SS') from dual;


Working with "Paths" in C#

using System;
using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ProTestService {     classProgram     {          staticvoid Main(string[] args)          {              string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);              path = Path.Combine(path.Replace("file:\\", ""), "test.txt");              using (StreamWriter newTask = newStreamWriter(path, true))              {                   newTask.WriteLine("ProTestService calisma zamani--> " +DateTime.Now.ToString());              }          }      } }

PL/SQL Insert into one table from another by using sequence

insert into table_1
(
  col_1, col_2, col_3
)
select  seq_my_sequence.nextval,
        k.col_2,
        k.col_3,
        from my_schema.table_2 k;

PL/SQL Synonym and Grant

grant select on table_name to schema_name;

grant select on seq_name to schema_name;

grant insert on table_name to schema_name;

grant update on table_name to schema_name;

grant execute on schema_name_x.pkg_package_name to schema_name_y;

------

create or replace synonym schema_name_2.table_name for schema_name_1.table_name;

drop sysnonym schema_name_2.table_name;


PL/SQL Using In&In Reverse Options in the Loop

begin
  for v_counter in 0..10 loop
      if mod(v_counter,2)=0 then
            dbms_output.put_line('v_counter='||v_counter);
          end if;
    end loop;
    dbms_output.put_line('Done...');
end;

begin
  for v_counter in reverse 0..10 loop
      if mod(v_counter,2)=1 then
            dbms_output.put_line('v_counter='||v_counter);
          end if;
    end loop;
    dbms_output.put_line('Done..');
end;


*******outputs********
v_counter=0
v_counter=2
v_counter=4
v_counter=6
v_counter=8
v_counter=10
Done...

v_counter=9
v_counter=7
v_counter=5
v_counter=3
v_counter=1
Done..

PL/SQL Use Loop with "Exit When" Condition

declare
  v_student_id students.section_id%type:=5;
  v_surname students.student_surname%type;
begin
  loop
        v_student_id:=v_student_id+1;
        insert into students
        (
          student_id,
          student_surname
        )
        values
        (
          v_student_id,
          'Test xyz'
        );
        exit when v_student_id=10;
      end loop;
      dbms_output.put_line('Done...');
end;