I am creating a stored procedure that, when I pass it a manufacturer's number, will print out (DBMS_OUTPUT.PUT_LINE) 5fivefields (I choose) from the manufacturer's table. I am having trouble including headings in the output. I also need to include my name in the heading. And, if a manufacturer isn't found, I want to print out the asked for ID and a "NOT FOUND" message.
Because DBMS_OUTPUT will only print what you tell it to, you will have to provide the proper calls to DBMS_OUTPUT to print any headings and other information you desire.
To print headings with DBMS_OUTPUT, you can simply format the first line of output you send to have the proper column names displayed. Since you know the values you'll be displaying, you should easily be able to create a heading line.
As far as the "NOT FOUND" message goes, I'll assume that you are using a SELECT...INTO statement to get your data. If that's the case and an invalid manufacturer is asked for, the SELECT should generate a NO_DATA_FOUND error. In the exception section, simply code a WHEN NO_DATA_FOUND handler to use DBMS_OUTPUT to put out the NOT FOUND message you desire.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle stored procedures
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.