create table phone_details (name varchar2(100), description varchar2(255), availability char, price float, in_stock int, rating float);
insert into phone_details values ('Samsung 7x', 'phone with 8mp camera & voice recording', 'y', 3999.0, 3, 4.5)
insert into phone_details values ('sony 98x', 'phone with 32GB memory & Bluetooth', 'y', 6999.0, 5, 4)
insert into phone_details values ('realme 3', 'phone with 8mp camera & wifi calling', 'y', 4999.0, 10, 3.5)
insert into phone_details values ('one plus 4', 'phone with 64GB memory, wifi, Bluetooth, 16mp camera', 'y', 9999.0, 7, 4.5);
select name from phone_details;
select description, price, in_stock, rating from phone_details;
create table book_details (book_name varchar2(100), author_name varchar2(100), book_description varchar2(255), price float, in_stock int, primary_keyword varchar2(10), secondary_keyword varchar2(10), rating float);
insert into book_details values ("Let us C", "Yashwant K.", "Learn C programming", 200.25, 3, "C", "software", 4.5);
insert into book_details values ("Let us C++", "Yashwant K.", "Learn C++ programming", 230.25, 5, "C++", "C", 4.5);
insert into book_details values ("Head first Java", "Kathy Sierra", "Learn Java programming", 330, 10, "Java", "JVM", 3.5);
insert into book_details values ("Java: The complete reference", "Mc Graw Hill", "7th edition, learn Java programming", 783, 4, "Java", "Javabeans", 4);
insert into book_details values ("Thinking in Java", "Bruce Eckel", "Java programming basics", 3000, 5, "Java", "JVM", 4.5);
select * from book_details where primary_keyword like '%java%';
select * from book_details where primary_keyword like '%java%' and rating > 4;
select * from book_details where author_name like '%Yashwant%';
select in_stock, book_name, price from book_details where book_name = 'Let us C';
update book_details set in_stock = in_stock-1 where book_name = 'Let us C';
select * from book_details where book_name = 'Let us C';
delete from book_details where rating < 4;
create table student (id integer primary key autoincrement, student_name varchar2(50), dept varchar2(10), major_subject varchar2(10), student_id varchar2(50), email varchar2(50) not null, pwdhash binary(64) not null);
CREATE PROCEDURE dbo.addStudent
email VARCHAR2(50),
pwdhash binary(64),
student_name VARCHAR2(50),
dept VARCHAR2(10),
major_subject VARCHAR2(10),
student_id VARCHAR2(50) as concat(id,'_',dept),
responseMessage NVARCHAR(250) OUTPUT
AS
BEGIN
SET NOCOUNT ON
BEGIN TRY
INSERT INTO student values(student_name, dept, major_subject, student_id, email, pwdhash);
SET @responseMessage=' Success.'
END TRY
BEGIN CATCH
SET @responseMessage=ERROR_MESSAGE()
END CATCH
END
Do'stlaringiz bilan baham: |