Doubt about PL / SQL function

0

I wanted to know how to create a function that inserts data into a table.

What value should I return ( return )?

With a procedure I do it correctly, but when it comes to doing it with a function, I do not understand what value I should return.

    
asked by alvaro guerrero vallejo 18.04.2017 в 19:56
source

1 answer

2

For your case the correct form is for a procedure because you do not necessarily have to have a return.

However the structure of a function is as follows.

CREATE [OR REPLACE] FUNCTION function_name
   [ (parameter [,parameter]) ]

   RETURN return_datatype

IS | AS

   [declaration_section]

BEGIN
   executable_section

[EXCEPTION
   exception_section]

END [function_name];

Where return_datatype must necessarily return a value. As it can be 0 in case the execution of insert was correct, and in case there has been a exception , return a 1, so that the program that occupies this function, understands whether or not the insertion of the the data in that table.

If you need more clarification, go leaving in the comments.

I hope this helps you. Greetings and success in your project

    
answered by 18.04.2017 в 20:01