on exception handling in function, while using this function in sql

Hi gurus,

I have a question concerning the registration of exceptions when using functions.

I wrote a separate package to handle errors, where I have a procedure.
In this process, I connect my error in a table and then triggers the error on the front end.
Ex:
proc_log_and_raise    -- this proc... inserts my error into a table and then raise
now, I have included this error procedure in all functions and procedures.

Consider an example with an example of procedure and function.
function func_1(( v_var   varchar2) return varchar2 is
begin
     select   column2
     from     table2
    where col1 = v_var;
exception 
    when others then 
         proc_log_and_raise;
end;   
procedure proc_1( v_var   varchar2) is
begin
    select   func_1(v_var)  -- error occurs here..
    from     table_a
    where   col1 = v_var;
exception 
    when others then 
         proc_log_and_raise;
end;    
now I do
exec  proc_1( v_var );
but now my problem is, when an error occurs in func_1, I get an error with the DML operation (as we are inserted in the table of errors)
ORA-14551: cannot perform a DML operation within a query.

So what I want to do, connect the two functions and procedure where the error occurred.

So is it better otherwise, we can write our exception handling, so that I could mistake the newspaper and use the function in a select statement.

Thank you.

A small example of using autonomous transactions

create table error_log (error varchar2(4000));

Table created.

SQL> create procedure log_error(p_error in varchar2) as
  2  pragma autonomous_transaction;
  3  begin
  4  insert into error_log values (p_error);
  5  commit;
  6  end;
  7  /

Procedure created.

SQL> create function will_fail return number as
  2  begin
  3  for x in (select 2/0 from dual) loop
  4  null;
  5  end loop;
  6  exception
  7  when others then
  8  log_error(sqlerrm);
  9  raise;
 10  end;
 11  /

Function created.

SQL> create procedure call_will_fail as
  2  begin
  3  for x in (select will_fail from dual) loop
  4  null;
  5  end loop;
  6  end;
  7  /

Procedure created.

SQL> exec call_Will_fail;
BEGIN call_Will_fail; END;

*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "WILL_FAIL", line 9
ORA-06512: at "CALL_WILL_FAIL", line 3
ORA-06512: at line 1

SQL> select * from error_log;

ERROR
-----------------------------------------------------------------
ORA-01476: divisor is equal to zero

Note that the recovery is carried out by the exception handler.

Tags: Database

Similar Questions

  • Someone used this on me and after a while windows shell program take completely my computer as well as bank accounts

    I finally understand what has happened to all computers, I threw out and now it's a. Someone used this on me and after a while windows shell program take completely my computer as well as the account numbers of bank accounts and cards and so on. I got it with computers. I have been a dedicated customer of Microsoft and I can't believe that you would put on such a dangerous program that any computer fool can use to people disrupting. I want to know what I can wip this thing by buying a new hard drive and operating system put this program on this subject before I sitgn on the internet and don't have not this thing happen? I would like to send you the hard drive rinse you these people in the open air where I could get my hands on them. This coswt haqs me more than I want to tell you.

    I think that you're wrong in your assessment of what you have been.  "Shell Microsoft Program"?  Please explain.

    If configure you your own computer, software Windows XP firewall is enabled, have a decent router (reset and configured with a password before connecting anything to him) between your network and the Internet, and you have changed all your passwords for each account to a password that is hard (15 characters or more containing at least three of the four character types (: uppercase, lowercase, number, and symbol) and checked that each account online has a configuration password recovery method that * you * have you personally (no one else has used your password they obtained to make sure if you have already changed your password, they could get the upper hand) and you have a decent anti-virus software installed. Then you should be fine.

    You can Disable Remote Desktop (on Windows XP Professional - you left out the details of your operating system in your rant) and Remote Assistance if that makes you more comfortable or you do not use these functions.

    Otherwise - most of it security is common sense stuff.  Do not download or run things do not know the origin of and trust said origin and application.  Do not open unknown emails and instant messages.  If you do not call to get your computer fixed, don't expect sopmeone will call you to fix your computer problem - and if they don't - know it's a scam.  Don't visit questionable websites.  Do not use the computer on a daily basis with a user account that could ruin everything (run as a normal user, not an administrator for your daily activities.)  Keep your system and you have installed - including all antivirus software - up to date/current.  Keep your computer in a locked - room physical security is a top priority.  Backup your important data to external media.  Change your password periodically - because you have a password - most probably someone can get it.  If something is * really * important keep you the 'secret' and protected - encrypt.  Almost every other method can be easily bypassed - encryption, not so much.  Etc and so on...

  • This just showed on my screen while using Firefox in a small box: "Applecare would like to view your screen".

    This just showed on my screen while using Firefox in a small box: "Applecare would like to view your screen".

    You specifically asked for their help? If this isn't the case, then dismiss the dialog box. It's probably a scam coming through your browser open.

  • I have a 6 s with Verizon iPhone. Can I send/receive calls (using this service and calls on other devices functionality) on my iPhone 5s, who was with AT & T service, but has no service now since I switched to Verizon?

    I have a 6 s with Verizon iPhone. Can I send/receive calls (using this service and calls on other devices functionality) on my iPhone 5s, who was with AT & T service, but has no service now since I switched to Verizon?

    Note: I'm able to get two phones to ring with an incoming call, but the 5s consist not out. Whenever I dial a number, it says call failed.

    Do not dial a number. Try to choose a contact in the contacts App and tapping on telephone button.

    That said, I don't think that outgoing calls work on continuity since another iPhone. given that the iphone is designed to make calls through its own service.

    Document to support that you just did not mention calls from a secondary iPhone at all, it points to Mac, iPad and iPod touch, which leads me to believe that it won't work.

    It runs from devices such as iPads and Macs, who have no other way to place a cell call.

  • I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    Question
    I want to record with < alt > < s > in the Exact program online. This function does not work. This is the first time I use this program with firefox.

    edit, escaped mod < s > in order to avoid the line through question

    A web page can be defined a "accesskey" for an item. Unlike IE/Chrome/Safari, who use the Alt key only, Firefox requires pressing Alt and Shift to activate the element. In other words, try

    ALT + SHIFT + S

    and see if it works.

    I don't know of any way to change this so that the change is not necessary. There may be an add-on?

  • Whenever I press "enter" while using firefox, 2 or 3 new tabs open with a website I've ever used. How can I stop this from happening? Thanks :)

    The Web site that appears is www.carpoint.com.au
    I've never used this site.

    Try Firefox SafeMode to see how it works there.

    A way of solving problems, which disables most of the modules.

    (If you use it, switch to the default theme).

    • You can open the mode without failure of Firefox 4.0 + by pressing the SHIFT key when you use the desktop Firefox or shortcut in the start menu.
    • Or use the Help menu option, click restart with the disabled... modules while Firefox is running.

    Do not choose anything at the moment, just use 'continue in safe mode.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before using the shortcut of Firefox (without the Shift key) to open it again.

    If it's good in Firefox Safe mode, your problem is probably caused by an extension, and you need to understand that one.

    http://support.Mozilla.com/en-us/KB/troubleshooting+extensions+and+themes

    When find you what is causing that, please let us know. It might help others who have this problem.

  • HELP - all words are underlined in red while using yahoo mail. How to solve this problem?

    I use Firefox browser and already upgraded to the latest 5.0. While using my yahoo mail, all words are underlined in red (it happens as I write this note). How can I prevent this and just him have misspelled words underlined? When the email is sent the underlining disappears.

    Please click the button solved it next to the answer that solved your problem of Firefox support, it appears when you are connected, so this thread is marked as resolved to help other users who may have this same problem.

  • You can run this program while using another anti-virus program

     
     
    You can run this program while using another antivirus program?
    I know that it is a matter of end now that MS does not have anyone else.
    However, I was going to dnld MS antivirus with Norton market too.
    I couldn't find info on one might or might not run another
    antivirus program during execution of the Member States. (as a general rule, you can't)

    Still, it would be interesting to know about this issue. And... Should be
    have been on one of the pages, so "requirements" or FAQ
    for example.
    Thank you in advance, Ric.

    Hello Ric Buckmiller,

    Thank you for using the Microsoft Windows Vista Forums.

    What specific Windows Vista virus protection software are you talking about?  Windows Vista will be usually comes with Windows Defender.  Windows Defender is software that helps protect your computer against the pop-ups, slow performance and threats caused by the software security spyware and other unwanted software to detect and remove spyware on your computer. Windows Defender Protection features in real time, a monitoring system that recommends actions against spyware when it's detected, minimizes interruptions, and helps you to remain productive.  Yes you can use it with antivirus software.

    Currently, Microsoft has an antivirus software on beta.  http://www.Microsoft.com/security_essentials/support.aspx
    If you have this downloaded, it advised that you can always use another software antivirus at this time.

    Or you are referring to Windows LiveOneCare?  Please let us know status.  Thank you!

    How to uninstall any other antivirus or firewall program?

    Before installing Windows Live OneCare, please make sure that you uninstall completely any existing antivirus or firewall program that may be on your computer.

    This step is very important, no matter what protection software you use, because installing one antivirus or firewall program over another on the same computer could potentially lock up the computer.

    Note: If you do want to keep the ability to reinstall your old antivirus or a firewall program in the future, make sure you have the original product CD (or a backup program disk) before you begin uninstalling.

    Engineer James Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.

  • I cannot perform certain functions because he says that I'm not an administrator, but it's my computer and I'm the only one who uses this computer__

    I cannot perform certain functions because he says that I'm not an administrator, but it's my computer and I'm the only person who uses this computer

    What are the functions? More global changes (changes to the system, software installation) require an elevation in Vista/Windows 7.

    Changes to the built-in Vista administrator account

    http://support.Microsoft.com/default.aspx?kbid=942956

    User - recommended configuration (Vista and Win7) accounts

    You absolutely don't want to have only one user account. As XP and all other Windows 7, Vista, and modern operating systems are operating systems multi-user with integrated system of accounts as default Administrator and comments. These accounts should be left alone because they are part of the structure of the operating system.

    In particular, you do not want account only one user with administrator privileges on Vista and Windows 7 because the administrator account integrated (normally only used in emergencies) is disabled by default. If you use as an administrator for your daily work, and this account is corrupt, things will be difficult. It is not impossible to activate the built-in administrator to rescue things, but it may require more work you want to do. Better not to get into a bad situation at first.

    The user account that is for your daily work must be a Standard user, with the extra administrative user (call it something like 'CompAdmin' or 'Tech' or similar) only it for elevation purposes. As a user Standard is recommended for security reasons and will help protect your computer against infections. After you have created "CompAdmin", connect to it and change your normal user account Standard. Then log on to your regular account.

    If you want to go directly to the desktop and ignore the Welcome screen with the icons of the user accounts, you can do this:

    Start Orb > Search box > type: netplwiz [Enter]
    Click continue (or provide an administrator password) when you are prompted by UAC

    Uncheck "users must enter a user name and password to use this computer". Select a user account to connect automatically by clicking on the account you want to highlight and press OK. Enter the password for this user account (when it exists) when you are prompted. Leave blank if there is no password (null). MS - MVP - Elephant Boy computers - don't panic!

  • \\N-PC is not accessible. You might not have permission to use this network resource while trying to access the network computer

    Title: Cannot access computers on my network?

    For some reason any my computer won't let me access any computer on my network.

    When I try to open any computer, including mine, since the tab "network" on the left he gives an error message saying "\\N-PC is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions. The specified network provider name is invalid.
    I ran the corner store to home group and network troubleshooting & two is out clearly said there are no problem.
    Anyone know how to fix this?

    Hello

    -What are the versions of the operating system installed on the conencted to computers in the network?

    -Did you do changes on the computer before this problem?

    Step 1: I suggest you to choose a network location, and then try to access the computer and check if it helps.

    Choose a network location

    http://Windows.Microsoft.com/en-us/Windows7/choosing-a-network-location

    Step 2: I also suggest you to check the network troubleshooter event logs to solve network problems and to check if it helps.

    Use Network Troubleshooter event logs to solve network problems

    http://Windows.Microsoft.com/en-us/Windows7/use-Network-Troubleshooter-event-logs-to-solve-network-problems

    Step 3: If the problem persists, I suggest you to follow the steps from the link and check if the problem persists.

    Why can't I connect to other computers?

    http://Windows.Microsoft.com/en-us/Windows7/why-can-t-I-connect-to-other-computers

    For reference:

    Networking of computers running different versions of Windows

    http://Windows.Microsoft.com/en-us/Windows7/networking-home-computers-running-different-versions-of-Windows

    Step 4: Disable the Antivirus

    I suggest to disable the Antivirus/Firewall temporarily, then check the issue.
    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software http://Windows.Microsoft.com/en-us/Windows7/turn-Windows-Firewall-on-or-off

    Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you need to disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network, while your antivirus software is disabled, your computer is vulnerable to attacks.
    Note: Please make sure that you enable the antivirus software after the test to keep your computer protected.

    Note: Turning off Windows Firewall may make your computer (and your network, if you have one) more vulnerable to damage caused by worms or hackers.

    Hope this information helps.

  • I have PSE14 and Lightroom 4.  You want to use 'open as layers"in lightroom.  It is not high lighted.  I thought that you can use this function to go to PSE.  Any suggestions?

    I have PSE14 and Lightroom 4.  You want to use 'open as layers"in lightroom.  It is not high lighted.  I thought that you can use this function to go to PSE.  Any suggestions?

    Ask in the forum of elements Photoshop Elements

  • I have to do, if this error message appears: "JavaScript exception: error calling function selector: [object Error]? It seems that by Internet Explorer. Thank you very much for your reply and I hope you can help me.

    I have to do, if this error message appears: "JavaScript exception: error calling function selector: [object Error]? It seems that by Internet Explorer. Thank you very much for your reply and I hope you can help me.

    Hi Brad,

    Here is the link: http://projektw.primo-werbung.de/

    We have this problem only by Internet Explorer. Mozilla, Safari and Opera - there is all right.

  • When I use the truncation tool, select a zone and press return it removes everything except for a single pixel. This just started today. CS5, Windows 7.

    When I use the truncation tool, select a zone and press return it removes everything except for a single pixel. This just started today. CS5, Windows 7. I tried to reinstall CS5 and who did not help. I am trying to set up a new computer and installed Photo Shop CS5 on it earlier in the day. Maybe it has something to do with it. But until I get the new fully configured machine I still want to continue to work on my current machine, which is where the problem is happening.

    Hi haroldschlegel,

    Please try resetting the cropping tool

    Restart Photoshop once done and see if that helps.

    Kind regards

    Assani

  • Using 'this' inside the XML onLoad function

    Hi all

    I use this line of code inside an onLoad() XML:

    this.attachMovie ("MasterBtn", "instance_name", this.getNextHighestDepth (), {_x:50, _y:50});})

    The 'this' keyword points me to the XML object. Are there alternatives to the use of 'this', as the use of a container element.


    concerning

    John
    http://www.javono.com

    So I guess you want on the main timeline? Here's what I do. That ' it's the best, but it seems to work for me. Outside the XML stuff with my other declarations of variables usually, I add the following:

    var host: MovieClip = this;

    Then in the event handler:

    home.attachMovie (etc.)

    I think it should work.

  • exception handling practices

    I just started a development project with a new client, they devised a way of handling/logging of exception that I don't think is good. Essentially in the plsql they wrap each call to the procedure to insert/update / a, when other exceptions, make a call to a procedure of logging and set a flag to continue = N. The following statement should then check if the indicator to continue is Y, while the declaration is also wrapped in others, etc. I know that it is wrong and wants to explain the best approach.

    According to me, logging (which is mandatory) must occur once in a block of exception at the end of their procedures. The DML statements can have their own exception handlers (but not "while others"), who can simply raise an exception custom for the recorder at the bottom know that DML has failed. When you call another procedure, the called procedure can raise an exception of "global" (defined in a package specification), so the proc call can then catch the exception even and save it.

    Is there a better approach? Thanks in advance.

    2901807 wrote:

    HI John - Thank you, in your example if there are several DML statements how does block the logger in the exception record is not?

    Simple - just use the technique discussed in the Oracle documentation:

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/errors.htm#BCFHFGHD

    Use of Variables of Locator to identify places of Exception

    Using a handler exception for a sequence of statements, such as INSERT , DELETE , or UPDATE statements, can hide the statement that caused an error. If you know which statement has failed, you can use a locator variable, as in example 11-14.

    Example using a Variable marker to identify the location of an Exception from 11-14

    CREATE OR REPLACE PROCEDURE loc_var AS

    stmt_no NUMBER;

    name VARCHAR2 (100);

    BEGIN

    stmt_no: = 1;  -designates the 1st SELECT statement

    SELECT table_name INTO name

    From user_tables

    WHERE table_name LIKE 'ABC % ';

    stmt_no: = 2;  -designates 2nd SELECT statement

    SELECT table_name INTO name

    From user_tables

    WHERE table_name LIKE '% XYZ ';

    EXCEPTION

    WHEN NO_DATA_FOUND THEN

    DBMS_OUTPUT. PUT_LINE

    ("Table name is not not in the query ' | stmt_no);

    END;

    /

    CALL loc_var();

    Each step can have code (conditional code for example) that records the appropriate parameters or the values of the variables in an object type custom LOG that you can set for this purpose.

    Then the log statement passes just the instance of the newspaper inside the journal type.

    See my sample code in this thread:

    How to get a procedure/function called in the package name?

    The code example illustrates the DDL for the type of object (TYPE_LOG_INFO). The type has attributes for: package_name, proc_name, step_number, etc.

Maybe you are looking for

  • Time Machine does not restore files in numbers

    I just tried to restore a file of numbers with Time Machine. I had just edited and saved.  But then I realized that I had made a mistake.  So I wanted the version that I had for a few months before. But even if I went back several weeks, when I click

  • Time machine vs iCloud

    Although I use iOS for a number of years (iPhone and iPad) I am a new Mac user, I just went from a Windows machine for my first MacBook Pro.  I'm still learning the differences between the systems, but I've recently become confused about back ups. If

  • P6-2330 HP: HP p6-2330 change from windows to windows 7 pro 8.1

    Im going to change my hard drive to an SSD. I hjave a disc for Windows 7 Pro OEM, if I install it on my new ssd will work on a computer(p6-2330) that came with 8 windows of the factory

  • Windows Vista - all programs 'stopped working' and nothing does not open. McAfee is also not working and help and support center does not even

    On my windows vista computer, whenever I turn on my computer and log on, none of my programs work. An error message appears saying that the program has stopped working and windows will try to find a solution to the problem.  The problem is that the h

  • PKCS5 padding with AES

    I use AES encryption, including the huaes.h header. Operating mode is BCE. Encryption and decryption on the device works very well. But I want to send the data encypted to a server using a PKCS5 padding. How can I configure PKCS5 padding?