0

I am trying to Insert a line into a table using PLSQL. The table name is DOCUMENT_ISSUE_HISTORY. I am using an API Procedure name PROCEDURE

Insert_New_Line_ (
   doc_class_ IN VARCHAR2,
   doc_no_ IN VARCHAR2,
   doc_sheet_ IN VARCHAR2,
   doc_rev_ IN VARCHAR2,
   info_category_db_ IN VARCHAR2,
   note_ IN VARCHAR2 );

I am confused if PRECEDURE can return value like function does. I am doing this:

DECLARE
    doc_class_ varchar2(4000) := 'CVS FILE';
    doc_no_ varchar2(4000) := '01004901.DWG-DWF';
    doc_sheet_ varchar2(20) := 1;
    doc_rev_ varchar2(20) := -1;
    info_category_db_  VARCHAR2(20) :=  NULL;
    note_ VARCHAR2(4000) := 'TEXTING TO UPDATE or FIeld to update';

BEGIN

Document_Issue_History_API.Insert_New_Line__ (doc_class_ ,doc_no_,doc_sheet_,doc_rev_ ,info_category_db_,note_);

end;

How can I can insert the line in the table?

Littlefoot
  • 131,892
  • 15
  • 35
  • 57
JLSG
  • 27
  • 7
  • Possible duplicate of [Functions vs procedures in Oracle](https://stackoverflow.com/questions/25419629/functions-vs-procedures-in-oracle) – kara May 23 '18 at 07:01

1 Answers1

0

Functions have return values and hence may appear anywhere an expression may be used (such as to the right of the assignment operator, or as a column expression in a SQL statement) while Procedures do not have return values and may not be used as expressions.

This is not to say that procedures can't return values, because they can as long as they are OUT or IN/OUT parameters. You just can't use the procedure directly in an expression.

Similarly since Functions do have a return value (other than those parameters specified as OUT or IN/OUT parameters) they must be used in an expression and can't be called directly.

Sentinel
  • 6,379
  • 1
  • 18
  • 23
  • How can I add a record line using the PLSQL without using INSERT? – JLSG May 22 '18 at 21:42
  • Well, How can I create a function inside the PACKAGE to be able to Insert a line to the table? Is It possible? – JLSG May 22 '18 at 21:45
  • Regarding your 1st comment, ultimately you can't insert into a table without eventually having an INSERT statement somewhere. Re Comment 2) to create a function in a package just declare it `function (input data_type, ...) returns SomeDataType as [local declarations] BEGIN END [YourFunctionName];` – Sentinel May 22 '18 at 22:05