Ask about UTL_FILE stored procedure

Hello

I tried to do an insert into a table which then triggers a stored procedure to write the data inserted into a text file. However, I have a few questions here in the stored procedure. Thanks for trying to help... [Insert-> table-> Trigger-> stored procedure-> text file]

-The user will execute this sql

-insert into tester.test_table values ("ab");

CREATE TABLE TESTER. TEST_TABLE

(

LINECODE VARCHAR2 (2 BYTE)

)

-Just for test purpose

CREATE TABLE TESTER. TEST_REC_TABLE

(

LINECODE VARCHAR2 (2 BYTE)

)

CREATE OR REPLACE TRIGGER TESTER. TRIGGER_AUDIT

AFTER INSERT OR UPDATE

TESTER MARKET. TEST_TABLE REFERENCING OLD AS OLD AGAIN AS NEW

FOR EACH LINE

DECLARE

sLineCode VARCHAR2 (2);

BEGIN

sLineCode: = ";

IF THE UPDATE CAN

sLineCode: =: NEW. LINECODE;

TRIGGER_PACKAGE. WRITE_FILE (sLineCode);

END IF;

IF THE INSERTION

sLineCode: =: NEW. LineCode;

TRIGGER_PACKAGE. WRITE_FILE (sLineCode);

END IF;

EXCEPTION

WHEN other then null;

END TRIGGER_AUDIT;

/

CREATE OR REPLACE PACKAGE BODY TESTER. TRIGGER_PACKAGE

is

procedure WRITE_FILE (in_LineCode in varchar2)

is

sLineCode varchar2 (2);

v_FileHandle UTL_FILE. TYPE_DE_FICHIER;

-a few checks for null input data

Start

If ((rtrim (in_LineCode) IS NULL) or (in_LineCode is nothing)) then

sLineCode: = "XX";

on the other

sLineCode: = in_LineCode;          -> PROBLEM HERE?

end if;

If (length (sLineCode) > 2) can

sLineCode: = substr (sLineCode, 1, 2);

end if;

Insert into TEST_REC_TABLE (LineCode) values (sLineCode); -Insert data to another table for the test

RUN IMMEDIATELY 'CREATE OR REPLACE DIRECTORY FILEDIR AS | '''' || 'c:\' || '''';

v_FileHandle: = UTL_FILE. FOPEN ('FILEDIR', 'Test_Table.txt', 'w'); -write in the text file in C:\Test_Table.txt

UTL_FILE. Put_line (v_FileHandle, 'insert' | sLineCode |) ' @ ' || TO_CHAR(SYSDATE,'DD-MM-YYYY HH:MI:SS AM'));

UTL_FILE. FCLOSE (v_FileHandle);

exception

When other then null;

end;

end TRIGGER_PACKAGE;

/

(1) the problem I encountered is that when I run sql INSERT for new data, it can be successfully be inserted in both tables TEST_REC_TABLE and table_test, but just do not write in the text file.

(2) However, when I simply run the procedure I'll get XX for data entry because it is NULL. These data XX then will be seen in TEST_REC_TABLE in the folder "XX" and Test_Table.txt as "Inserted XX @ 01/10/2014-16:56:06. UTL_FILE wrote to textfile so my guess is that it could be due to my misunderstanding of the logic in the audit input null data. Tried, but I'm still distraught, thanks for reporting the issue.

> 1) I'm just tests and I'm learning here with insert trigger...

Good. In this case, it's just a bad choice that you have decided to write to a file of a trigger. Basic Oracle is a good site. They also have examples. Please check that the BASE ORACLE - overview of database triggers.

(> 2) how do I do next?

Simply create the object once

CREATE OR REPLACE DIRECTORY FILEDIR AS

The path must be a location on your server where oracle is installed.

(> 3) how do I do next? Use this?

EXCEPTION

WHILE OTHERS THEN

DBMS_OUTPUT. PUT_LINE

("ERROR" |) TO_CHAR (SQLCODE) | SQLERRM);

NULL;

Do not do something. Just remove the exception handling. Do not handle unknown exceptions. If all you want to manage the purpose of logging RECOVERY to end like that.

exception

while others then

lift;

And on one of the exceptions management forum, member BluShadow has written a nice article 101 PL/SQL: exception management. It would be an enjoyable read.

Tags: Database

Similar Questions

  • Question about handling apostrophe in the stored procedure parameter

    I was wondering how people have dealt with this problem.  In my process I use the operation to execute stored procedure (sp) to write data to a database, and it is by the way the field values to the sp as parameters.  Works fine when everything is normal but as soon as an apostrophe is added in one of the fields, ka-boom.  It breaks .  So I have been messing around with the means to fight against this problem and did not really come wih an appropriate option.  I know that I can go on the form and write a few RegEx and change the single apostrophe double that would work, but I have to write in several events since the form is sent to someone else and I can't have them seeing "clerk"s"instead of"clerk".  Right now I'm writing an xpath statement that would replace the single apostrophe with a double bed with no luck.  I was wondering if anyone else has had this problem and found an easy solution.  Thank you

    Mike

    Why not use the parameterized query option.

    In this way, your settings are replaced by some? and you don't get messed up with the '

    Your select statement would look like: select * from table where column1 =? and column2 =?

    Then you can map the? s in the process variables.

    Jasmine

  • Trapping errors in stored procedures

    I run queries on a Government computer. There are errors in some of the stored procedures that will NEVER disappear. Reality of life and I have to live with it (I'm just a data analyst - not the developer of procedures)
    If I do this, hoping to catch the error
    BEGIN
         run_stored_proc (my_cursor, my_id, param3);
    EXCEPTION
         WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE ('ERROR IN ID (' || my_id || '). The error was ' || SQLCODE || ' -ERROR- ' ||SQLERRM);
    END;
    Well, he can still plant.
    SQL> @c:\mysql\run_test
    ERROR IN ID (2692). The error was -20100 -ERROR- ORA-20100: Exception occurred in some_other_stored_procedure
    ORA-01422: exact fetch returns more than requested number of rows
    So, it seems that run_stored_proc calls some_other_stored_procedure, which has problems. I was hoping to trying to capture the error in the procedure at a higher level, it would also seize the error at a lower level 'Sub procedure. It is how works a TRY-CATCH in java. If an error occurs anywhere along the path inside the TRY-CATCH, she is caught. Of course, java ins't of PL/SQL, but is it possible for me to catch a lower level error and do not have this code crash?

    Fortunately for me, it actually does not crash as often. But I have to put this code in a loop, then run it to many different my_id. And when he plant, it is not important from a data analysis perspective. I can't do without a small percentage of the data. But I'd love to be able to just run my script and do not have to look for unexpected accidents.

    This isn't a question about how to solve the error too many lines in the procedure. I don't have access to the procedure, and it's not going to be fixed. I just need to know how to deal with the capture of the error, if it is at all possible.

    I'm not sure I Armi what you're asking here. Your script is not 'crash', it is just to report the error through the dbms_output.put_line statement you added. When you say "I have to put this code in a loop, then run it to many different my_id", do you mean you want to call run_stored_proc multiple times with different values of my_id?

    If so, then it should look like:

    begin
       for rec in (select my_id from wherever) loop
          BEGIN
               run_stored_proc (my_cursor, my_id, param3);
          EXCEPTION
               WHEN OTHERS THEN
                DBMS_OUTPUT.PUT_LINE ('ERROR IN ID (' || my_id || '). The error was ' || SQLCODE || ' -ERROR- ' ||SQLERRM);
          END;
       end loop;
    end;
    

    The other Manager to swallow the error and control will return at the top of the loop statement and execute the procedure with the next value of my_id.

    John

  • the command - stored procedure support

    Hi all

    I'm having a lot of trouble getting my head around an update command / stored procedure, I took out all my books and has spent the last two days on Google which has aggravated my confusion. In simple terms what I try to do is to update a field in a table with the ordered there, but according to certain criteria. So my table contains the fields - following

    JBAID
    JBASiteID
    JBADatePosted
    JBAPostFor
    JBANotified

    What I want to do is to update the value of the JBANotified field for all records that meet the following requirements for Y

    The criterion is-

    WHERE the DATEADD(d,JBAPostFor,JBADatePosted) BETWEEN DATEADD (d,-7, GETDATE() AND GETDATE() AND JBANotified = ' AND JBASiteID = MMColParam n (where MMColParam is Session("SITEID")))

    So I just tried to build a command procedure / stored - which reads (see attached code) (more than probably all bad)

    I can't get my head around things-

    First rethink code in the first place, execution of the command on the loading of the page and then when the command run the redirection to the next page.

    I would really appreciate help with this-

    Thank you all

    Do you use the CS3 with ASP/VBScript? There is a bug in the implementation of the order which has this broken feature.

    I asked about it in this forum several months ago, but now I can't find my original post, but I found another post that talks about the same thing: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=263&threadid = 1281539 & enterthread = y

    My solution is to fall back to DW8 for the edition of the command, but use CS3 for the rest. I don't know what you're supposed to do if you do not have a previous version.

    It seems that your sql is correct, but the bug prevents the second block of code updated with the correct values.

    I hope that a solution is coming...

  • Calling stored procedures with parameters with the database connectivity Toolkit

    Hi all

    I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work.  I have a database in which I tables and stored procedures with parameters.  Some of these stored procedures have input, output and return parameters.

    I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument

    Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table).  In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred.  The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).)  I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful.  I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step.  I then try to use the VI of parameter query create to call the stored procedure and set the parameters.  I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI?  I am also having some confusion during and after these steps as well.  I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert.  Also, I would be happy to provide more information that might be useful.

    Kind regards

    Jon

    Here's what I use to do this.  I think I had to change him create parameterized query VI for him to work.  There is a post on the forum about this somewhere.

  • Problem with stored procedure and validation

    I have the following stored procedure:

    create or replace PROCEDURE SOME_PROC)

    /*

    Some settings

    */

    ) AS

    NUMBER of errors

    BEGIN

    errors: = FN_CHECK_BUSINESS_RULE_1 (/ * some args * /);

    if(Errors > 0) then

    raise_application_error (ERR_CONSTANTS. SOME_ERROR_NUMBER, ERR_CONSTANTS. SOME_ERROR_MESSAGE);

    end if;

    INSERT INTO une_table (/ * columns * /) VALUES (/ * values * /);

    END SOME_PROC;

    Because the business rule 1 is placed inside the stored procedure I can't check it out without calling the stored procedure.

    I need to call the stored procedure 10 times with a different set of parameters and validation of the changes only after all calls to the stored procedure

    are successful. I want to show the user all the errors that occurred during the stored procedure calls. If for a first example of stored procedure call

    succeeds and a second failure no data has to be stored in a database.

    How to prevent the stored procedure for insert lines until I call the method commit of ApplicationModule?

    Thanks in advance.

    No, other users only see the lines until you commit. The search term is the transaction isolation level. Tom Kite write a paper on this here ask Tom: on transaction isolation levels. This article gives some samples, according to theory, and you should read it.

    Timo

  • Why these stored procedures his does not work

    Hi I'm new and I need help following SQL works correctly, but when I walked into a stored procedure me displays error

    SELECT Por.PortalID,

    Name,

    Lower (LTrim (RTrim (SEOName))) SEOName,

    IsParent,

    Por.Parentid,

    (Select Seoname

    Portal port

    Where Por.Parentid = Port.Portalid) Parentportalname;

    SettingValue.SettingValue DefaultPage

    Por PORTAL

    JOIN SettingValue

    ON Por.PortalID = SettingValue.settingtypeid

    Where Settingtype = 'SiteAdmin '.

    And Settingkey = 'PortalDefaultPage. '

    his return:

    Portald Name SEONAME ISPARENT ParentId parentportalname DefaultPage
    1by defaultby default10nullHomepage

    It's my stored procedure

    create or replace

    Procedure Sp_Portalgetlist as

    Start

    SELECT Por.PortalID,

    Name,

    Lower (LTrim (RTrim (SEOName))) SEOName,

    IsParent,

    Por.Parentid,

    (Select Seoname

    Portal port

    Where Por.Parentid = Port.Portalid) Parentportalname;

    SettingValue.SettingValue DefaultPage

    Por PORTAL

    JOIN SettingValue

    ON Por.PortalID = SettingValue.settingtypeid

    Where Settingtype = 'SiteAdmin '.

    And Settingkey = 'PortalDefaultPage ';

    END SP_PORTALGETLIST;

    When I compile with oracle sqldeveloper show this error:

    • Error (4.1): PLS-00428: an INTO clause in this SELECT statement

    I appreciate all the help

    What about the compile error in a PL/SQL block a select statement has an additional part:

    Select attr1, attr2...

    in var1, var2,...

    Of...

    but you can also use your selection (without the) in a cursor:

    procedure is...

    cursor my_select is

    Select...;

    my_variable my_cursor % rowtype;

    Start

    Open my_cursor;

    extract my_cursor in my_variable; -fails at the record and then one more found!

    close my_cursor;

    ...

    Good bye

    DPT

  • Transaction in stored procedure not treated as Atomic?

    Hello

    I have a stored procedure that inserts a line in a table called reservations and also decrement the places available for an event.

    For example: at an event, there are 100 places available. After you add a reservation, it will be left only 99 seats.

    I also have a Java program that sends 100 concurrent transactions to the database.

    After 100 transactions, there are 100 reservations, but there are still about 60 free places.

    So, I guess that the transaction he has not treated as atomic. I don't know why some transactions fail?

    The code of the stored procedure:

    create or replace PROCEDURE procedureOne (s_price, NUMBER, NUMBER, of s_customer)

    s_event NUMBER, DATE, s_movie NUMBER of s_dat)

    IS

    s_ev NUMBER;

    s_free NUMBER: = 0;

    BEGIN

    commit;

    Set transaction read write;

    Start

    SET TRANSACTION ISOLATION LEVEL READ COMMITTED;

    Select Event_ID, Free_seats EN s_ev, s_free

    events

    where ID_Movie = s_movie;

    If s_free > 0 then

    Start

    update events set Free_seats = s_free-1;

    insert into values of reservations (seqa_seq. NEXTVAL, s_dat, s_customer, s_event, s_price);

    commit;

    end;

    on the other

    Start

    Rollback;

    end;

    end if;

    end;

    commit;

    end procedureOne;

    invatacelul wrote:

    So, I guess that the transaction he has not treated as atomic. I don't know why some transactions fail?

    You said: "I also have a Java program that sends 100 concurrent transactions to the database. Atomicity applies to a single transaction - it says transaction executes all or nothing. Is what you run in isolation. If you want isolation unless you serialize, transaction 2 sees no uncommitted transaction 1 results because the READ COMMITTED isolation level indicates that a transaction can read only the data that has been committed to the database. And since you wrote your code as SELECT + UPDATE you get results you never expected. Use:

    UPDATE OF EVENTS

    SET FREE_SEATS = FREE_SEATS - 1

    WHERE ID_Movie = s_movie

    AND FREE_SEATS > 0;

    SY.

  • To proceed if a condition is fulfilled in a stored procedure

    Hello Experts,

    I have a fairly simple requirement and I was not able to solve, I hope someone could help me with this.

    I have an existing stored procedure that captures data in a cursor and writes it to a file using the UTL utilities. It works very well. I want to add a condition before the cursor, if this condition is met, it must proceed to the cursor and write the file, otherwise it's just not the procedure with an error message saying the unmet condition. I'm doing something wrong here, can someone please fix the part of the State. I think I could use 'IF EXISTS'. Please notify. Thank you in advance.

    This is the model,

    CREATE OR REPLACE PROCEDURE < PROC >

    as

    Define variables

    n_cnt number: = 0;

    ...

    ...

    ..

    -Here is the condition I want to go far from other I want to fail the procedure-

    BEGIN

    SELECT COUNT (TABLE_NAME) made a MISTAKE in n_cnt

    EXTRACT

    WHERE

    AND STATE = 'error ';

    IF n_cnt <>0 THEN go - continue the procedure -

    END else fail PROCEDURE - the procedure-

    -Creates a cursor/temp table that contains the data to be processed at line by line, which is used to write to a file

    <>SLIDER

    IS

    -Home select query starts here.

    SELECT DISTINCT FIRSTNAME

    LASTNAME

    NAMES

    ;

    BEGIN

    UTL_FILE. PUTF (v_FILE_HANDLE, '% s%s\n',

    'FIRST NAME' |' | ',

    "LASTNAME");

    CURSOR OPEN.

    -Get the cursor in the temporary folder

    CURSOR FETCH IN REC.

    CURSOR % WHILE

    -Using the loop to load data

    LOOP

    -Using the UTL package to write to a file

    UTL_FILE. PUTF (v_FILE_HANDLE, '% s%s\n',

    RECOMM. FIRSTNAME |' | ',

    RECOMM. LASTNAME );

    end loop;

    END '

    Hello

    You can do the following.

    IF n_cnt = 0 THEN

    RAISE_APPLICATION_ERROR (-20001, 'condition not met');

    END IF;

    See more info on PL/SQL Error Handling http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm#LNPLS007

  • All stored procedures wrapped in DB performance profiling

    DB: Oracle 11 g 2

    Hello

    In our database, we have about 150 stored packaged procedures on which I would like to make a few profiles, i.e. more expensive procedures (both: by the number of executions; for run time). We use DBMS_APPLICATION_INFO. SET_MODULE (MODULE_NAME = > procedure_name, ACTION_NAME = > "started/completed...") ") to record the name of the procedure in the comic book. Now of AWR report I couldn't find top 10-15 queries (not procedures; note, multiple queries can be part of the same procedure). So my question is how to find the settings above for all procedures of 150? Is there a CWA ready for use as a query for that *, or some particular tables/views that I should look into?

    Thank you

    * Note, I'm not a DBA, so I'll have to provide the DBA user query

    This is the query:

    embedded value

    set pagesize 0

    the colsep value ' |'

    trigger the echo

    Set feedback off

    set linesize 1000

    Set trimspool on

    headsep off Set

    REEL 'C:\Users\ssinha\Desktop\performance_profile_1.csv '.

    SELECT pkg,

    proc, max_execs, SUM (exec_time) total_time, MAX (execs),

    Rank() over (ORDER BY MAX (execs) DESC) exec_rnk,-from rank of just total executions

    Rank() over (ORDER BY SUM (exec_time) DESC) exec_time_rnk,-just total execution time function

    Rank() over (ORDER BY MAX (execs) * SUM (exec_time) DESC) rnk - ranking based on total operations x duration of execution

    Of

    (

    SELECT LOWER (module) proc,

    (SELECT name FROM dba_source WHERE the LOWER (text) AS TO_CHAR ('%' |)) Lower (s.module) | ('%') and rownum = 1) pkg,

    sql_id,

    The AMOUNT of execs (NVL (s.executions_delta, 0));

    SUM (ROUND (s.elapsed_time_delta/1000000, 3)) exec_time

    OF s dba_hist_sqlstat, dba_hist_snapshot ss

    WHERE the ss.begin_interval_time BETWEEN (SYSDATE-8) AND (SYSDATE-1) - for the last seven days

    AND ss.snap_id = s.snap_id

    AND ss.dbid = s.dbid

    AND ss.instance_number = s.instance_number

    AND s.executions_delta > 0

    GROUP BY s.module, sql_id

    ) t1

    WHERE the pkg IS NOT NULL AND NOT LIKE "% SYSTEM %" pkg AND pkg NOT LIKE '% AWR % '.

    GROUP BY proc, pkg

    ORDER BY rnk

    /

    SPOOL off

  • selection of lines by using the stored procedure

    All the

    At the risk of asking something obvious, I would like to know if it is possible to wrap a selection within a stored procedure.

    Create the abc as procedure

    Start

    date of b;

    Select sysdate into double b;

    end;

    /

    Question: I have a select complex which should be called from JAVA. I don't want to create a VIEW since at the request of the view, indeed I will do so: SELECT * FROM (my original query) which leads to performance.

    I would like to be able to:

    exec has;

    This should give me the result of

    SELECT

    x, z, c

    Of

    one

    ;

    How can I make this possible a stored procedure?

    Thank you

    Well, yes there are ways to do it, but first of all, you are mistaken in thinking that select * from , would lead to a performance overhead.  The optimizer based on CSSTidy will optimize the request to provide results without worrying so there is no noticeable performance difference.

    Java, you probably want to use a ref cursor and get java to retrieve the results back.

    Example of refcursor function (demonstrated SQL * more I don't have Java)...

    SQL > create or replace function test RETURN as sys_refcursor
    cur_o 2 sys_refcursor;
    3. start
    4. open cur_o to select empno, ename from emp;
    5 return cur_o;
    6 end;
    7.

    The function is created.

    SQL > var r refcursor;
    SQL > exec: r: = test();

    PL/SQL procedure successfully completed.

    SQL > print r;

    EMPNO, ENAME
    ---------- ----------
    7369 SMITH
    7499 ALLEN
    7521 WARD
    7566 JONES
    7654 MARTIN
    7698 BLAKE
    7782 CLARK
    7788 SCOTT
    KING 7839
    7844 TURNER
    7876 ADAMS
    JAMES 7900
    7902 FORD
    7934 MILLER

    14 selected lines.

  • Understanding stored procedures

    Hello

    Oracle 11.2.0.0.2

    I am trying to learn how stored procedures to use them later in the future web applications.  I was going through some documentation and found a simple stored procedure and I just wanted to see if someone could help to clarify if I understand how this stored procedure is supposed to work.

    TRIGGER XXX_TEST CREATE create a trigger with the name of XXX_TEST

    BEFORE INSERT Execute the trigger before it runs the command INSERT

    ON f.w5 FOR EACH ROW, do something "for each line' which is 'on' the table w5 belonged f schema

    START the starting point of the orders which will take place within this block

    Select count (1) IN the rt of 1934_e.doc where: new. U0 = docnum and 'AA' = a1 and a2 = 'DR' and a3! = « Z »)) ; Select all the records and put new 'in' the variable doc table belonging to f, where rt. U0 variable equals the docnum and column a1 is equal to 'AA' and column a2 is equal to 'DR' and a3 is not equal to 'Z'

    IF rt > 0 THEN conditional statement, if the rt variable is greater than 0, then below that

    : new.pt: = 9 | substr (PT 2);  concatenation of the variable which is set to match the 9

    : new. U1: = 'UNFAIR ';  sets the variable: new. U1: equal to 'EVIL'

    END IF;  end of the conditional statement

    delete from f.w5 where substr (pt, 1, 1) = 9 and U1 = "UNFAIR."  delete records from table w5 belonged to f where substring value 9 starting at position 1 with a length of 1 is equal to 9 and U1 is equal to 'FALSE'

    END;  the point of arrival of the "BEGIN"

    The part that I'm not sure of is the IF / END IF block.  I read that the | means the concatenation, but I don't really know what or why it is concatenation.  Another explanation is appreciated!  Thank you.

    Hello

    You have understood about correctly.

    There are many errors in this code.  For example, he referred to the local variables, rt and pt, but these variables are not defined anywhere.  For example, in the assignment you intrigued plus:

    : new.pt: = 9 | substr (PT 2);

    : NEW.pt initially made reference (rightly) of a column in the current insertion, but pt near the end line (without: NEW.) reference a local variable and I do not see where all the local variables are currently reported.  Perhaps the one who wrote this means use; NEW.pt in both places.

    SUBSTR (pt, 2)

    means the part of string pt starting with his 2nd character, so

    '9' || SUBSTR (pt, 2)

    a copy of the pt, but with its first character replaced by "9".

    Why the trigger would do this?  Your guess is as good as mine.  Apparently, the pt of the column is a kind of code, and the first character of the code is supposed to be "9" If there is no line in the table corresponding to the column of u0, doc and met certain other conditions, at the point where this line was inserted.

    (The | operator expected strings before and after it.)  If you use a NUMBER, such as 9, in a place where one expects a string, such as '9', Oracle will automatically convert the NUMBER to a string, but it is advisable to use the correct data in type.)

    Moreover, another error in this trigger is that he tries to DELETE rows from the same table that is based on.  A FOR EACH ROW trigger on tble f.w5 can't even read other f.w5 lines, let alone delete them.

  • How can I automatically run a stored procedure when a report is called?

    I've created a classic report on a table (without screen). When I go to this report, I would like to the stored procedure that deletes and inserts information about the table that is based on the report has been started automatically. Where and how can I do to put the call to the stored procedure that the report displays the data once the report is called?

    Thank you!

    Mark1970 wrote:

    I've created a classic report on a table (without screen). When I go to this report, I would like to the stored procedure that deletes and inserts information about the table that is based on the report has been started automatically. Where and how can I do to put the call to the stored procedure that the report displays the data once the report is called?

    Create a page of PL/SQL process by calling the procedure with a Point process On Load - front of regions.

    The report is based on a global temporary table?

  • Re: "insufficient privileges" error when you run the Java stored procedure in another schema

    I get an "insufficient privileges" error when you run the Java stored procedure in another schema, see details below.  I don't know what are missing privileges (I already granted the EXECUTE privilege), suggestions?  -Thank you.

    Define a simple java class and deploy it as a Java stored procedure to test:


    Schema: User1

    test of the package;

    public class HelloWorld {}

    public HelloWorld() {

    Super();

    }

    public static String Hello () {}

    Return "HELLO";

    }

    }

    CREATE or REPLACE FUNCTION HELLO RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME ' test. HelloWorld.hello () return java.lang.String';

    Grant execute on USER2 HELLO

    Test the Java stored procedure through the PL/SQL function call (in the same schema):


    Schema: User1

    SET SERVEROUTPUT ON

    DECLARE

    v_Return VARCHAR2 (200);

    BEGIN

    v_Return: = User1. HELLO;

    DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);

    END;

    anonymous block filled

    v_Return = HELLO

    Test the Java stored procedure through the PL/SQL function call in a different pattern:


    Schema: USER2

    SET SERVEROUTPUT ON

    DECLARE

    v_Return VARCHAR2 (200);

    BEGIN

    v_Return: = User1. HELLO;

    DBMS_OUTPUT. Put_line ('v_Return =' | v_Return);

    END;

    Error report-

    ORA-01031: insufficient privileges

    ORA-06512: at "User1." HELLO', line 1

    ORA-06512: at line 4 level

    01031 00000 - "insufficient privileges".

    * Cause: An attempt was made to change the user name or password

    without the privilege appropriate. This error also occurs if

    trying to install a database without the need for employment

    access privileges.

    When Trusted Oracle is configure in DBMS MAC, this error may occur

    If the user has been granted the privilege necessary for a higher label

    that the connection is active.

    * Action: Ask the database to perform the operation or grant administrator

    the required privileges.

    For users Trusted Oracle get this error, well that granted the

    the privilege that is suitable for the top label, ask the database

    administrator to grant the privilege to the appropriate label.

    You have created the function with AUTHID CURRENT_USER, which means that the function is executed with the rights of the applicant (but not with the rights of the author). This means that the applicant must have grants (directly or through roles) on all used/accessible objects in the service. In your case the user USER2 has not granted with EXECUTE on the class/source Java test. Class HelloWorld, causing the ORA-01031 exception. You create service without AUTHID CURRENT_USER (i.e. with AUTHID DEFINE, which is by default, if you do not have a specific reason to use AUTHID CURRENT_USER) or grant EXECUTE on JAVA test SOURCE. Class HelloWorld to User2.

    Dimitar

  • status of stored procedures

    Hi all

    Recently, our production database has been moved from DB2 to Oracle.

    I want to optimize DB

    I want to know, are at - it stored procedures, as performance impact. ?

    Thanks in advance

    Jr.Raj wrote:

    Thanks to you all

    import/export using sql loader, was done.

    I want to record/document the consequences, what sqls are affected. How can I do this

    IE is it possible trace/find the consequences.

    its easy to fix the database for me as soon as I know the implications.

    Thanks in advance

    SQL Loader to load data from Oracle

    Export/import (if you really mean the Oracle exp/imp orders) would be used to export and import from a database to a different Oracle database Oracle, if you say it's on DB2, so I don't know how you did that.

    Your question is always crazy.

    We do not know how you took procedures of DB2 and converted to procedures on Oracle.

    As Frank says, there will certainly be performance factors, so you can just take the code of a database, write the same code on Oracle in the same style and expect it to work as well.   The correct way to migrate the code must understand what each unit of code is supposed to do (entered accept, what exit that generate, what he does on the basis of data etc.) and write from scratch in Oracle uses the best features of Oracle for this.

    In regard to the performance of SQL queries, if database tables were well designed for their use (i.e. properly normalized (assuming that it is not an OLAP database)) and appropriate indexes exist for queries that will be made against it and statistical database etc are collected then Oracle will choose the best path of execution by SQL executed against them.

    So is your question about the performance of SQL queries on the database tables or code PL procedure/functions that were converted from DB2 to Oracle; and if the latter, then it would need to know which deal with these procedures/functions through to become Oracle'ized, and what looks like him code PL (i.e. don't talk about code that has loads of nested loops cursor rather than the SQL instructions pure; or code that did a lot of "off-database" calcuations or other).

    There is no way that anyone can just give you a list of the "impact", and how you say it is easy to set up the database once you know the implications is somewhat flippant.

Maybe you are looking for