Call procedure within procedure

Hai
I have some question
1)
This below procedure create user at run time
============================================
create or replace procedure new_u1( p_name in varchar2,
p_pw in varchar2,
p_def_tblspace in varchar2 default 'users' )
as
begin
execute immediate 'create user ' || P_name || ' identified by ' ||
p_pw || ' default tablespace ' || p_def_tblspace ||
' temporary tablespace temp';
execute immediate 'grant create session to ' || p_name;
end;
This below procedure create tables at run time
==============================================
create or replace procedure M2 (table_name varchar2) as
cursor1 integer;
begin
cursor1 := dbms_sql.open_cursor;
dbms_sql.parse(cursor1, 'DROP TABLE ' || table_name,
dbms_sql.v7);
dbms_sql.close_cursor(cursor1);
end;
I want ,when first procedure calls ,it calls second procedure and create tables in that schema (call procedure within procedure).How to do that?
2)What is diffrenece between row and statement level trigger?how many types of triggers?
3)what is mutating trigger or table?
4)dbms_stats.gather_table_stats package it collects the statistics about the tables .I want statistics to be collected at every day 9am and 7pm how to do that?
Thanks in advance
Mohan

You could use an expression like this, to generate the run times:
SQL> create table times (dt date) ;
Table created.
SQL> BEGIN
  2      FOR idx IN 1 .. 24
  3      LOOP
  4          INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24));
  5          INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24) + (1 / (24 * 60)));
  6          INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24) + (59 / (24 * 60)));
  7      END LOOP;
  8  END;
  9  /
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT to_char(dt,
  2                 'dd-mon-yyyy hh:mi:ss AM'),
  3         to_char(decode(sign(to_number(to_char(dt,
  4                                               'hh24MI')) - 900),
  5                        -1,
  6                        trunc(dt) + (9 / 24),
  7                        0,
  8                        trunc(dt) + (9 / 24),
  9                        decode(sign(to_number(to_char(dt,
10                                                      'hh24MI')) - 1900),
11                               -1,
12                               trunc(dt) + (19 / 24),
13                               0,
14                               trunc(dt) + (19 / 24),
15                               trunc(dt) + 1 + (9 / 24))),
16                 'dd-mon-yyyy hh:mi:ss AM')
17  FROM   times
18  ORDER  BY dt
19  /
TO_CHAR(DT,'DD-MON-YYYY TO_CHAR(DECODE(SIGN(TO_
01-jan-2004 01:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 01:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 01:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 09:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 09:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 09:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:00:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:00:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 12:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 12:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 12:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 07:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 07:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 07:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:59:00 PM 02-jan-2004 09:00:00 AM
02-jan-2004 12:00:00 AM 02-jan-2004 09:00:00 AM
02-jan-2004 12:01:00 AM 02-jan-2004 09:00:00 AM
02-jan-2004 12:59:00 AM 02-jan-2004 09:00:00 AM
72 rows selected.
SQL>

Similar Messages

  • Procedure within procedure problem

    Hi
    I have a table of 5 different magazines and a table of purchases of those magazines. I have written a procedure to take the details of a given magazine and place the sales for a given month into a sales table as follows:
    create or replace procedure monthly_sales(mag number, startdate date, enddate date) is
    magtotal number(7,0);
    magprice magazine.unitprice%type;
    magsales number(7,2);
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = mag and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, mag, magtotal, magsales);
    end;
    What I would like to do though is have a procedure that you just need to run once and it will enter the sales for a given month for all magazines into the sales table. My thought was to try to do this using procedures within a procedure as follows:
    create or replace procedure monthly_sales(startdate date, enddate date) is
    magtotal number(7,0);
    magprice magazine.unitprice%type;
    magsales number(7,2);
    procedure mag1 is
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = 1 and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, 1, magtotal, magsales);
    end mag1;
    procedure mag2 is
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = 2 and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, 2, magtotal, magsales);
    end mag2;
    procedure mag3 is
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = 3 and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, 3, magtotal, magsales);
    end mag3;
    procedure mag4 is
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = 4 and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, 4, magtotal, magsales);
    end mag4;
    begin
    select count(p.magid), m.unitprice into magtotal, magprice from purchase p, magazine m where p.datepurchased between startdate and enddate and p.magid = 5 and m.magid=p.magid
    group by m.unitprice;
    magsales := magtotal*magprice;
    insert into sales values(startdate, 5, magtotal, magsales);
    end;
    However, when I run this it is ignoring all the procedures within the main procedure and just entering the results for magazine 5. I'm at a loss as to why this isn't working, is this even the correct way to go about it? any help would be greatly appreciated
    thanks

    Why doing it the hard way?
    A single insert statement will do the trick.
    I made a bit of a guess as to the structure of your tables:
    create table magazine (magid number primary key, unitprice number);
    create table purchase (magid number references magazine(magid), datepurchased date);
    create table sales (startdate date, magid number references magazine(magid), magtotal number, magsales number);
    insert into magazine(magid, unitprice) values (1, 3.95);
    insert into magazine(magid, unitprice) values (2, 4.95);
    insert into magazine(magid, unitprice) values (3, 3.50);
    insert into magazine(magid, unitprice) values (4, 6.0);
    insert into magazine(magid, unitprice) values (5, 5.50);
    insert into purchase(magid, datepurchased) values (1, sysdate);
    insert into purchase(magid, datepurchased) values (1, sysdate);
    insert into purchase(magid, datepurchased) values (2, sysdate);
    insert into purchase(magid, datepurchased) values (2, sysdate);
    insert into purchase(magid, datepurchased) values (2, sysdate);
    insert into purchase(magid, datepurchased) values (4, sysdate);
    insert into purchase(magid, datepurchased) values (5, sysdate);
    insert into purchase(magid, datepurchased) values (5, sysdate);
    insert into purchase(magid, datepurchased) values (5, sysdate);
    insert into purchase(magid, datepurchased) values (5, sysdate);
    commit;
    create or replace procedure monthly_sales(p_startdate in date, p_enddate in date)
    is
    begin
      insert into sales (startdate, magid, magtotal, magsales)
        select p_startdate
        ,      p.magid
        ,      count(p.magid)
        ,      count(p.magid) * m.unitprice
        from   purchase p
          join magazine m on m.magid = p.magid
        where  p.datepurchased between p_startdate and p_enddate
        group by p.magid
        ,        m.unitprice;
    end;
    begin
      monthly_sales(trunc(sysdate,'MM'), last_day(trunc(sysdate,'MM')));
    end;
    select * from sales;
    STARTDATE      MAGID   MAGTOTAL   MAGSALES
    01-JAN-11          1          2        7.9
    01-JAN-11          2          3      14.85
    01-JAN-11          4          1          6
    01-JAN-11          5          4         22

  • Not able to call procedure within procedure in HANA Studio

    I am trying to call a procedure I made earlier in new procedure. I am getting error in same line no matter what I try. My original line was :
    CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetail"(:EmpID)
    on this I got error "invalid name of function or procedure: ABS_GETEMPLOYEEHISTORYDETAILS: "
    then I tried
    CALL "PAYROLLDBTEST/ABS_GetEmployeeHistoryDetail"(EmpID)
    on this I got error
    "sql syntax error: incorrect syntax near "(":"
    then I tried
    call "_SYS_BIC"."PAYROLLDBTEST/ABS_GetEmployeeHistoryDetail"(:EmpID)
    now I am getting
    sql syntax error: incorrect syntax near "."
    So please let me know whats wrong.
    Thanks

    To call a procedure in the SQL console the parameters have to be replaced by question marks (?).
    CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetail"(?)
    Will work and ask you to enter the parameter value when you execute it in SAP HANA Studio.
    - Lars

  • Calling a stored procedure from within a ViewObject

    Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
    select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
    If not, is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
    In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
    We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.

    Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
    select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
    Yes. Using our expert-mode query feature this is possible.
    is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
    Yes. See this article about basing a view object on a REF CURSOR:
    http://radio.weblogs.com/0118231/2003/03/03.html
    In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
    No. Not directly. What's the business requirement here so I can understand better?
    We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.
    REF CURSOR would work fine, or if it's just the statement that needs to be generated dynamically, you could fetch the text of the SQL statement from the stored procedure, then use createViewObjectFromQueryStmt(). Although this has runtime overhead involved with describing the query.
    The REF CURSOR based approach is probably best for this.

  • Calling a stored procedure within a package

    We have a number of packages containing stored procedures. In an existing production application, we used embedded SQL in C programs to call these stored procs
    e.g.
    EXEC SQL EXECUTE
    BEGIN owner.fees_calc.some_fee(:parm1,...);
    END;
    END-EXEC;
    Now, I am trying to use SQLJ to call this same stored proc in the package. However, I am getting a compilation error from sqlj saying that it cannot find a stored procedure or function of that name. It works fine if I use a stored proc that is not in a package.
    So how do I call a stored procedure within a package? Or is this not currently possible with sqlj?
    I am also getting a warning just before the error and I'm wondering if the error is being caused by this:
    Warning: You are using an Oracle JDBC driver, but connecting to a non-Oracle database. SQLJ will perform JDBC-generic SQL checking.
    I am connecting to an Oracle 7.3.3 database using an Oracle 7.3.4 JDBC driver. I also tried using the Oracle 8.0.5 JDBC driver for the same database but I get the same warning message.

    I used the following code to call a stored
    procedure via SQLJ:
    try {
    #sql [iCtx] {
    CALL ibs.cvs_validate.validate_port_id(:IN record_id ,:IN poe_pod_flag,:IN port_id,:OUT error_code,:OUT error_message) };
    where
    "ibs" is the schema
    "cvs_validate" is the package
    "validate_port_id" is the procedure
    The code runs fine, but to get it to compile
    in JDeveloper 2.0, I had to disable the "Check SQL semantics against database schema" option on the Project Properties (SQLJ) property sheet.
    null

  • Function call in procedure within Package Body

    I am a novice in PL/SQL so that I can't find out where the problem is. I am testing a function call in procedure within a Package Body.
    But the PL/SQL Complier doesn't compile the package body but I don't know what I do wrong. Plz let me know how to call a function in procedure within a Package Body?
    Here are the Packaget test programs..
    CREATE OR REPLACE PACKAGE manage_students
    IS
    PROCEDURE find_sname;
    PROCEDURE find_test;
    PROCEDURE find_test_called;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE;
    END manage_students;
    CREATE OR REPLACE PACKAGE BODY manage_students AS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    PROCEDURE find_sname
    IS
    BEGIN
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER is : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_sname;
    PROCEDURE find_test
    IS
    BEGIN
    BEGIN
    DBMS_OUTPUT.PUT_LINE('MAX NUMBER Called from another procedure : '||v_max_nbr);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test;
    FUNCTION GET_LASTMT
    RETURN SEQUENCE_TEST.SEQ_NO%TYPE
    IS
    v_max_nbr SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    SELECT MAX(SEQ_NO)
    INTO v_max_nbr
    from SEQUENCE_TEST;
    RETURN v_max_nbr;
    EXCEPTION
    WHEN OTHERS
    THEN
    DECLARE
    v_sqlerrm VARCHAR2(250) :=
    SUBSTR(SQLERRM,1,250);
    BEGIN
    RAISE_APPLICATION_ERROR(-20003,
    'Error in instructor_id: '||v_sqlerrm);
    END;
    END GET_LASTMT;
    PROCEDURE find_test_called
    IS
    BEGIN
    BEGIN
    V_max := Manage_students.GET_LASTMT;
    DBMS_OUTPUT.PUT_LINE('MAX_NUMBER :'|| V_max);
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    RETURN NULL;
    END;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN DBMS_OUTPUT.PUT_LINE('Error in finding student_id: ');
    END find_test_called;
    END manage_students;
    DECLARE
    v_max SEQUENCE_TEST.SEQ_NO%TYPE;
    BEGIN
    manage_students.find_sname;
    DBMS_OUTPUT.PUT_LINE ('Student ID: Execute.');
    manage_students.find_test;
    manage_students.find_test_called;
    END;
    -----------------------------------------------------------------------------------------------

    Hi,
    Welcome to the forum!
    You'll find that there are a lot of people willing to help you.
    Are you willing to help them? Whenever you have a problem, post enough for people to re-create the problem themselves. That includes CREATE TABLE and INSERT statements for all the tables you use.
    Error messages are very helpful. Post the complete error message you're getting, including line number. (It looks like your EXCEPTION sections aren't doing much, except hiding the real errors. That's a bad programming practice, but probably not causing your present problem - just a future one.)
    Never post unformatted code. Indent the code to show the extent of each procedure, and the blocks within each one.
    When posting formatted text on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted test, to preserve the spacing.
    For example, the procedure find_test_called would be a lot easier to read like this:PROCEDURE find_test_called
    IS
    BEGIN
         BEGIN
              V_max := Manage_students.GET_LASTMT;
              DBMS_OUTPUT.PUT_LINE ('MAX_NUMBER :' || V_max);
         EXCEPTION
              WHEN OTHERS
              THEN
                   DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
                   RETURN      NULL;
         END;
         COMMIT;
    EXCEPTION
         WHEN OTHERS
         THEN
              DBMS_OUTPUT.PUT_LINE ('Error in finding student_id: ');
    END find_test_called;
    It's much easier to tell from the code above that you're trying to return NULL from a procedure.  Only functions can return anything (counting NULL); procedures can have RETURN statements, but that single word"RETURN;" is the entire statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Call a procedure within a Procedure

    hi
    How can i call a procedure within a procedure
    Thanks in advance

    SQL> create procedure b as
      2  begin
      3  null;
      4  end;
      5  /
    Procedure created.
    SQL> create procedure a as
      2  begin
      3  b;
      4  end;
      5  /
    Procedure created.
    SQL>

  • UTL_FILE in a trigger or calling a stored procedure within a trigger

    Hello,
    We are using Oracle 8i version where I need to either call a SP within a trigger or use UTL_FILE within a trigger.
    1. SP runs fine by itself to write to a file but when I try calling SP within a trigger-> I get INVALID Path - is there some kind of restriction with DB triggers and UTL_FILE options
    create or replace trigger testtrig
    after insert on test_table
    for each row when (new.stat_code = '99')
    BEGIN
    utl_file_test_write;
    EXCEPTION
    WHEN others THEN
    raise_application_error(-20000, sqlerrm);
    END;
    2. use UTL_FILE with a trigger
    create or replace trigger testtrig
    after insert on test_table
    for each row when (new.stat_code <> '99')
    DECLARE
    v_line varchar2(32767);
    v_location varchar2(80) :='/u01/oraadmin/udump';
    v_filename varchar2(80) := 'KC11.txt';
    v_handle utl_file.file_type;
    BEGIN
    dbms_output.put_line('Location is'||v_location);
    dbms_output.put_line('Location is'||v_filename);
    v_filename := :new.emp_id;
    v_handle := utl_file.fopen(v_location, v_filename,'W',32767);
    v_line := :new.emp_id;
    utl_file.put_line(v_handle,v_line);
    utl_file.fclose(v_handle);
    EXCEPTION
    WHEN TOO_MANY_ROWS THEN
    dbms_output.PUT_LINE('Too Many Rows');
    WHEN NO_DATA_FOUND THEN
    dbms_output.PUT_LINE('No Data Found');
    --WHEN utl_file.invalid_path THEN
    -- RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_path');
    WHEN utl_file.invalid_mode THEN
    RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_mode');
    WHEN utl_file.invalid_filehandle THEN
    RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_filehandle');
    WHEN utl_file.invalid_operation THEN
    RAISE_APPLICATION_ERROR(-20000, 'utl_file.invalid_operation');
    WHEN utl_file.read_error THEN
    RAISE_APPLICATION_ERROR(-20001, 'utl_file.read_error');
    WHEN utl_file.write_error THEN
    RAISE_APPLICATION_ERROR(-20001, 'utl_file.write_error');
    WHEN utl_file.internal_error THEN
    RAISE_APPLICATION_ERROR(-20001, 'utl_file.internal_error');
    End;
    I still get INVALID_PATH. What am I missing?
    Any help is greatly appreciated.
    Thanks.

    Hi,
    from docs on UTL_FIL.FOPEN:
    location:
    Directory location of file. This string is a directory object name and is case sensitive. The default is uppercase. Read privileges must be granted on this directory object for the UTL_FILE user to run FOPEN.This, '/u01/oraadmin/udump' does not look like the name of a DIRECTORY object.
    Besides, the whole idea of having UTL_FILE commands directly in a trigger body sucks. At the least stay with a stored procedure.
    And have you considered what should happen with that file in case the transaction is rolled back?
    Regards
    Peter

  • Calling a oracle procedure within a procedure - Urgent

    Hi
    Can some one tell me, how to call a oracle procedure within a procedure ?
    Thanks
    Murali

    You could always try looking in the manuals.

  • Calling package procedure within another procedure ???

    Hello ,
    I have package called import_pack, within this i have procedure called import_proc. I have another separate procedure called main_proc.
    Now i want to call import_proc in main_proc. how do i do this ???
    Any example would be great. Thank you so much.

    Hi,
    If the import_pack package is in the user_x schema, then the following will always work:
    user_x.import_pack.import_proc (...);If main.proc is also in the user_x schema, then the owner name is optional, so this would be acceptable, too:
    import_pack.import_proc (...);If main_proc is in the same package, then the package name is optional, so this would also work:
    import_proc (...);

  • I am getting ORA-01403: no data found error while calling a stored procedur

    Hi, I have a stored procedure. When I execute it from Toad it is successfull.
    But when I call that from my java function it gives me ORA-01403: no data found error -
    My code is like this -
    SELECT COUNT(*) INTO L_N_CNT FROM TLSI_SI_MAST WHERE UPPER(CUST_CD) =UPPER(R_V_CUST_CD) AND
    UPPER(ACCT_CD)=UPPER(R_V_ACCT_CD) AND UPPER(CNSGE_CD)=UPPER(R_V_CNSGE_CD) AND
    UPPER(FINALDEST_CD)=UPPER(R_V_FINALDEST_CD) AND     UPPER(TPT_TYPE)=UPPER(R_V_TPT_TYPE);
         IF L_N_CNT >0 THEN
              DBMS_OUTPUT.PUT_LINE('ERROR -DUPlicate SI-1');
              SP_SEL_ERR_MSG(5,R_V_ERROR_MSG);
              RETURN;
         ELSE
              DBMS_OUTPUT.PUT_LINE('BEFORE-INSERT');
              INSERT INTO TLSI_SI_MAST
                   (     CUST_CD, ACCT_CD, CNSGE_CD, FINALDEST_CD, TPT_TYPE,
                        ACCT_NM, CUST_NM,CNSGE_NM, CNSGE_ADDR1, CNSGE_ADDR2,CNSGE_ADDR3,
                        CNSGE_ADDR4, CNSGE_ATTN, EFFECTIVE_DT, MAINT_DT,
                        POD_CD, DELVY_PL_CD, TRANSSHIP,PARTSHIPMT, FREIGHT,
                        PREPAID_BY, COLLECT_BY, BL_REMARK1, BL_REMARK2,
                        MCC_IND, NOMINATION, NOTIFY_P1_NM,NOTIFY_P1_ATTN , NOTIFY_P1_ADDR1,
                        NOTIFY_P1_ADDR2, NOTIFY_P1_ADDR3, NOTIFY_P1_ADDR4,NOTIFY_P2_NM,NOTIFY_P2_ATTN ,
                        NOTIFY_P2_ADDR1,NOTIFY_P2_ADDR2, NOTIFY_P2_ADDR3, NOTIFY_P2_ADDR4,
                        NOTIFY_P3_NM,NOTIFY_P3_ATTN , NOTIFY_P3_ADDR1,NOTIFY_P3_ADDR2, NOTIFY_P3_ADDR3,
                        NOTIFY_P3_ADDR4,CREATION_DT, ACCT_ATTN, SCC_IND, CREAT_BY, MAINT_BY
                        VALUES(     R_V_CUST_CD,R_V_ACCT_CD,R_V_CNSGE_CD,R_V_FINALDEST_CD,R_V_TPT_TYPE,
                        R_V_ACCT_NM,R_V_CUST_NM ,R_V_CNSGE_NM, R_V_CNSGE_ADDR1,R_V_CNSGE_ADDR2, R_V_CNSGE_ADDR3,
                        R_V_CNSGE_ADDR4,R_V_CNSGE_ATTN,     R_V_EFFECTIVE_DT ,SYSDATE, R_V_POD_CD,R_V_DELVY_PL_CD,R_V_TRANSSHIP ,R_V_PARTSHIPMT , R_V_FREIGHT,
                        R_V_PREPAID_BY ,R_V_COLLECT_BY ,R_V_BL_REMARK1 ,R_V_BL_REMARK2,R_V_MCC_IND,
                        R_V_NOMINATION,R_V_NOTIFY_P1_NM, R_V_NOTIFY_P1_ATTN, R_V_NOTIFY_P1_ADD1, R_V_NOTIFY_P1_ADD2,
                        R_V_NOTIFY_P1_ADD3, R_V_NOTIFY_P1_ADD4, R_V_NOTIFY_P2_NM, R_V_NOTIFY_P2_ATTN, R_V_NOTIFY_P2_ADD1,
                        R_V_NOTIFY_P2_ADD2, R_V_NOTIFY_P2_ADD3, R_V_NOTIFY_P2_ADD4, R_V_NOTIFY_P3_NM, R_V_NOTIFY_P3_ATTN,
                        R_V_NOTIFY_P3_ADD1, R_V_NOTIFY_P3_ADD2, R_V_NOTIFY_P3_ADD3, R_V_NOTIFY_P3_ADD4,
                        SYSDATE,R_V_ACCT_ATTN,R_V_SCC_IND,R_V_USER_ID,R_V_USER_ID
                        DBMS_OUTPUT.PUT_LINE(' SI - REC -INSERTED');
         END IF;

    Hi,
    I think there is a part of the stored procedure you did not displayed in your post. I think your issue is probably due to a parsed value from java. For example when calling a procedure from java and the data type from java is different than expected by the procedure the ORA-01403 could be encountered. Can you please show the exact construction of the call of the procedure from within java and also how the procedure possible is provided with an input parameter.
    Regards, Gerwin

  • How to call a stored procedure from WorkShop

    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

    Atahualpa--
    Maybe this will help:
    http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
    Eddie
    Atahualpa wrote:
    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

  • Ssrs 2008 r2 report dataset call a stored procedure

    I am modifying an existing SSRS 2008 r2 report. In a dataset that already exists within the ssrs 2008 r2 report I need execute
    a stored procedure called StudentData and pass 3 parameter values to the stored procedure. The stored procedure will then return 5 values that are now needed for the modified ssrs report. My problem is I do not know how to have the dataset call the stored procedure
    with the 3 parameter values and pass back the 5 different unique data values that I am looking for.
    The basic dataset is the following:
    SELECT  SchoolNumber,
            SchoolName,
            StudentNumber,      
     from [Trans].[dbo].[Student]
     order by SchoolNumber,
              SchoolName,
              StudentNumber
    I basically want to pass the 3 parameters of SchoolNumber, SchoolName, and StudentNumber to the
    stored procedure called StudentData from the data I obtain from the [Trans].[dbo].[Student]. The 3 parameter values will be obtained from the sql listed above.
    The  columns that I need from the stored procedure called  StudentData will return the following data columns
    that I need for the report: StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName.
    Thus can you show me how to setup the sql to meet this requirement I have?

    Hi wendy,
    After testing the issue in my local environment, we can refer to the following steps to achieve your requirement:
    Create three multiple parameters named SchoolNumber, SchoolName and StudentNumber in the report. Those available values from the basic dataset SchoolNumber, SchoolName and StudentNumber fields.
    If you want to pass multiple values parameter to stored procedure, we should create a function as below to the database:
    CREATE FUNCTION SplitParameterValues (@InputString NVARCHAR(max), @SplitChar VARCHAR(5))
    RETURNS @ValuesList TABLE
    param NVARCHAR(255)
    AS
    BEGIN
    DECLARE @ListValue NVARCHAR(max)
    SET @InputString = @InputString + @SplitChar
    WHILE @InputString!= @SplitChar
    BEGIN
    SELECT @ListValue = SUBSTRING(@InputString , 1, (CHARINDEX(@SplitChar, @InputString)-1))
    IF (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar))>(LEN(@InputString))
    BEGIN
    SET @InputString=@SplitChar
    END
    ELSE
    BEGIN
    SELECT @InputString = SUBSTRING(@InputString, (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar)) , LEN(@InputString)-(CHARINDEX(@SplitChar, @InputString)+ len(@SplitChar)-1) )
    END
    INSERT INTO @ValuesList VALUES( @ListValue)
    END
    RETURN
    END
    Use the query below to create a stored procedure, then use it to create a dataset to return 5 values:
    create proc proc_test(@SchoolNumber nvarchar(50),@SchoolName nvarchar(50),@StudentNumber nvarchar(50))
    as
    begin
    select StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName
    from table7 where SchoolNumber in (SELECT * FROM SplitParameterValues (@SchoolNumber,','))  and SchoolName in(SELECT * FROM SplitParameterValues (@SchoolName,','))  and StudentNumber in (SELECT * FROM SplitParameterValues (@StudentNumber,','))
    end
    Right-click the new dataset to modify the parameter value in the Parameters pane as below:
    =join(Parameters!SchoolNumber.Value,",")
    =join(Parameters!SchoolName.Value,",")
    =join(Parameters!StudentNumber.Value,",")
    For more details about pass multi-value to stored procedure, please see:
    http://munishbansal.wordpress.com/2008/12/29/passing-multi-value-parameter-in-stored-procedure-ssrs-report/
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • ORA-06502 when calling from a procedure

    HI,
    I have a procedure(p1) inside a package that queries a table and send out the result based on the input paramater value. OUT variable is of same type as the table column(using %type), column size is varchar2(4000). This procedure is called from another procedure(p2) and sends out the result to Java Page to display the results at front-end.
    Problem is when application runs and p1 is called I get the following error message,
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Length/size of the character string queried from table is _1747_ that is within the limit of 4000 chars. If I limit the output to just 500 using substr, I don't get any error but adding a single character startes throwing error. OUT variable in both p1 and p2 are declared as table.column%type and error comes from p1 only as confirmed by the error log.
    When I call p1 or p2 from a declare block, I don't get any error.
    This has really confused me and I am not able to find any reason for this difference in behaviour.
    Request to help me in understanding what could be the issue here.
    Oracle version used is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
    -Thanks in Advance.

    CREATE or replace PROCEDURE p1
    ( l_id IN VARCHAR2
    , l_str OUT VARCHAR2
    ) IS
      l_temp VARCHAR2(4000);
    BEGIN
      SELECT Response_Message INTO l_temp FROM t1 WHERE Response_ID = l_id;
      l_str := l_temp||'10 symbols';
    END;
    CREATE or replace PROCEDURE p2
    ( l_id IN VARCHAR2
    , l_str OUT VARCHAR2
    ) IS
    BEGIN
      p1(l_id, l_str);
    END;
    /no errors in procedures, but
    DECLARE
    resultstr VARCHAR2(1000);
    BEGIN
      p2(58, resultstr);
      DBMS_OUTPUT.PUT_LINE(resultstr);
    END;
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "P1", line 8
    ORA-06512: at "P2", line 6
    ORA-06512: at line 4Procedure is called with small variable.
    Try check all calls and all procedures for size and check if there are string concatenations.

  • How to call multiple stored procedure from same DB Adapter

    Hi,
    I want to invoke 3 stored procedures from my message flow in BUS . I created a DB adapter and invoked 1 successfully . Now I don't to configure 2 other DB adapters for calling other 2 stored procedures . I want some how to be able to call the other 2 from the first DB adapter only . Somehow I need the flexibility to have procedure names as the operation names in 1 wsdl and be able to configure this in JDeveloper for this at time of DB adapter configuration . I am using 11G . Is it possible ?

    You can probably create a DB adapter with operation type selected as Execute Pure SQL and write SQL code to invoke the stored procedures depending on the procedure name (which you can get as one of the parameters of DB Adapter).
    However, Even if you were able to do it, the DB Adapter schemas are generated based on stored procedure parameter list and types. If you use Execute Pure SQL type of DB Adapter the schema will be generated based on the parameters which you are using in your custom SQL code within DB Adapter. Which means that if you want to add a new stored procedure as target which has a different name and different parameters then you will need to regenerate the DB adapter and update your custom SQL code. This also means that you will need to do regression testing interfaces to all stored procedures whenever there is any change in this DBAdapter.
    Now, my question is why do you want to invoke multiple stored procedures from same DB adapter?
    This is not a good way to design integration solutions and makes your services resistance to change as it will take more time to change and test.
    If all that you want is to have a web service which can have different operations for different stored procedures then you should create three business services and create a wrapper proxy service which has one operation for each stored procedure, within the proxy transform and call the correct backend service (you can use operational branch). This way you have a modular code where each module (read interface to one stored procedure) can be independently modified and tested.

Maybe you are looking for

  • How do I pause a slide without the playbar?

    Hi I am using Cap 6 and I do not have a playbar on my published project, I have a back and next button, how can allow the user to stop or pause the slide do I need some java script on a button?

  • Printing field values to a PDF using a template

    Hi I have a set of field values stored in variables, I need to print these fields into a PDF file. There is a template for this PDF , and each field value should go to a specific location wrt the template on the new PDF. Could you any one recommend a

  • Burn error 4251

    Sorry I know this has been addressed in post ealier but i have recently down loaded Itunes music from the store and get error 4251 after around the third song burn't. I am able to burn all music i have imported from CD but the purchesed album just wi

  • How to put text in a film?

    I have a film and want to put after 2 minutes text into it. Where can I set in the time when the text had to start? Thank you for an answer!! (Keynote 5.3 / OSX 10.8.5)

  • E Recruitment authorizations

    Hi All, We are implementing E-Recruitment 6.0 EHP3. As per my understanding, any candidate can be hired against a job only after he/she is registered into talent pool. Once the candidate is registered to the talent pool, his/her application will be a