Error Trapping

Using Forms 6i Client/Server...
Does anyone have a generic error handling routine for Forms?
I want to trap Forms and DB error messages in on-error/on-message triggers to display more user-friendly messages. I also want to retain message bultins in their present format.
Ideally the code will be in a PL/SQL library that I can reference in the triggers.
I know about the dbms_error_code/erroc_code/text built ins but I am having trouble differentiating them!
At the moment, everything seems to be picked up in the on-error trigger as a dbms_error_code!
EG.
BEGIN
IF dbms_error_code IS NOT NULL
THEN
--FLAG DB ERROR
ELSIF error_code IS NOT NULL
THEN
-- FLAG FORM ERROR
END IF;
END;
always flags a db error!

Here is our PLL_ON_ERROR pll library trigger. It has some site-specific code, but the dbms_error_text handling should work well for you. The PLL_MsgC and MsgE are just Message commands followed by a Raise FormTrigger_Failure; The _MsgE sets the background color red on a specific field.
PROCEDURE PLL_ON_ERROR(ERR_IN IN NUMBER   DEFAULT NULL,
                       MSG_IN IN VARCHAR2 DEFAULT NULL) IS           --*
-- PLL_On_Error overrides default form error processing.  Usually
-- this is called from a form-level on-error trigger with the command
--    PLL_ON_ERROR;
-- However, if the form requires additional error processing, the
-- following method can be used:
DECLARE
  Err_Code NUMBER(5)     := ERROR_CODE;
  MSG     VARCHAR2(150)
          := SUBSTR('   '||ERROR_TYPE||'-'||TO_CHAR(Err_Code)||': '
                                     ||ERROR_TEXT,1,150);
BEGIN
  IF Err_Code=<special value here> THEN
      PLL_MSGE('   <special message, etc. here> ');
  ELSE
    PLL_ON_ERROR(Err_Code,MSG);
  END IF;
END;
  Err_Code NUMBER(5)     := NVL(ERR_IN,ERROR_CODE);
  Err_Text VARCHAR2(100) := ERROR_TEXT;
  MSG      VARCHAR2(150) := NVL(MSG_IN,SUBSTR('   '||ERROR_TYPE||'-'
                           ||TO_CHAR(Err_Code)||': '||Err_Text,1,150));
  DBMS_TXT VARCHAR2(500);
BEGIN
  IF Err_Code IN (40401,40405,     --No changes to save/apply
                  40100,40352) THEN --at first/last record
    MESSAGE(MSG,NO_ACKNOWLEDGE); -- Don't raise Form_Trigger_Failure
  ELSIF Err_Code=41049 THEN
    PLL_MSGC('   0017  DELETE IS NOT ALLOWED');
  ELSIF Err_Code=41051 THEN
    PLL_MSGC('   0016  INSERT IS NOT ALLOWED');
  ELSIF Err_Code=40733 --pl/sql built-in <xxx> failed.
    AND INSTR(MSG,'SHOW_LOV')>0
    AND (   GET_BLOCK_PROPERTY(NAME_IN('SYSTEM.TRIGGER_BLOCK'),
              UPDATE_ALLOWED)='FALSE'
         OR GET_BLOCK_PROPERTY(NAME_IN('SYSTEM.TRIGGER_BLOCK'),
              INSERT_ALLOWED)='FALSE'
           AND NAME_IN('SYSTEM.RECORD_STATUS')='NEW'
         OR DBMS_ERROR_CODE = -54 ) then -- -54=Locked record
    -- Dsply-only user selected a val from LOV. Prevents double msgs
    RAISE FORM_TRIGGER_FAILURE;
  --  Display Forms error along with
  --  database error.  Helps determine the "real" problem.
  ELSIF Err_Code IN
     (40102,       --Record must be entered or deleted first
      40501,       --unable to reserve rec for updt/delete (ORA-00054)
      41008,       --undefined fn key(dbms_txt=ora-01003:no stmt parsed)
      47013,47021) --no such parameter errs.
    THEN -- display msg on status line.  Don't check dbms_txt below
    PLL_MSGC(MSG);
  --  Format date input error msg
  Elsif Err_Code between 50002 and 50026
    and Err_Code - 50000 in(2,3,4,12,17,18,19,21,22,23,25,26) then
    -- 50002: Month must be between 1 and 12.
    -- 50003: Year must be 00-99 or 1000-4712
    -- 50004: Day must be between 1 and last of month.
    -- 50012: Date must be entered in a format like <fxMMDDRR>
    -- 50017,18,19: Hour,Min,Sec must be between 0 and 23,59,59.
    -- 50025: Date/time must be entered in a format like <xxyytttt>
    -- 50026: same as 50012 and 50025 with <yyyy> year.
    Declare
      Fmt varchar2(30)
        := replace(replace(replace(replace(
             upper(GET_ITEM_PROPERTY(
                                     Name_in('SYSTEM.TRIGGER_ITEM'),
                                     FORMAT_MASK)),
            'RR','YY'),'FX',''),'HH24','hh'),'MI','mm');
      Itm  varchar2(30);
      Msg1 varchar2(100);
      Msg2 varchar2(30);
    Begin
      Itm := Substr(Name_in('SYSTEM.TRIGGER_ITEM'),
                    instr(Name_in('SYSTEM.TRIGGER_ITEM'),'.')+1);
      Itm := replace(Itm,'_',' ');
      Msg1 := '   0012  Invalid value in '|| Itm ||'.   ';
      If fmt = 'YY' then
        PLL_MSGE(Msg1||'Enter a two-digit year between 00 and 99.');
      Else
        Msg2 := substr(Err_Text,1,instr(Err_Text,' ')-1);
        If upper(Msg2) in ('MONTH','DAY','YEAR','HOUR','MINUTES') then
          Msg1 := Msg1 ||'Error in ' || Msg2 ||' --  ';
        end if;
        PLL_MSGE(Msg1 || 'Format is ' || Fmt );
      End if;
    End;
  ELSIF Err_Code BETWEEN 40200 AND 40299 --field errors detected by Form
     OR Err_Code = 40108 -- No such form
     OR Err_Code > 50000 THEN
    PLL_MSGE(MSG); --sets erroritem visual attribute
  ELSE -- all other messages
    -- check database error message --
    DBMS_TXT := SUBSTR(DBMS_ERROR_TEXT,1,500);
    if  DBMS_TXT is not null
    and substr(DBMS_TXT,5,5)
      not in('00000',
             '01403') then --1403=no data found
      -- Show entire msg, add new_line chars.
      DBMS_TXT := replace(DBMS_TXT,'ORA-',chr(10)||'ORA-');
      DBMS_TXT := replace(DBMS_TXT,' '||chr(10), chr(10));
      -- show MSG and DBMS_TXT both as an alert --
      PLL_ALERT( ltrim(MSG) || DBMS_TXT );
      Raise Form_Trigger_Failure;
    else
      PLL_MSGC(MSG);
    End if;
  END IF;
END PLL_ON_ERROR;And PLL_ALERT is as follows:
PROCEDURE PLL_ALERT(MSG IN VARCHAR2) IS
-- Alert_Message can be up to 200 characters.
-- Message can be up to 255.
-- Displays an alert message.  If the form has an alert named ALERT_001
-- and the message is not more than 200 characters, then that is used.
-- Otherwise, the default "stacked message" alert method is used by
-- setting two successive messages.  An alert can display a maximum of
-- 200 characters while the stacked messages can display 255.  If Msg
-- is longer than 255, then this loops to display all the message.
  Alert_ID Alert;
  Btn      Number;
  P        pls_integer := 1;
  L        pls_integer := nvl(length(msg),0);
  mtxt     varchar2(300);
  ltrm     boolean := true;
  -- This function ensures new line characters are handled properly.
  -- replaces linefeed [chr(10)] and Carriage Return [chr(13)] chars
  -- as necessary depending on where form is running (Web
  -- or client/server) and whether using an Alert or stacked message.
  function trans(m_in in varchar2,using_alert boolean := False)
       return varchar2 is
    m  varchar2(300) := m_in;
  begin
    -- Modify end-of-line characters, depending on WEB or client/server
    -- and whether using alert or stacked message.
    If Get_Application_Property(User_Interface) = 'WEB' then
      if using_alert then --web alert: chr(10) is new line
        m := replace(m, chr(13), chr(10));
        m := replace(m, chr(10)||chr(10), chr(10));
      else -- web, message: chr(138) is new line
        m := translate(m, chr(10)||chr(13), chr(138)||chr(138) );
        m := replace(m, chr(138)||chr(138), chr(138));
      end if;
    elsif not using_alert then
      -- Client/server:  If using alert, no change required
      -- Client/server message: chr(13) is new line
      m := replace(m, chr(10), chr(13));
      m := replace(m, chr(13)||chr(13), chr(13));
    end if;
    -- ltrim first line only
    if ltrm then
      m := ltrim(m);
      ltrm := false;
    end if;
    return m;
  end trans;
BEGIN
  If L <= 200 then
    Alert_ID := Find_Alert('ALERT_001');
    If not ID_Null(Alert_ID) then
      Set_Alert_Property(Alert_ID,ALERT_MESSAGE_TEXT,trans(Msg,True));
      Btn := Show_Alert(Alert_ID);
      return;
    end if;
  end if;
  if L <= 255 then
    Message(trans(msg));
  else
    loop exit when P > L;
      If L - P <= 254 then
        mtxt := substr(msg,p);
        P := P + 255;
      Else
        mtxt := substr(msg,p,252) || '...';
        P := P + 252;
      End if;
      Message(trans(mtxt));
    end loop;
  end if;
  Message(' ',no_acknowledge); --forces message into an alert box.
End PLL_ALERT;

Similar Messages

  • Form Validation - Error Trapping Not Working.

    Hi,
    I'm a Coldfusion beginner desperately trying to get along with some database work for my site and have come across an annoying error that I just can't solve! I'm sure I'm missing something really basic - I just can't for the life of me figure out what it is!
    Basically, I have a form for users to sign-up. I have introduced several cfif statements and a basic CAPTCHA system to trap errors. If any errors are submitted then they should be displayed in a cfwindow. This process works fine until I specify the form action - after which it is completely ignored and the form contents are written to the database without any validation taking place. Even without specifying the form action the errors won't show in Internet Explorer.
    I really would appreciate any help - it's driving me crazy!
    Thanks in advance,
    Tom.
    Here is the code:
    <cfinclude template="CFIDE/headertemplate.cfm">
    <!-- RANDOM NUMBER GENERATOR  FOR CAPTCHA -->
    <cffunction name="makerandom" returnType="string" output="false">
    <cfset var chars = "23456789ABCDEFGHJKMNPQRSTW">
    <cfset var length = randRange(4,6)>
    <cfset var result = "">
    <cfset var i = "">
    <cfset var char = "">
    <cfscript>
         for(i=1; i <= length; i++) {
              char = mid(chars, randRange(1, len(chars)),1);
              result&=char;
    </cfscript>
    <cfreturn result>
    </cffunction>
    <!-- ERROR TRAPPING -->
      <cfset showForm = true>
      <cfparam name="form.email" default="">
      <cfparam name="form.artistname" default="">
      <cfparam name="form.city" default="">
      <cfparam name="form.postcode" default="">
      <cfparam name="form.pass" default="">
      <cfparam name="form.captcha" default="">
      <cfparam name="form.captchahash" default="">
      <cfparam name="form.terms" default="">
    <cfif isDefined("form.send")>
          <cfset errors = "">
    <cfif len (form.email) LT '4'>
    <cfset errors = errors & "You must include a valid e-mail address.<br />">
    </cfif>
    <cfif find('.',form.email) is '0'>
    <cfset errors = errors & "Your E-mail features no . symbol.<br />">
    </cfif>
    <cfif find('@',form.email) is '0'>
    <cfset errors = errors & "Your E-mail features no @ symbol.<br />">
    </cfif>
    <cfif not len(trim(form.artistname))>
    <cfset errors = errors & "You must include your name.<br />">
    </cfif>
    <cfif not len(trim(form.city))>
    <cfset errors = errors & "You must include your city.<br />">
    </cfif>
    <cfif not len(trim(form.postcode))>
    <cfset errors = errors & "You must include your postcode.<br />">
    </cfif>
    <cfif not len(trim(form.pass))>
    <cfset errors = errors & "You must specify a password.<br />">
    </cfif>
    <cfif len(form.pass) LT '6'>
    <cfset errors = errors & "Password must be between 6 and 10 characters.<br />">
    </cfif>
    <cfif hash(ucase(form.captcha)) neq form.captchahash>
    <cfset errors = errors & "You did not enter the correct Captcha text.<br />">
    </cfif>
    <cfif not len(trim(form.terms))>
    <cfset errors = errors & "You must agree to our Terms and Conditions.<br />">
    </cfif>
    <cfif errors is "">
    <cfset showForm = false>
    </cfif>
    </cfif>
    <cfif showForm>
    <cfset captcha = makerandom()>
    <cfset captchahash = hash(captcha)>
    <cfoutput>
    <h1>Artist Sign-Up</h1>
    <p>Your details are required for sign-up. Mandatory fields are indicated with a *.</p><br/><br/>
    <cfif isDefined("errors")>
    <cfwindow name="formerrors"
    title="Form Errors"
    width="450"
    height="250"
    modal="true"
    initshow="true"
    center="true"
    closable="true"
    minheight="200"
    minwidth="200">
    <center><b>Please correct the following errors and re-submit the form:</b><br /><br/>#errors#
    <br/><a href="javascript:ColdFusion.Window.hide('formerrors');">Close Window</a>
    </center>
    <br/></cfwindow>
    </cfif>
    <!-- FORM CONTENTS -->
    <cfform action="artist_insert.cfm" method="post">
    <table class="signup">
    <tr>
    <td class="noborder" width="200">
      <label for="email">E-Mail Address*:</label>
    </td>
    <td class="noborder" width="156">
    <input type="text" name="email" class="textbox" value="<cfoutput><cfif IsDefined("URL.email")>#URL.email#<cfelse></cfif></cfoutput>"/>
    </td>
    <td class="noborder">
    <cftooltip autoDismissDelay="9999" tooltip="This needs to be a valid e-mail so that<br/> promoters can get in contact with you. <br/>If several people will be using this<br/> account then try and make it a shared<br/> address."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder" width="200">
      Your Password* (6 to 10 chars.):
    </td>
    <td class="noborder">
    <input type="password" class="textbox" name="pass" maxlength="10"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder" >
    Artist/Band Name*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="artistname" />
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    City*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="city" />
    </td>
    <td class="noborder">
    <cftooltip autoDismissDelay="9999" tooltip="Entering your locational details enables Gig<br/>Digger to find the events and promoters<br/>in your area. Try specifying a well known<br/>city nearby for the best results."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder">
    Postcode*:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="postcode" maxlength="8"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    Your Contact Number:
    </td>
    <td class="noborder">
    <input type="text" class="textbox" name="contact" maxlength="14"/>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <tr>
    <td class="noborder" valign="top" width="200">Please enter the CAPTCHA text in the box below*: </td>
    <td class="noborder" align="left">
    <center><cfimage action="captcha" width="156" height="50" text="#captcha#" border="1">
    <input type="hidden" name="captchaHash" value="#captchaHash#"></center>
    </td>
    <td class="noborder" valign="top">
    <cftooltip autoDismissDelay="9999" tooltip="This is here to ensure that<br/>you're human. It stops abuse <br/>of the site and makes it a safer <br/>place for us all."><img src="pics/i.jpg" alt="info" border="1" /></cftooltip>
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    <td class="noborder" align="right"><font size="-2"><b><a href="javascript:location.reload(false)">Refresh Page</a></b></font>
    </td>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder"></td>
    <td class="noborder"><input type="text" name="captcha" class="textbox"></td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder" width="170">Please check this box to confirm that you agree<br/> to our <b><a href="termsandconditions.cfm">Terms and Conditions</a></b>*.
    </td>
    <td class="noborder">
    <input type="checkbox" class="textbox" name="terms" /></td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    </tr>
    <tr>
    <td class="noborder">
    </td>
    <td class="noborder" align="center">
    <cfinput type="image" src="pics/submit.png" name="send" value="Submit" validate="submitonce" border="1">
    </td>
    </tr>
    </table>
    </cfform><br/>
    </cfoutput>
    <cfelse>
    <cfoutput>
    Thank you for submitting your details, #form.name#. You may now log in with your e-mail and password.
    </cfoutput>
    </cfif>
    </td>
    </tr>
    </table>
    <!-- FOOTER START -->
    </body>
    </html>
    ARTIST INSERT PAGE - artist_insert.cfm
    <cfquery datasource="071907cs07to">
    INSERT INTO Artist(    Nsudate,
                        Nemail,
                        Npass,
                        Nname,
                        Ncity,
                        Npostcode,
                        Ncnumber
    VALUES(    ( #Now()# ),
            '#Trim(form.email)#',
            '#Trim(form.pass)#',
            '#Trim(form.artistname)#',
            '#Trim(form.city)#',
            '#Trim(form.postcode)#',
            '#Trim(form.contact)#'
    </cfquery>

    In addition to BreakawayPaul's answer.
    You are making it very difficult to troubleshoot your if/else logic because your code includes all the display stuff.  Since you're a self proclaimed beginner, you might want to try another approach.
    Save your old page and start a new one from scratch.  Solve all your logic problems first.  Display what you need to see with the cfdump tag.
    Here are some hints to make the whole thing easier.
    1.  In your cfform, use the validate and required attributes to catch errors earlier.
    2. You don't have to cfparam every form field.  The form has either been submitted to it hasn't.  If it has, all the fields will be there with the possible exception of checkboxes or radio button, if nothing was selected.

  • Error trap with Start-Process

    I am trying to use Start-Process to drive Regedit merging a REG file with this code.
    Start-Process regedit -Argumentlist:"/S $TempReg" -Wait -ErrorAction:Stop
    When the REG file is properly formatted this works a treat, but I can't seem to address the error condition. If I do a Try/Catch it seems to produce a successful Try. I tried doing it with a return code as well, and that didn't seem to see the error either.
    Am I doing something wrong in the code, or is Regedit a special case, and if so, can I catch errors from it at all?
    Thanks!
    Gordon

    Hmm, I assume you mean Regedit can't be used "with an error trap"? So, perhaps a different form of the question. First thing to note is that I have tried to address this with direct PowerShell access to the registry, and for some reason Autodesk
    products don't respond well to that approach. Everything looks right when I do it, but then the Autodesk product will push it's own settings over the top, and their settings are idiotic. However, when I push my settings via REG file the Autodesk products accept
    it and move on.
    So, does anyone have a suggestion for either
    A: Identifying exactly what the difference is between the .REG and Set-ItemProperty approaches, so the more elegant solution can be made to also work? Or
    B: Another approach to REG file merge that does allow for error trapping?
    My only other option I think is to implement it without error trapping, as the functionality is pretty important, and the most likely errors will show up in testing not production anyway.
    Thanks!
    Gordon

  • Error trap on extraneous script parameters

    I have a script that accepts named parameters at the command line, and I would like to error trap any extraneous parameters, rather than having a malformed shortcut cause an error. I tried just wrapping the Param section at the top of the script in a Try/Catch
    but that doesn't work at all. Is there any mechanism to address this more gracefully, or do i just need to document proper argument syntax and let users see the error if they mess it up?
    Note, I used Try/Catch with and without cmdletbinding, and with camdletbinding in and out of the Try. Some variations caused errors, and some caused all parameters to be ignored, even the ones that where correctly being passed.
    Gordon

    So, basically what I want to do is have two named parameters, one required and one optional, and then catch the error when someone includes a third, or gets a name wrong. It seems like there is no way to catch that, you are just going to get a standard
    PowerShell error. Not the end of the world, but like not being able to natively run a powershell script with no console at all, a little annoying, if in fact it can't be done.
    It sounds like this is what you want (as far as the 1 mandatory and 1 option params go):
    Function Test {
    [cmdletbinding()]
    Param (
    [parameter(Mandatory=$True)]
    [string]$Param1,
    [parameter()]
    [string]$Param1
    #CODE HERE
    Unfortunately, you will not be able to get around the issue of someone attempting to use a 3rd parameter and having an error thrown. This will happen at runtime and can't be caught.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Error Trapping for Report

    I have a access 2013 database.  I am trying to automate generation of 3K+ pdf reports.  I have the following code. It was working in a previous iteration of the code pictured here, but due to some "illegal" characters, was canceling
    the outputTo command lines due to those characters.  i.e. mostly / chars.  So, I wanted to trap those errors and write them to a table, I added the on error statement.  It works for the first record with an illegal character, but second time
    around it cancels the outputTo command.  What am I doing wrong?
    Private Sub OutputAll_Click()
        DoCmd.GoToRecord , , acFirst 
        Dim V_Counter
        V_Counter = 1
        Me.Counter = V_Counter
        Do While V_Counter <= 20
            On Error GoTo FirstReportError
            DoCmd.OutputTo acOutputReport, "NoMeasurementsIPReportForQualityPreview", acFormatPDF, "c:\PDFFiles\" & Me.IPKey
            GoTo NoFirstFeportError
    FirstReportError:
            DoCmd.OpenForm "IPKeyErrorsForm"
            Forms!IpKeyErrorsForm.IpKeyError = Me.IPKey
            DoCmd.Close acForm, "IPKeyErrorsForm"
            DoEvents
            GoTo SkipSecondReportDueToError
    NoFirstFeportError:
            DoCmd.OutputTo acOutputReport, "NoMeasurementsIPReportForQualityPreviewProductionVersion", acFormatPDF, "c:\PDFFiles\" & Me.IPKey & "_ProductionVersion"
            DoEvents
    SkipSecondReportDueToError:
            DoCmd.GoToRecord , , acNext
            V_Counter = V_Counter + 1
            Me.Counter = V_Counter
        Loop
    End Sub
    IPKey on this report is:
    00-5901-981-02_STYLUS BAR 4/6 MM_100_D

    Hans,
    Thanks again for your timely response.  It is now sort of working, but I must be missing one important piece.  Here is what I have.
    Private Sub OutputAll_Click()
        DoCmd.GoToRecord , , acFirst 'Go to the first record
        Dim V_Counter
        V_Counter = 1
        Me.Counter = V_Counter
        Do While V_Counter <= 739
            If V_Counter = 739 Then
                MsgBox "Counter is 739"
            End If
            On Error GoTo FirstReportError
            DoCmd.OutputTo acOutputReport, "NoMeasurementsIPReportForQualityPreview", acFormatPDF, "C:\PDFFiles\" & Me.IPKey & ".pdf"
            Resume NoFirstReportError
    FirstReportError:
            DoCmd.OpenForm "IPKeyErrorsForm"
            Forms!IpKeyErrorsForm.IpKeyError = Me.IPKey
            DoCmd.Close acForm, "IPKeyErrorsForm"
            DoEvents
            Resume SkipSecondReportDueToError
    NoFirstReportError:
            DoCmd.OutputTo acOutputReport, "NoMeasurementsIPReportForQualityPreviewProductionVersion", acFormatPDF, "c:\PDFFiles\" & Me.IPKey & "_ProductionVersion" & ".pdf"
            DoEvents
    SkipSecondReportDueToError:
            DoCmd.GoToRecord , , acNext
            V_Counter = V_Counter + 1
            Me.Counter = V_Counter
        Loop
    Done:
    End Sub
    Only problem is, it does the code after the label "FirstReportError" every time. What am I missing?

  • Error trapping with OPEN FOR

    I am trying to add some error handling to this packaged procedure written by someone else.
    How can I check for an Oracle error in the query in m_sql_string? I have tried checking
    SQLCODE after the 'OPEN FOR', but it is always 0 even when errors are being encountered.
    I need to trap errors and write them to an error table.
    CREATE OR REPLACE PACKAGE P1
    AS
    TYPE CHCUR IS REF CURSOR;
    PROCEDURE QRY_WR_STATUS_CHANGES (tsAfter IN VARCHAR2, rsResult OUT CHCUR);
    END P1;
    CREATE OR REPLACE PACKAGE BODY P1
    AS
    PROCEDURE QRY_WR_STATUS_CHANGES(tsAfter IN VARCHAR2, rsResult OUT CHCUR)
    IS
    m_sql_string VARCHAR2(30000);
    BEGIN
    m_sql_string := 'SELECT TS_STATUS, CD_STATUS, CD_WR, RowId
    FROM TABLE_A
    WHERE
    NOT EXISTS (SELECT ''X'' FROM TABLE_B where TABLE_B.USER_NAME =TABLE_A.ID_OPER)
    ) AND
    NOT EXISTS (SELECT ''X'' FROM TABLE_C where TABLE_C.wr = TABLE_A.CD_WR and
    TABLE_C.dist = TABLE_A.CD_DIST)
    AND
    TABLE_A.TS_STATUS >
    TO_DATE('''||tsAfter||''', '||'''MM/DD/YYYY HH24:MI:SS'')
    AND CD_STATUS Like ''%X''';
    OPEN rsResult FOR m_sql_string;
    END QRY_WR_STATUS_CHANGES;
    END P1;
    Thanks in advance.

    Thank you. I just tried adding such an exception block. It compiles and runs fine, but isn't trapping the error. I see the error returned in the results when I call the proc from SQL*PLUS, but can't seem to trap it in the code...it's like I need to check the contents of the OUT data for the error or something. Below is the modified code and then showing executing it and the results. Any further ideas are greatly appreciated.
    CREATE OR REPLACE PACKAGE P1
    AS
    TYPE CHCUR IS REF CURSOR;
    PROCEDURE QRY_WR_STATUS_CHANGES (tsAfter IN VARCHAR2, rsResult OUT CHCUR);
    END P1;
    CREATE OR REPLACE PACKAGE BODY P1
    AS
    PROCEDURE QRY_WR_STATUS_CHANGES(tsAfter IN VARCHAR2, rsResult OUT CHCUR)
    IS
    m_sql_string VARCHAR2(30000);
    BEGIN
    m_sql_string := 'SELECT TS_STATUS, CD_STATUS, CD_WR, RowId
    FROM TABLE_A
    WHERE
    NOT EXISTS (SELECT ''X'' FROM TABLE_B where TABLE_B.USER_NAME =TABLE_A.ID_OPER)
    ) AND
    NOT EXISTS (SELECT ''X'' FROM TABLE_C where TABLE_C.wr = TABLE_A.CD_WR and
    TABLE_C.dist = TABLE_A.CD_DIST)
    AND
    TABLE_A.TS_STATUS >
    TO_DATE('''||tsAfter||''', '||'''MM/DD/YYYY HH24:MI:SS'')
    AND CD_STATUS Like ''%X''';
    OPEN rsResult FOR m_sql_string;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Error code is: Long postings are being truncated to ~1 kB at this time.

  • Unexpected kernel mode error trap (Ndu.sys)

    I've been getting thus BSOD error "unexpected kernel mode trap (ndu.sys)" after
    installing visual studio 2013 when in connect to the internet and open the browser. If the browser is not opened then it runs just fine even if the internet is connected. 
    The worst situation even makes my PC crash 5 times in an hour. Almost crazy.
    I've read the related topic about upgrade my driver would solve the question. But I just
    clean reinstall Windows 8.1 two days ago. Before that I was still using Windows 8.1, VS2013, older driver and patch, and never got BSOD before. Why newer and cleaner environments cause PC so much trouble? I don't get it and come seek for help.
    Here is one of my BSOD dump file. Please check it.
    https://dl.dropboxusercontent.com/u/62254866/072614-11859-01.rar
    Thank you very much!

    I suggest you start by doing a system file check.  This one crash was Related to Ndu.sys Windows Network Data Usage Monitoring Driver from Microsoft Corporation
    Please run a system file check (SFC)
    All instructions are in our Wiki article below...
    Should you have any questions please ask us.
    System file check (SFC) Scan and Repair System Files
    Wanikiya and Dyami--Team Zigzag

  • Two errors trap

    i have this doubt of how to trap the 2 errors 'ORA-00001' which is kind of a
    unique error & 'ORA-00054' which is kind of a resource busy error. I don't want to use 'when others' in my forms code. Please, give the code to do this as i have till now only used 'ON-ERROR' trigger with the following type of code
    DECLARE
    lv_errtype VARCHAR2(3) := ERROR_TYPE;
    lv_errcod NUMBER := ERROR_CODE;
    lv_errtxt VARCHAR2(80) := ERROR_TEXT;
    BEGIN
    IF lv_errcod = 40401 THEN
    null;
    END IF;
    END;
    I hope, my question is clear. Please help, in solving the doubt.
    regards.

    Re: Exception?

  • Error trapping for 'Save' dialog open?

    I'm writing a program which will do an extensive amount of work in Photoshop, and I'm trying to make sure it's as idiot-proof as possible. Before starting the image editing code, I want to make sure the user hasn't left any dialogs open in Photoshop, so I can show them a warning and cancel the application. I have found that attempting to get any properties of the application (e.g. version, document count, build, etc.) will throw an error if the user has the 'Open' dialog showing, but if they have the 'Save' dialog open, there is no error. Is there any reliable way to determine if the user has left Photoshop in a state where it will cause problems executing code?
    My script is currently written in Applescript, but will hopefully be someday rewritten in Javascript, so I'd be interested in any suggestions in either language with preference leaning towards Javascript.

    Well, they just keep on amazing me. And it doesn't seem like they went to any great lengths to do so either.
    During this 'exercise' I just kept thinking I'd eventually find something that would throw an error while the dialog was up...
    "Well, I shouldn't be able to do _____."
    "...well, I certainly won't be able to do _____..."
    "...ok, there's absolutely no way I would be able to ____."
    ...I thought being able to alter the document was bad enough - but you can even CLOSE the document you are trying to save from an external script!! ...and you are guaranteed a crash when you click the 'save' button at that point.
    The only thing I have come across so far which doesn't seem to work with the save as dialog open is opening another document. And even that doesn't throw an error - it just hangs the script (no change with 'try/on error...", no change with 'with timeout...")
    ...oh, well. It's almost 5:00 on a Friday. I think I'll just go home feeling defeated.

  • Error Trapping for reports

    I inserted a formula column and written an SQL statement which sometimes returns a value. But sometimes there is no data matches the criteria so no row is selected.
    In this case reports gives fatal error warning and stops. To get around this i wrote
    exception
    when no_data_found then null;
    i also tried
    if sql%notfound then null;
    None of this worked. Please help
    ps. it is a function which has to return a value.

    Hi
    May be the reason is that you doesn't return the value after exception. Try:
    WHEN no_data_found THEN RETURN ret_val;
    Andrew.

  • Error trapping a sound file

    Hi all
    Is it at all possible to test if a sound file has not been found? Every tutorial I have read regarding sound.loadSound and sound.onLoad has been focused on everything being fine and flash finding the correct file. I need to be able to get a flash movie to continue as normal if the sound file is unavailable.
    For example:
    My flash movie loads in a sound then waits for the sound to finish before continuing using the sound.onSoundComplete event. This wont work if the sound is not present, and so the movie stops and does nothing. I have tried to use sound.onLoad if (success == false) but flash seems to go here before it even starts loading the sound file, making my movie believe that no flash file is loading even though one is.
    Any help on this matter would be most grateful, a workaround would be even better
    cheers
    Ash

    Here is the code I am using:
    the variables soundAvail, point and endPoint are declared on another frame.
    var speech:Sound = new Sound(this);
    speech.onLoad = function(success:Boolean) {
    if (success) {
    speech.start(0,0);
    soundAvail = true;
    if (success == false){
    soundAvail = false;
    speech.loadSound("lesson2audio/02_00.mp3",false);
    here are the functions that control the movie:
    speech.onSoundComplete = function() {
    if (point == endPoint) {
    gotoAndPlay("end");
    } else {
    gotoAndPlay("point"+point);
    point++;
    function soundCheck():Void {
    if (soundAvail == false) {
    if (point == endPoint) {
    gotoAndPlay("end");
    } else {
    gotoAndPlay("point"+point);
    point++;
    soundCheck(); on the stop frame is called after all the animations are finished.
    At the moment all of this code does work apart from:
    if (success == false){
    soundAvail = false;
    which is called way to quickly.

  • SNMP trap on OutOfMemory Error Log record

    I would like to implement SNMP trap on OutOfMemory Error Log record.
    In theory SNMP LogFilter with Severity Level "Error" and Message Substring "OutOfMemory" should do the trick.
    In reality it does not work (doh)(see explanations below), I wonder if someone managed to make it work.
    Log entry has following format:
    ----------- entry begin ----------
    ####<Nov 12, 2003 3:09:23 PM EST> <Error> <HTTP> <ustrwd2021> <local> <ExecuteThread: '14' for queue: 'default'> <> <> <101020> <[WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception>
    java.lang.OutOfMemoryError
         <<no stack trace available>>
    ------------ entry end ------------
    Notice that java.lang.... is NOT part of the log record, yep it seems that exception stack trace is not part of log record! Thus filter could be applied only to "<[WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception>" string, which is really useless.
    Here is fragment of trap data (i had to remove Message Substring in order to get Error trap to work)
    1.3.6.1.4.1.140.625.100.50: trapLogMessage: [WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception

    Andriy,
    I dont think you could do much here, since Outofmemory is not part of
    log record SNMP agent cannot filter on this. I would be curious to hear
    if anyone got it to work using SNMP.
    sorry,
    -satya
    Andriy Potapov wrote:
    I would like to implement SNMP trap on OutOfMemory Error Log record.
    In theory SNMP LogFilter with Severity Level "Error" and Message Substring "OutOfMemory" should do the trick.
    In reality it does not work (doh)(see explanations below), I wonder if someone managed to make it work.
    Log entry has following format:
    ----------- entry begin ----------
    ####<Nov 12, 2003 3:09:23 PM EST> <Error> <HTTP> <ustrwd2021> <local> <ExecuteThread: '14' for queue: 'default'> <> <> <101020> <[WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception>
    java.lang.OutOfMemoryError
         <<no stack trace available>>
    ------------ entry end ------------
    Notice that java.lang.... is NOT part of the log record, yep it seems that exception stack trace is not part of log record! Thus filter could be applied only to "<[WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception>" string, which is really useless.
    Here is fragment of trap data (i had to remove Message Substring in order to get Error trap to work)
    1.3.6.1.4.1.140.625.100.50: trapLogMessage: [WebAppServletContext(747136,logs2,/logs2)] Servlet failed with Exception

  • Error propagation

    Hi,
    I'm having a bit of an odd problem in Forms10g with the propagation of an error. I'll describe what happens:
    I rightclick on an item, and select an action from a menu-item. In the code there is a call to a database package function where it is possible an application_error is raised (multiple values are possible, i'll use -20061 as example).
    The menu-item code has an 'exception when others' clause, which obviously traps this error.
    However...
    (note: We have forms6 versions of our forms, who then are converted to a 10g version. The problem does not come from this conversion, i only mention this because the problem occurs differently for both)
    In *6i*, the error is shown, though not correctly. The title of the alert would show the ora-number, but the message was also an ora-number, and not the expected message as was defined in the application_error. We then worked around this by trapping the code and message in a variable, using dbms_error_code and dbms_error_text, and showed these in an alert, faking the default behaviour.
    In *10g* however, no dice. dbms_error_code is 0, and error_text is empty, resulting in a neat empty alert. Without faking the behaviour, it seems as there occured no problems to a user (no alert).
    - i propagate errors trapped in 'when others' with RAISE
    - Removing the 'when others' clause results in normal behaviour, in both 6i and 10g, showing the correct oracode and message.
    - There was 1 more begin-exception when others-end block inside the main begin-end, i tried trapping the code/message there: no luck. Commenting out the 'when others': no luck.
    - I then put a begin-exception when others-end around the call to the DB-function. In the 'when other' i trapped the code and message: correct values! When doing this, the values are propagated further and the main exception when others then shows my own alert with the correct values (dbms_error_text and code then suddenly can trap the values...). Only by trapping the values into a dummy var (or outputting them) maintains their value it seems.
    I'm a bit bewildered:
    - Do i really need to go ahead and put a begin-end around each of my calls to this db-function, and trap the error_text once, to correctly propagate the error thrown there? I'd just like to shed some light on this.
    - How come a 'when others' blocks the correct working of the default alert?
    Thanks.

    Maybe can you tell me some usefull patterns?There's not much of a pattern here except for your (correct) MVC pattern.
    Imagine this: something in the Model goes wrong. You don't want this
    to pass by unnoticed. Your Model has no other way then throw an Exception.
    Your GUI is way too stupid to handle business logic (as it should be).
    So your Controller (the 'Logic') must handle the Exception, make the GUI
    display a nice retry/cancel dialog (that's what it's good at) and make the
    Controller try to solve the problem.
    kind regards,
    Jos

  • I'm running snow leopard. The try to open any .mov file in Quicktime, and I get an error message that says, "The document xyz.mov could not be opened. The movie is not in a format that Quicktime player understands. I'm a recent upgrade to Snow Leopard.

    I'm running snow leopard. The try to open any .mov file in Quicktime, and I get an error message that says, "The document xyz.mov could not be opened. The movie is not in a format that Quicktime player understands. I'm a recent upgrade to Snow Leopard.
    Help!
    Thanks, Mark

    Unfortunately, the error message gives no details about what codec might be missing or what it needs.
    If the file can't be opened in QT, it only means you cannot use the QT "Inspector" window to check what compression formats were used to create the file. It does not mean you can't use the Finder "Information" window to check on the compression formats or use a third party media information window (e.g., like VLC which will open many compression formats not supported natively by QT) to determine what kind of data is included in the MOV wrapper. If the file cannot be opened in any app, it is usually a good sign that the file itself is corrupted.
    It's a stupid error message. Apple should do better than that.
    Error trapping is quite extensive but there are still many areas which require human oversight. The message is telling you that either the container has a problem (e.g., not properly terminated, non-standard, or corrupted) or that one or more of the compression formats used is not supported by your current codec component configuration or that the data was encoded using non-standard settings or preferences not supported by QT or that the fourCC code does not match the data contained in the file or that there are timecode inconsistencies, etc., etc., etc. In short there are a near infinite number of possible problems for which it would be very difficult/nearly impossible to program error trapping depending on your sourcing of content and how you process it before it reaches the player app. Think of it like trying to play a BD disc in an DVD player.
    I'll call Apple support when I get a chance.
    Chances are good that they will end up sending you back here. In any case, it is often a good idea to post a sample file for examination by other QT users. At the very least, they should be able to tell you if the sample file will play on other systems which would indicate whether or not the file itself is bad and under the best of circumstances whould allow them to examing the file in detail for various common problems.

  • Report Document Preview Error

    Hi All,
    Please how do i resolve this following  error:
    The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.
    This comes up when i run my application online but doesn't occur when i run it during design.
    The application was developed with VS2010 with Crystal Report 2010, and hosted on a 64bit Window server 2008 Server.
    I have installed the both VS2010 and Crystal Report on the server with no result.
    Anyone, Everyone, please help.
    KayMan

    Hi Ludek
    I disabled the error traps in the app and this what the error reported in full. Any clue?
    Server Error in '/zamfara' Application.
    Retrieving the COM class factory for component with CLSID {4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
    ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically \ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
    To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
    Source Error:
    Line 41:         datAdapter.Fill(dsSet, SelectTable)
    Line 42:
    Line 43:         Dim CRS As New ReportDocument
    Line 44:         CRS.Load(ReportName)
    Line 45:         CRS.SetDatabaseLogon("sa", "Kayuzz1*")
    Source File: C:\inetpub\vhosts\estarsnet.net\httpdocs\zamfara\ReportPage.aspx.vb    Line: 43
    Stack Trace:
    [UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {4DB2E2BB-78E6-4AEA-BEFB-FDAAB610FD1B} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).]
       CrystalDecisions.CrystalReports.Engine.ReportDocument..cctor() +193
    [TypeInitializationException: The type initializer for 'CrystalDecisions.CrystalReports.Engine.ReportDocument' threw an exception.]
       CrystalDecisions.CrystalReports.Engine.ReportDocument..ctor() +44
       ReportPage.Page_Load(Object sender, EventArgs e) in C:\inetpub\vhosts\estarsnet.net\httpdocs\zamfara\ReportPage.aspx.vb:43
       System.Web.UI.Control.OnLoad(EventArgs e) +91
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Maybe you are looking for

  • [SOLVED] Forms Web - Works on IE and Chrome, firefox says it misses plugin

    Greetings, Both in IE and Chrome it works perfectly i open the Gin client through the same URL, ex: http://10.0.0.28:7778/forms/frmservlet?config=gin4 However if i try the same URL in firefox it shows a big grey square in the page saying "Click here

  • Address book sync not correct

    I sync my address book with both my . me account and via itunes with my iphone, also it appears in my bento and my bento on my iphone. all worked well till bento 3 (not sure this caused it, but timing is same as problem) now it does not sync anymore

  • Bookmarks not created when generating pdf

    Hello I am using 'robohelp for html' and generate pdf files as user guide from existing word format user guide. I import than and  create bookmarks for the TOC of the word user guide. Now I generate pdf. But the generated pdf file, do not show bookma

  • Can I get books from any other source than iBooks and read them in iBooks?

    I find that the iBooks Store list of titles is somewhat limited and some popular titles are not available. Can I purchase an ebook from another source, download it and then read it in iBooks? I have the iPad 2' my daughter has a Kindle but when it co

  • Adobe Creative Suite6 for mac

    Hi I downloaded ACS6. But how do I go on with it now when it is downloaded? The download has finished but it seems like not all is downloaded? I can't see the filesize as one usually does. Any advice? Thanks