473,287 Members | 1,659 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,287 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 1076

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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
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...

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.