473,399 Members | 2,146 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,399 software developers and data experts.

Stored function

Create a stored function that adds an employee to the employees table. The function must accept enough values to add a row to the employees table and return a character string. the return character string should be "Success" of the employee was added as a result of an error(analyze the types of errors that can be raised when the function is executed and create the code to handle those errors). Write an sql statement that will invoke the procedure and display the result
Aug 18 '10 #1
1 1802
amitpatel66
2,367 Expert 2GB
It seems to be an assignment or a homework question. I will give you an hint to start with:

Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE FUNCTION insert_employee(empno NUMBER,ename VARCHAR2,age NUMBER,dept NUMBER) RETURN VARCHAR2 IS
  2. BEGIN
  3. --<insert the values in to emp table>>
  4. --commit your transaction
  5. --return 'success';
  6. --handle exception using below block
  7. EXCEPTION
  8. WHEN OTHERS THEN -- to handle all kind of exceptions
  9. --return failure
  10. END;
  11.  
  12.  
Also note, if any DML statement is executed within a function, you cannot invoke that function using a SQL. Though this is possible to do using "precompiler derivatives" PRAGMA, research on oracle precompiler derivative and check how you can make your function work from sql statement.
Aug 19 '10 #2

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

Similar topics

0
by: Sachin Narasimhan via .NET 247 | last post by:
(Type your message here) Hi, I am at my wits end. It would be great if someone can help. Wehave a Stored Function(Oracle) that returns a boolean that wecannot change to return something else and we...
1
by: LineVoltageHalogen | last post by:
I have many stored procs in my database and I can call them just by their name uspMyProc with success always. However, I just created a user function ufnMyFunction as the same user that I created...
4
by: Sameer Deshpande | last post by:
How do I create and return user defined data types in DB2. F.ex In Oracle I can create a user define datatype and return this data type from stored function. How can I do the same in DB2? ...
2
by: Roger | last post by:
I put this in the microsoft.public.dotnet.langueages.vb.data newsgroup, but noticed there aren't alot of people there frequently like this newsgroup. So I thought I would try here. I get an...
2
by: lnd | last post by:
This was probably asked n-times but still: Is there any way to end (commit/rollback) a transaction inside a stored function? (The reason why it is good to commit/rollback in a stored procedure...
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
4
by: Alchemist | last post by:
I am using Python 2.4 and Postgresql 8.2 database server. On the database I have created a stored function, example, CREATE OR REPLACE FUNCTION calculateaverage() I created a new python script...
8
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
2
by: Jivanmukta | last post by:
Hello, I have little experience in PHP+MySQL programming. I need your help in such problem: how to call stored MySQL function from PHP5 code using mysql_ interface? I failed to find solution in...
0
by: mstres | last post by:
How to call Stored Function in Mysql from Access 2003 Access 2003 I am using as Front End and Access DB have a link table to MySql DB with ODBC connection Thank you Mike
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.