Custom Search
Showing posts with label PL/SQL block. Show all posts
Showing posts with label PL/SQL block. Show all posts

Wednesday, 30 November 2011

Write a trigger that check the mark is not zero or negative, PL/SQL trigger that check the mark is not zero or negative


Write a trigger that check the mark is not zero or negative, PL/SQL trigger that check the mark is not zero or negative


create table astd(mark number(3));


insert into astd values(&mark);

SQL> select * from astd;


MARK

---------

23

0

800

0

0


set serveroutput on

create or replace trigger tri29 before insert on astd for each row

declare

tmark astd.mark%type;

begin

tmark:=:new.mark;

if tmark>700 or tmark<0 then

raise_application_error(-20003,'Invalid Mark');

end if;

end;

Write a Trigger to ckeck the Pincode is exactly six degit or not., Write a PL/SQL Trigger to ckeck the Pincode is exactly six degit or not


Write a Trigger to ckeck the Pincode is exactly six degit or not.,  Write a PL/SQL Trigger to ckeck the Pincode is exactly six degit or not

create table citypin(

pin number(10));


insert into citypin values(&pin);


SQL> select * from citypin;


PIN

---------

2434355

3435465

122

123235467


set serveroutput on

create or replace trigger tri28 before insert on citypin for each row

declare

tpin citypin.pin%type;

begin

tpin:=:new.pin;

if length(to_char(tpin))!=6 then

raise_application_error(-20002,'Your Pincode is Invalid');

end if;

end;

Write a PL/SQL block to raise the salary by 20% of given employee on following table.., PL/SQL Program to raise the salary by 20% of given employee on following table


Write a PL/SQL block to raise the salary by 20% of given employee on following table.., PL/SQL Program to raise the salary by 20% of given employee on following table

Emp_Salary (eno, ename, city, salary)

Table Creation…

eno number primary key,

ename char(15),

city char(15),

sal number(10,2));

insert into empsal values(1,'Hiral','Mehsana',20000);

insert into empsal values(2,'Pinkey','Mehsana',15000);

insert into empsal values(3,'Dhruvi','Mehsana',10000);


Program…

declare

n number;

s number(10,2);

begin

n:=&n;

--select sal into s from empsal where eno=n;

update empsal set sal=sal+(sal*0.20) where eno=n;

end;

Write a PL/SQL block to display the Information of given student on following table Stud (sno, sname, address, city)., PL/SQL Program to display the Information of given student on following table Stud (sno, sname, address, city)


Write a PL/SQL block to display the Information of given student on following table Stud (sno, sname, address, city)., PL/SQL Program to display the Information of given student on following table Stud (sno, sname, address, city)


Table Creation…
create table stud(

sno number primary key,

sname char(15),

addr varchar(30),

city char(15));

insert into stud values(1,'hiral','2,krishna society','Mehsana.');

insert into stud values(2,'pinky','4,Kalyaneshwer society','Mehsana.');

insert into stud values(3,'Dhruvi','24,Pushpavati society','Mehsana');


Program…


declare

no number;

n number;

name char(15);

add varchar(50);

c char(15);

begin

n:=&n;

select sno,sname,addr,city into no,name,add,c from stud where sno=n;

dbms_output.put_line('The Sno is ' || no);

dbms_output.put_line('The Sname is ' || name);

dbms_output.put_line('The address is ' || add);

dbms_output.put_line('The city is ' || c);

end;

Laptops