473,769 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PL/SQL theoretical questions

kiss07
99 New Member
Hi,

i want 2 and 3 rd max salary in a table .i want a single query.

please help..

Arun
Apr 23 '07
70 6215
debasisdas
8,127 Recognized Expert Expert
A sample example of
NO_DATA_FOUND exception
=============== =============
Expand|Select|Wrap|Line Numbers
  1. DECLARE
  2. NAME VARCHAR2(20);
  3. NO INT:=&NO;
  4. BEGIN
  5. SELECT ENAME INTO NAME FROM EMP WHERE EMPNO=NO;
  6. DBMS_OUTPUT.PUT_LINE(NAME);
  7. EXCEPTION
  8. WHEN NO_DATA_FOUND THEN
  9. RAISE_APPLICATION_ERROR(-20002,'NO DATA IS FOUND FOR THIS RECORD.....!');
  10. WHEN OTHERS THEN
  11. RAISE_APPLICATION_ERROR(-20003,'SOME OTHER ERROR........!');
  12. END;
  13.  
May 7 '07 #11
debasisdas
8,127 Recognized Expert Expert
A sample example of
INVALID_CURSOR exception
=============== ========
Expand|Select|Wrap|Line Numbers
  1. DECLARE
  2. CURSOR c1 IS SELECT ename FROM emp WHERE ROWNUM < 11;
  3. name emp.ename%TYPE;
  4. BEGIN
  5. OPEN c1;
  6. LOOP
  7. FETCH c1 INTO name;
  8. EXIT WHEN c1%NOTFOUND;
  9. dbms_output.put_line(c1%ROWCOUNT || '. ' || name);
  10. END LOOP;
  11. CLOSE c1;
  12. dbms_output.put_line(c1%ROWCOUNT); 
  13. exception
  14. when invalid_cursor then
  15. raise_application_error(-20001,'invalid operation in cursor');
  16. END;
  17.  
In the above example the cursor is invalid because of trying to access the cursor attribute %rowcount after the cursor is closed(in 2nd dbms_output ......). This raises INVALID_CURSOR exception.
May 7 '07 #12
kiss07
99 New Member
Dear Debasisdas,

Am really proud of Your answer. Thanku Very much.

Regards,
Arun..
May 8 '07 #13
kiss07
99 New Member
dear friends,

I have some doubt .
This is sample program

DECLARE
---
BEGIN
SELECT employee_id, last_name, salary INTO emp_id, emp_lastname,
emp_salary FROM employees WHERE employee_id = 120;
UPDATE emp_name SET salary = salary * 1.1 WHERE employee_id = emp_id;
DELETE FROM emp_name WHERE employee_id = 130;
INSERT INTO emp_name VALUES (emp_id, emp_lastname, emp_salary);

--SOME DML STATEMENTS
--this is sample . but contain lot of statemnts are there in this body.
Delete .............
insert ...............
select ............... ...

END;


i got an error .i don't known which statement.
How can i find out which statement is got an error.How can i handle this error statement..

Pls explain briefly........ ...


Arunkumar
May 8 '07 #14
debasisdas
8,127 Recognized Expert Expert
If u r using sql* plus

To solve this better use any tool like TOAD or PLSQL DEVELOPER.

Since u r new to pl/sql it will be difficult for you to find the bug using sql* plus.
May 8 '07 #15
pradeep kaltari
102 Recognized Expert New Member
If u r using sql* plus

To solve this better use any tool like TOAD or PLSQL DEVELOPER.

Since u r new to pl/sql it will be difficult for you to find the bug using sql* plus.
Arun,
You can also use
SHOW ERRORS command. This will also give you the line number where the error has occured.
May 8 '07 #16
kiss07
99 New Member
Dear friends,

what is nested table?
i want a sample program in nested table and varray in oracle pl/sql.

Regards,
Arun..
May 9 '07 #17
kiss07
99 New Member
Dear debas,

Is there possible a cursor,not needed open and close in static cursor.one person ask to me in interview.
I think is possible .You have any idea ? possible means some code to me..

Regards,
Arun..
May 9 '07 #18
kiss07
99 New Member
Dear debas,

1)how many unique are allowed in a table?
2) How many foreign key are allowed in table?
3)create trigger t_trig
after insert on emp

begin

insert into log values(username ,sysdate);

end;


now i insert 100 records in emp table .How many records insert in log table

choose:

1)100 records.
2) 1 record.


thanks,

Arun..
May 9 '07 #19
debasisdas
8,127 Recognized Expert Expert
If u r using for loop then no need to open or close the cursor.
May 9 '07 #20

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

Similar topics

16
1872
by: Materialised | last post by:
I have been given the task, of developing a program to sit next to a cgi based c program (I know this is offtopic but my question does only refer to the standard c part of the code). Basically what the program needs to do, is open a text file, containing hundreds maybe even thousands of items, and remove duplicate items. Also if the line length exceds a certian amount of characters, I wish to remove it. I was thinking of using malloc...
0
4102
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for all companies between year 2000-2005 in my website http://www.geocities.com/allinterviewquestion/ So please have a look and make use of it.
0
4597
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
7226
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
4
2512
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for cross-posting. I am trying to build a "checklist", where a user can navigate to an ASP page on the intranet which shows a list of "questions" that the user can check off. I am trying to figure out how to do this so that it is scalable, but I am...
8
783
by: sqlservernewbie | last post by:
Hi Everyone, Here is a theoretical, and definition question for you. In databases, we have: Relation
8
7984
by: Krypto | last post by:
Hi, I have used Python for a couple of projects last year and I found it extremely useful. I could write two middle size projects in 2-3 months (part time). Right now I am a bit rusty and trying to catch up again with Python. I am now appearing for Job Interviews these days and I am wondering if anybody of you appeared for a Python Interview. Can you please share the questions you were asked. That will be great help to me.
0
1469
by: Joseph Ferris | last post by:
Good afternoon, I understand the basic theories of capacity planning as it relates to profiling an existing web site, such as in the examples given in the MSDN Article, "How To: Perform Capacity Planning for .NET Applications" http://msdn2.microsoft.com/en-us/library/ ms979198.aspx]. This assumes the existence of an application to profile, though. What is a good way to perform a more abstract, theoretical assessment
0
1500
by: ramu | last post by:
C# Interview Questions and Answers8 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html C# Interview Questions and Answers7 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html C# Interview Questions and Answers 6 http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html C# Interview Questions and Answers 5...
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.