Skip to main content

Posts

PL/SQL Unique Constraints

create table supplier (   supplier_id numeric(10) not null,   supplier_name varchar2(50) not null,   contact_name varchar2(50),   constraint u_supplier_id unique(supplier_id) ); end; create table supplier (   supplier_id numeric(10) not null,   supplier_name varchar2(50) not null,   contact_name varchar2(50),   constraint u_supplier unique(supplier_id, supplier_name) ); end; declare   v_supplier_name supplier.contact_name%type; begin   select user   into v_supplier_name   from dual;   insert into supplier   (     supplier_id,     supplier_name,     contact_name   )   values   (     seq_supplier_id.nextval,     v_supplier_name,     'Test'   ); end; select * from supplier;

PL/SQL Using Sequence in Insert Command

declare   v_last_name employees.last_name%type;   v_hire_date employees.hire_date%type; begin   select user, sysdate   into v_last_name, v_hire_date   from dual;     insert into employees     (       employee_id,       first_name,       last_name,       email,       hire_date,       job_id     )     values     (       seq_employee_id.nextval,       'Test',       v_last_name,       '[email protected]',       v_hire_date,       'IT_PROG'     ); end; select * from employees where job_id like '%IT%'; insert into employees (   employee_id,   first_name,   last_name,   email,   hire_date,   job_id ) values (   seq_employee_id.nextVal,   'Nurhak',   'K...

Using Apache log4net in C#/.NET

Here are the steps; Download the latest version of log4net library from Apache web site  and add reference of log4net.dll in to your project. Go to your project's AssemblyInfo.cs file and add below line at the end of it.                        [ assembly : log4net.Config. XmlConfigurator (Watch = true )] Go to your project's Web.config file and add these in it, just below <configuration> tag. < configSections >     < section name = " log4net " type = " log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 " />   </ configSections >   <!-- Log4net Logging Setup -->   < log4net >     < appender name = " FileAppender " type = " log4net.Appender.FileAppender,log4net " >       < file value = " c:\\mylogfile....

PL/SQL Working with Columns

Drop & Modify Constraints alter table table_name drop constraint PK_XXX_XXX_ID; alter table table_name modify constraint FK_XXX_XXX_XXX_ID enable; alter table table_name modify constraint FK_XXX_XXX_YYY_ID enable; alter table table_name modify constraint FK_XXX_XXX_ZZZ_ID enable; --validation disabled alter table table_name modify constraint CHK_XXX_XXX_TTT_NAME enable novalidate; Add Constraints ALTER TABLE table_name add CONSTRAINT FK_XXX_XXX_XXX_ID    FOREIGN KEY (column_name)    REFERENCES reference_table (ID); Rename Table alter table table_name rename to new_table_name; Rename Columns alter table table_name rename column column_name_x to new_column_name_x; alter table table_name rename column column_name_y to new_column_name_y; alter table table_name rename column column_name_z to new_column_name_z; Add Columns alter table    table_name add    (     USER_ID NUMBER(18,0) DEFAULT 1 NOT NULL ENAB...

PL/SQL Oracle Dual Table

select * from locations end; declare   v_city locations.city%type; begin   select 'Roma'   into v_city   from dual;   dbms_output.put_line('Selected city is; '||v_city); end; declare   v_city locations.city%type; begin   select 'Roma'   into v_city   from dual;   update locations   set city=v_city   where postal_code='6823'; end; declare   v_postal_code locations.postal_code%type; begin   select '6823'   into v_postal_code   from dual;   dbms_output.put_line(v_postal_code);   update locations   set city='Romaxx'   where postal_code=v_postal_code; end;