Function in the procedure call

Hi team

I have a question, if I create function inthat I create procedure then how to call the procedure only please give little example

Thank you

Hello

Here is a little example:

SQL> set serverout on
SQL> create or replace function test
  2  return varchar2
  3  as
  4    my_var varchar2(4);
  5   --
  6    procedure my_proc
  7    is
  8    begin
  9       dbms_output.put_line('Hello World');
 10    end my_proc;
 11  begin
 12     my_proc;
 13     my_var := 'Done';
 14  return my_var;
 15  end;
 16  /

Function created.

Elapsed: 00:00:00.01
SQL> select test from dual;

TEST
----------------------------------------------------------------------------------------------------
Done

1 row selected.

Hello World
Elapsed: 00:00:00.04

Tags: Database

Similar Questions

  • The execution of a function in the procedure, passed as parameter string

    Hello

    He must create a function, pass the name of the function to a procedure, and then run this function in the procedure.

    For example:

    Hello from the FUNCTION to CREATE or REPLACE

    RETURN NUMBER

    IS

    BEGIN

    RETURN 23;

    END;

    /

    CREATE OR REPLACE PROCEDURE pro_fun (v_fun VARCHAR2, v_cal OUT NUMBER)

    IS

    BEGIN

    v_cal: = exec v_fun; <-error on this line

    END;

    /

    Now my plsql block annonymous where I'm passing function as sting of procedure:

    DECLARE

    VARCHAR2 (30) v1.

    NUMBER of v2;

    BEGIN

    v1: = "Hello";

    pro_fun (v1, v2);

    DBMS_OUTPUT. Put_line ('VALUE IS' | v2);

    END;

    /

    pro_fun (v1, v2);

    *

    ERROR on line 6:

    ORA-06550: line 6, column 1:

    PLS-00905: object SCOTT.PRO_FUN is not valid

    ORA-06550: line 6, column 1:

    PL/SQL: Statement ignored

    How below line of procedure must be written to perform this function.

    v_cal: = exec v_fun;

    Try something like this:

    create or replace function forum_hello return number

    is

    Start

    Back to 123;

    end forum_hello;

    /

    create or replace procedure forum_call_function (function_name_in in varchar2)

    is

    number of l_returnvalue;

    Start

    run immediately "begin: l: = ' |" function_name_in |'; end;' using l_returnvalue;

    dbms_output.put_line (l_returnvalue);

    end;

    /

    exec forum_call_function ('forum_hello')

    Sincere greetings,

    Patrick Barel

  • The procedure call?

    Hello
    That's what I try to do, if you have some context to my problem.

    1. I'm putting some details for a command in a rowtype variable.
    2. I then tries to call a procedure that inserts data in providing this rowtype as a parameter variable.


    My code:

    DECLARE
    order_info mytable % rowtype;
    BEGIN
    order_info.ID: = '1';
    order_info. Name: = "lollipops".
    END;
    /

    create or replace procedure orderinsert (order_info in mytable % rowtype)
    AS
    BEGIN
    INSERT INTO mytable
    values order_info;
    END;
    /





    How do I get this to actually change the fact table? I'm on track for what I'm doing?

    Thank you

    >
    OK sorry I didn't know that he could compile and still be wrong.
    >
    What are you talking about? There's NOTHING wrong with the code of procedure you have posted.

    And there is nothing of syntactically wrong with the code of the anonymous block that you posted. The only thing missing, it's that you NEVER called the procedure.
    >
    Especially because the way that I am asked to do is... I guess that weird because there are easier ways to accomplish the task.
    >
    Yet, what are you talking about? What, exactly, is asked to do?
    >
    So in PL/SQL, you can use SQL, but you cannot combine elements of SQL and PL/SQL in the same statement, they stay separate?
    >
    What do you mean by any of this? Please explain.
    >
    I'm at least correct in declaring the rowtype first, then by assigning values to the columns, then by calling the procedure that the data will be transmitted via the parameter 'in '? Or is there a better way / okay to do that?
    >
    Never I demonstrated just to you when I added the procedure call to the anonymous block that you created?
    >
    If that is correct then I need to just find a way to put these data in the table of my database
    >
    Please explain. The procedure will be "put this data in the table" in your database.

    Almost nothing of what you say in this last answer makes no sense. What, exactly, you try to do?

  • imitate the situation when the procedure call fails

    Hi all

    My need is to emulate the situation when the procedure call fails and I have an exception.
    How can I make it?

    You can use, RAISE_APPLICATION_ERROR to raise a custom exception, or you can create a situation where an exception will be raised-for example inserting duplicate data in a table with a uniqueness constraint, inserting data with an invalid foreign key, taking a tablespace offline, using too many characters in a string assignment... the list is long.

    Published by: Bravid on August 12, 2011 08:37
    typo

  • the exception in the procedure call management

    Hello

    I have a package where currently make phone calls to private public process procedures.

    and the senario is: -.

    create package body p_tst
    is

    ex_failed exception;

    -It's private proc
    procedure p_private
    is
    Start
    .
    .
    raise ex_failed;
    exception
    When ex_failed
    then
    lift;
    .........
    end p_private;

    procedure p_public
    is
    Start
    ....
    -nomaking appeal to the private sector
    -procedure
    p_private;

    -Here, I need to catch
    -the exception thrown
    -past of callee
    -procedure
    When ex_failed
    ...
    end p_public;

    end;

    Basically, I want to catch any exception of procedure called passed to the procedure call and raise the same exception by calling procedure.

    is it possible to intercept the exception even in the calling procedure?

    Yes, p_private throws the exception, it will be taken by p_public and the program stops after dbms_output.

  • the procedure call in the other schema with credentials of this scheme

    Hi, experts.

    I have this problem. I need to call a procedure of WORKSPACEOWNER1 schema SCHEMA1, but I need to do this as SCHEMA1 was WORKSPACEOWNER1.

    This is the procedure:

    CREATE OR REPLACE procedure WORKSPACEOWNER1.Test_stop_process is
    workspace varchar2(500);
    begin
    
    owbsys.wb_rt_script_util.set_workspace('WORKSPACE1');
    owbsys.wb_rt_script_util.deactivate_all();  
    end;
    

    Now, if I call the WORKSPACEOWNER1 procedure is not problem, but when I call to SCHEMA1

    begin
    workspaceowner1.test_stop_process;
    end;
    

    Throw this error:

    ORA-20008: the workspace with the name: WORKSPACE1 and owner: SCHEMA1 does not exist.

    You can find out the information of existing workspace from the ALL_IV_WORKSPACE view or view WORKSPACE_ASSIGNMENT.

    ORA-06512: at "OWBSYS. WB_WORKSPACE_MANAGEMENT', line 1602

    This is because WORKSPACE1 exist for WORKSPACEOWNER1 not for SCHEMA1.

    Is this possible?

    Thanks in advance.

    Concerning

    Hi, Ana GH.

    Thanks for the reply.

    I checked in Gobals and safety, and Yes, SCHEMA1 is registered as a user of WORKSPACE1.

    Finally, I can solve the problem using DBLinks. Looks like dblink executes the procedure next to WORKSPACEOWNER1.

    I have create a DBLink as:

    CREATE the LINK of DATABASE link_wks CONNECT TO workspaceowner1 IDENTIFIED BY pass USING "orcl".

    Then this:

    BEGIN

    WORKSPACEOWNER1. Test_stop_process@link_wks;

    END;

    Works.

    Thanks to you all. I learned a lot.

    Concerning

  • How to find the name of the procedure call or a package?

    Hi all..

    Is it possible to find the name of the procedure or the calling package?

    I mean.. If proc_1 calls proc_2 how can I find in proc_2 proc_1 call?

    Proc_2 is called from a different procedure? I need to write to the size of the code that should fire depends on the Proc he calls?

    Please help me solve this problem.

    Thank you

    You could try OWA_UTIL. WHO_CALLED_ME
    "This procedure returns information (in the form of output parameters) on the unity of PL/SQL code that called it."
    See:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/w_util.htm#sthref11492

  • Create the function in the procedure

    Hi experts,

    is it possible to create a java function in odi procedure command

    ex:

    target technologies: java bean shell
    command:

    Public Shared Sub SayHello() {})
    System.out.println ("Hello");
    }

    Hello

    Yes its possible. Try to create a procedure with the code you said.

    Thank you
    G

  • Function within the statement call box SQL

    I have a procedure with many cases not to validate inside statements that compare the data in a table and fill in a description of the error of the dates. (snip of the size of the code below)

    create or replace procedure "PROC_TEMP_UPDATE"
    is
    begin
    update temp_update
    set error_desc = 
        CASE
        WHEN (error_desc != 'MATCH')
            THEN 'PCFN/TCN combo not found in destination table.'
        WHEN (error_desc = 'SKIP')
            THEN NULL
        WHEN (ge_ata is null and az_ata is not null)
            THEN 'Enter GE ATA Date before entering AZ ATA Date.'
        WHEN ((ge_ata is not null and az_ata is not null) and ge_ata > az_ata)
            THEN 'GE ATA Date cannot be greater than AZ ATA Date.'
           end proc_temp_update;
    
    
    

    Instead of having to enter the bottom 2 when reporting for each date, I created these functions:
    (Function 1: check if Date1 is null and Date2 is not.)
    Function 2 these two dates are not null, check if Date1 is greater than Date2.)

    function Is_D1_NULL
                (Date1  DATE, Date2 DATE)
                return BOOLEAN is
    
          result     BOOLEAN := FALSE; 
       begin 
          if (Date1 is null and Date2 is not null) then  
             result := TRUE; 
          end if; 
          return (result); 
       end Is_D1_NULL;
    

    You cannot use Boolean in SQL queries.  You must modify your function to return something like Y/N or 1/0 and assess against that.

    That said, move the engine of SQL and PL/SQL is, relatively speaking, cheap, so I let just the comparisons as they are in instruction box instead of calling a function.

    John

  • make sure that the procedure, called pl/sql from apex DURATION

    Hi gang,.

    I was wondering what the thoughts of the people where assuring him a packaged procedure is called in a session of runtime Apex, as opposed to sql * more or elsewhere.

    For example, how apex_mail.send to validate and output the following if executed from sql * more:
    ORA-20001: this procedure must be called from a session of the application.

    A simple call to check v ('APP_USER') wouldn't is not null enough?

    See you soon,.

    ScottWE

    Hello

    I think you could use the APEX_CUSTOM_AUTH.IS_SESSION_VALID function
    http://download.Oracle.com/docs/CD/E14373_01/apirefs.32/e13369/apex_auth.htm#BABHDFII

    Example of

    CREATE OR REPLACE PROCEDURE my_procedure(p_poaram1 VARCHAR2)
    AS
    BEGIN
    IF APEX_CUSTOM_AUTH.IS_SESSION_VALID THEN
     -- do stuff here when session is valid
    
    ELSE
     raise_application_error(20001,'Session is not valid');
    END;
    

    BR, Jari

  • How the procedure call stored procedure Store and no need to wait for the answer?

    There are two store procedure, sp1 and sp2, sp1 include sp2.


    If I have that sp1call but sp1 sp2 don't neet to wait the response of sp2, sp1 sp2 simply start and countinue to run the following command.

    How do I do?

    submit a job (DBMS_JOB) which sp2 excecutes in an autonomous transaction (which starts the task immediately)

  • ORA-06508, procedure cannot call the procedure of package

    I have a large stored procedure that calls a package (procedure) that manages a number of procedures to determine whether the process can continue or not.  (It checks authorization of the student to enroll in a class).  We have a web process calling the stored procedure, and that works fine.  What does not work, is a call to the package.  Oracle returned ORA-06508: PL? SQL: could not find program unit called.

    I have included instructions for debugging, so I know that it is the specific call to a procedure in the package fails with ORA-06508.  Thinking it's perhaps something in the package, I inserted a debug statement as the first line in the procedure called in the package.    (Debugging instructions call a procedure inserts of rows in a table of debugging with independent validation).

    When I log in the user account with sqlplus and run a test, everything works fine.  But when the web process is running under the same user, the process fails to call the procedure of package and fails with ORA-06508.

    It seems as if the web process runs with the rights of the appellant, or a role is not granted.

    Can someone help me understand what the problem is?

    offered hv, I appreciate your comments.

    We solved the problem: remove the package that couldn't be cited, then re-create.   That's all!

    Apparently, something in the database was tangled upward.   The server recently had problems with disk space, then it might have been related to that.  But we'll never know for sure.

    The stored procedure and packaging (procedures) which he called were owned by the same schema, and there is no mechanism that I can find to prevent one of the other appellant.  But that was the case - Oracle threw the ORA-06508 exception when the stored procedure called the package procedure.

    I replaced the stored procedure and package several times fine-tuning debugging code, but this has not fixed the problem.

    Finally let it drop and then re-create the package, it's which solved the problem.

    Regarding requests to view the code, there is no way that I could reproduce the problem, since the error that occurred was against the permissions and rules which packages run and the procedures of the Oracle.  Thanks for all the tips and suggestions.

  • procedure call with sys_refcursor as a parameter in the procedure

    Hello
    I tried the following procedure after sys_refcursor as parameter of a procedure,
    And confused about the procedure call
    CREATE OR REPLACE PROCEDURE test_ref (emp_cur IN sys_refcursor) IS
    emp_rec Z_emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH emp_cur INTO emp_rec;
    EXIT WHEN emp_cur%NOTFOUND;
    dbms_output.put_line(emp_rec.ename ||' is a ' || emp_rec.job);
    END LOOP;
    END;
    How can I call the above procedure to get the data

    Thank you

    You must declare a variable sys_refcursor and open it with the necessary query and then pass that variable as a parameter to your procedure.

    Something like that.

    set serveroutput on
    
    declare
      my_cursor sys_refcursor;
    begin
      open my_cursor for select * from employee;
      test_ref (my_cursor);
    end;
    /
    
  • insufficient privileges when you create sequence using the procedure

    CREATE OR REPLACE PROCEDURE schema1.proc1 AS
    BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE schema1.add_ins_seq';
    EXECUTE IMMEDIATE 'CREATE SEQUENCE schema1.add_ins_seq MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 1000 NOORDER  NOCYCLE';
    END;
    

    This procedure is created to schema1 by schema1.

    Schema1 boasts a CREATE SEQUENCE privilege.

    When I run this procedure through SQL Developer after the Cup to schema1, the error is thrown in insufficient privilege to CREATE SEQUENCE, however, DROP SEQUENCE is executed. I can create the sequence without the procedure call.

    If I add AUTHID CURRENT_USER so I don't get the error of insufficient privileges.

    Why it gives this error when the owner and the applicant of the procedure is schema1?

    Hello

    1st thing to know: when a procedure is defined (and updated), any privileges granted through ROLE is not taken into account. This is because these privileges can be active or not at the level of the session (as happens if for example a user has active 'role A' in session 1 but not in session 2 and if this role has been used to define a procedure?) The proecedure must at the same time be VALID in session 1 and INVALID session 2? Is not possible.

    Thus, for instance in a situation of 'standard': user SYSTEM has 'DBA Rôle', so you can for example make a sqlplus session "SELECT * v $ instance;", but you would write a procedure owned by system making instance_name SELECT INTO l_variable OF v$ instance;  "then"surprise": the procedure cannot be compiled because of the ORA-904 Table or view does not exist..." To be able to create the procedure, a DSS system needs to be done.

    2nd thing for your special case, a little more complex: default for a procedure is 'AUTHID DEFINE', but once more: it means "privileges of the author creating the procedure", so without taking into account the acquired privileges through roles... Your user name is 'sequence create' through a role, it cannot use the privilege within the procedure.  But... but when you define the procedure with AUTHID CURRENT_USER, privileges are evaluated at run time, and thanks to the active ROLE in the session by calling the procedure, at this time, the user can create the sequence.  If try again you but with 'The VALUE NONE ROLE' in the session before the call, you will again have the question.

    Conclusion: If you need to do the action, you must grant the user the necessary privilege directly.

    Best regards

    Bruno Vroman.

  • Can we call the procedure inside the function?

    Hello

    Can we call the procedure inside the function?

    Thank you
    Brij

    845712 wrote:

    Can we call the procedure inside the function?

    Strange question to ask.

    Yes. This is the standard behavior in most (if not all) procedural and object oriented languages.

    A procedure, function or a method is a unit of code.

    You can call one of the other units. Units can call themselves (recursion). Technically, this means simply by pushing the battery current (to save the stack of the current device memory), the call to the new unit and then popping up battery when control is returned to the unity of the appellant.

    There are very few exceptions to this. The only one that comes to mind programming languages I've used through the years, is natural 1 - could not call a new unit of code to replace the existing one in memory. If no call-and-return was possible.

    Exactly what did you ask this question? Some newcomers to confused Oracle SQL and PL/SQL - two different languages aside server. And then also mistaken for PL/SQL client command vocabulary of SQL * more.

    You will need to make sure that understand the basics of programming (applies to most current programming languages) and Oracle concepts.

Maybe you are looking for