473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

i m having no idea how to do it

i have completed these q. in sql but unable to do it in pl/sql let me help or give me path to do it




Exercises :



Q 1) Display department number and sum of the salaries of employees in each department.

select deptname,deptno,sum(sal) from emp group by deptno,deptname;
/


Q 2) Display the employee with the maximum salary

SELECT ename,sal FROM emp
wHERE sal = (SELECT MAX(sal) FROM emp);
/


Q 3) Create a table t1 with fields c11, c12, c13 all numbers, Create a table t2 with c21, c11,c23 as fields (all numbers)

such that c11 is the primary key of t1 and the foreign key in t2. insert 5 records in each table.

creating t1:-
create table t1(c11 number NOT NULL PRIMARY KEY,c12 number,c13 number);/
/

creating table t2
create table t2(t1 number,c21 number,c23 number,FOREIGN KEY (t1) REFERENCES t1(c11))
/

Q 4) After doing Q2 delete table t1.

delete from t1;

delete from t1
*
ERROR at line 1:
ORA-02292: integrity constraint (SCOTT.SYS_C0010480) violated - child record
found

A foreign key references is where one field "links" to another table.

The database will maintain referential integrity - this means that there must be a corresponding record in the other table - in this example each track must be on an album that exists in the album table.

The field (or fields) linked to must be unique - usually the other field is the primary key of the other table.

DROP TABLE t2;
DROP TABLE t1;


Q 5) Just like employee table emp, create another table emp1(same structure as emp). Insert 5 records same as emp and

5 different records not in emp, Then write one single select query to select records from emp and emp1 for each condition given below:



a) Repeated records are also displayed

ans:-
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,DEPTN AME from emp
union all
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,DEPTN AME from emp1
/


b) Repeated records are not displayed

ans:-
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,DEPTN AME from emp
union
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,DEPTN AME from emp1
/



Q 6) Display the department name of employee having the minimum salary.

select deptname,ename from emp where sal = (SELECT min(sal) FROM emp);



Q 7) After finishing off Questions 1 to 6 in SQLPLUS, write a procedure for each with name same as the question number.
Aug 3 '07 #1
0 1077

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Markku Uttula | last post by:
I think I'm doing something wrong. I'm able to connect to Oracle just fine, execute queries and all, but I'm having serious problems with the speed :( For example, the following PHP-script on my...
0
by: nino9stars | last post by:
Hello, I have a table (PEOPLE) with the following information (Id, Name) I have another table (CLASSES) with the following information (Id, Course, Section, Term) I want to get all the...
11
by: Jeff Robichaud | last post by:
Are there any security issues having the ASPNET user account member of Administrators ? Is it a good practice ?
7
by: Andrew Christiansen | last post by:
Hey everyone. I have Visual Basic .NET 2003 and am trying to show images on a treeview control. I have the imagelist on the form filled with images, and have the ImageList property of the...
1
by: vbDavidC | last post by:
I am adding a new record to a table via a dataset/adapter. I have got the following to work for me but I am wondering if there is a better way to do this. I am having to have something in my...
2
by: ARC | last post by:
Just curious if anyone is having issues with Acc 2007 once the number of objects and complexity increases? I have a fairly large app, with many linked tables, 100's of forms, queries, reports, and...
28
by: jmDesktop | last post by:
Studying OOP and noticed that Python does not have Interfaces. Is that correct? Is my schooling for nought on these OOP concepts if I use Python. Am I losing something if I don't use the...
2
by: Jack | last post by:
Hi, Performance-wise, is there a difference between these 2 clauses? I assume a large database... 1) With the WHERE clause: Select FLD1, FLD2, FLD3 From myFile Where FLD1 = 1 And FLD2 = 1
7
by: tiptap | last post by:
Hey Guys, I have a huge statement loads of if statements in... and its getting bigger. On closer inspection there is only 3 difference in the select statement. so I thought I could cut the...
4
by: muddy22 | last post by:
I'm only having a problem with a small part, i'm fairly new to computer programming and the program i'm using is Dev-C++. The part that i'm having a problem with is this: int WINAPI WinMain...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.