Entering Characters into Numeric Field

Let's say I want to add two numbers with parameters num1 and num2. Now, I want to make sure the user does not enter characters or symbols. If they do I wan to throw an exception. Does anyone know how to do this?
declare
v_num1 number := p_num1;
v_num2 number := p_num2;
v_results number;
begin
if user enters an alphabetic field or symbol
raise error
else
v_results := v_num1 + v_num2;
...

No real application should be using SQL Plus as its user interface! And as I said in my first reply, it is no good assigning the values to the variables in the DECLARE section if you want to catch exceptions.
Here is some fully working code:
SET SERVEROUTPUT ON
ACCEPT p_number1 PROMPT 'Enter a number: '
ACCEPT p_number2 PROMPT 'Enter another number: '
DECLARE
  v_number1 NUMBER;
  v_number2 NUMBER;
  v_results NUMBER;
BEGIN
  v_number1 := '&p_number1.';
  v_number2 := '&p_number2.';
  v_results := v_number1 * v_number2;
  DBMS_OUTPUT.PUT_LINE('Result='||v_results);
EXCEPTION
  WHEN value_error THEN
    DBMS_OUTPUT.PUT_LINE('Invalid entry. ');
END;
/

Similar Messages

  • Auto populate text fields with a trigger such as entering text into input fields in ADF

    Hello all,
    I am not able to auto populate text fields with a trigger such as entering text into input fields in ADF.
    I tried AdfFacesContext.getCurrentInstance().addPartialTarget(val); in the back end using setter method of input text field.
    its not working ..
    is there any way to achieve it
    Regards,
    Shakir

    Hi,
    Always mention your JDev version.
    The valueChangeListener would fire only when you set the autoSubmit property of the field to true. Can you elaborate your requirement? What do you mean by related data? Are you performing some sort of search?
    If you want to get the value you entered on the field, just set autoSubmit to true and get the new value from the valueChangeListener. If your requirement is something like as and when you type, do something, you need to check out this approach :https://blogs.oracle.com/groundside/entry/auto_reduce_search_sample
    -Arun

  • Using numberd buttons to enter text into a field

    Hi all, was wondering if I had 10 seperate sprites acting as
    buttons on a page, which will be numbered 0 -9, is it possible to
    use them to enter text into a field. e.g.
    If the user presses the sprite with a number 1 on it, would
    it be possible to have a 1 displayed in an edit field. I need to
    pretend as though im using a remote.
    thanks

    You can create a behavior that will allow you to set a
    variable for each
    button. When you assign the behavior to your button sprite,
    it'll
    prompt you to enter the ButtonNumber property. Haven't tested
    this yet,
    but something like this should work:
    global gNumberEntered
    property ButtonNumber
    on getPropertyDescriptionList
    description = [:]
    addprop description, #ButtonNumber, [#comment:"Enter number
    to assign
    to this button", #format:#integer, #range:[1,10], #default:
    1]
    return description
    end getPropertyDescriptionList
    on mouseup
    sprite(the currentSpriteNum).member = member("buttonOver")
    gNumberEntered = ButtonNumber
    cursor -1
    end
    on mouseEnter me
    sprite(the currentSpriteNum).member = member("buttonOver")
    cursor 280
    end
    on mouseDown me
    sprite(the currentSpriteNum).member = member("buttonDown")
    end
    on mouseLeave me
    sprite(the currentSpriteNum).member = member("buttonUp")
    cursor -1
    end

  • How to prevent a user from entering characters into a number field

    How do you prevent a user from entering characters like A or B into a field that is defined as a numeric field?
    Please note that
    - we use block validation (for other reasons)
    - we are not able to convert these numeric fields to character fields
    We want to avoid a user being hasseled with the FRM-40209 ... message.
    This message is
    - not very helpfull because it does not inform us what the problem field is
    - not suppressable
    Any hints ?

    I went back to the drawing board on this one.
    You are absolutely right : the message can be catched !
    By writing an on-error trigger you can check for the error number. Sadly enough my first attempt on this used the on-message trigger which never fired hence my desperation.
    Anyway, the on-error trigger in combination with :SYSTEM.CURRENT_ITEM or :SYSTEM.TRIGGER_ITEM enables me to display a more meaningfull message to my users.
    Thanks for the hint.

  • Entering Zero in Numeric Fields

    Can someone please help me as to how to format a numeric field to
    enter '0'.
    e.g. a client enters 0122
    How do I format the diplayed text to be 0122.

    To get rid of the separators have to select "integer" for the fields format (see binding palette).
    How long are the numbers a user can enter to the field?
    A pattern can only match one case.
    So num{9999999} will display 121587 as 0121587 and 123 as 0000123.
    If you want a leading zero to every entry then you will need scripting.

  • Safari crashes when entering text into entry fields

    I recently bought a MacBook 2.0 (White) and have set up accounts for multiple family members. On one (standard) account, Safari immediately crashes as soon as you try to enter text into an entry field, e.g. to do a search on Google or Yahoo. I've already tried dragging the Safari pref files to the desktop and icon files to the desktop and rebooting both Safari and the entire machine with no success. However, if I log onto any of the other accounts, Safari works fine. Initially, (for about two weeks), it worked fine, it just started acting like this recently. Toggling Java and Javascript off, also doesn't solve the problem. I'm about to create a new account and trash this account entirely, but I was wondering if anyone has seen this problem and knows what's gone wrong.
    2.0DualG5, 15"PBook1.5, MacBook2.0   Mac OS X (10.4.6)  

    Thanks Yang, you pointed me in the right direction. I was able to edit and delete items in the Autofil - Other Forms, but when I tried to do the same thing on the Autofil - Address Book Card, it crashed immediately. Further investigation showed that if I tried to open any applications related to the Address Book like Mail or Address Book itself, they immediately crash also! This is kind of weird because this account hasn't been set up for Mail and as far as I know there are no entries in the Address Book. If I uncheck "Using info from my address Book card", Safari doesn't crash, so now it looks like the problem originates from Address Book or possibly Mail.
    RadiCal

  • Enter Data into Two Fields At Once

    This seems like it should be simple, but I can't find anything on it. I'm creating a fillable pdf, and I need the data from one text field to appear in another text field.
    Example: The form has two sections, one for the applicant to fill out and one for office use only. There is a field for "Project Address" in both sections. The client wants the address entered in the first field to be automatically populated in the second address field.
    How do I make that happen?

    If you give both fields the same name, they will automatically have the same value. But if you want the second field to be editable independently of the first address field, you can use the following custom Validate script for the first field. It will set the second field's value to the same as the first if the second field is blank.
    // Custom Validate script for text field
    (function () {
        // Get a reference to the second field
        var f = getField("ProjectAddress2");
        // Set the second address field to this field's value, if it's blank
        if (!f.valueAsString) f.value = event.value;
    Replace "ProjectAddress2" with the actual name of the field.

  • CONCATENATE a string a characters into a field

    Hi everyone!
    Let's say that i want to CONCATENATE a string of characters (for example: 'ABC') into every WTAB-AUFNR record that i retrieve. How do i do that?
    Let's assume that WTAB-AUFNR's header currently has the value '50-12345', i want it to be 'ABC50-12345'.

    I've got another CONCATENATE question. Here it is:
    Let's say i wanna have the values in CTAB-WTJHR to be in brackets, which i am going to hardcode by doing a CONCATENATE. So it should work if i write it like this:
    DATA: BEGIN OF CTAB OCCURS 0,
          LEDNR LIKE BPJA-LEDNR,  "Ledger
          OBJNR LIKE BPJA-OBJNR,  "Object Number
          TRGKZ LIKE BPJA-TRGKZ,  "Object Indicator
          WRTTP LIKE BPJA-WRTTP,  "Value Type
          GJAHR LIKE BPJA-GJAHR,  "Fiscal Year
          VERSN LIKE BPJA-VERSN,  "Version
          VORGA LIKE BPJA-VORGA,  "Budget Type
          TWAER LIKE BPJA-TWAER,  "Transaction Currency
          WTJHV LIKE BPJA-WTJHV,  "Original Budget
          WTJHR LIKE BPJA-WTJHR,  "Amount Utilised YTD
          V_BEFORE TYPE I,             "Balance Before This Request
          V_CURRENT TYPE I,            "Current Acquisition Cost
          V_BALANCE TYPE I,            "Balance Variation
          END OF CTAB.
    SELECT SINGLE LEDNR OBJNR TRGKZ WRTTP GJAHR VERSN VORGA TWAER WTJHV
    WTJHR
      INTO CTAB
      FROM BPJA
      WHERE OBJNR = WTAB-AUFNR AND
            WRTTP = '42' AND
            GJAHR = ITAB-LFDAT+0(4).
    APPEND CTAB.
    LOOP AT CTAB.
    CONCATENATE '(' CTAB-WTJHR ')' INTO CTAB-WTJHR.
      MODIFY CTAB TRANSPORTING WTJHR.
    ENDLOOP.
    I've looked through it and i can't find any syntax problem or anything else but i keep getting this message when i try to activate my program: "CTAB-WTJHR" must be a character-type data object (data type C, N, D, T or STRING). field string". When i looked at SE11 and i found out that the WTJHR field in BPJA is a type CURR. Is there a way to solve this?

  • I just upgraded to Firefox 17.0.1 and now I am unable to entered anything into text fields.

    After upgrading to Firefox 17.0.1 text cannot be entered in either the URL bar, the search bar, or any text boxes/input fields/forms on webpages. When the text field is clicked the cursor is positioned properly and blinks but typing generates no text.

    Hello hj21c1yg, check it in [https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode#os=win7&browser=fx17 Safe Mode], in Safe Mode window select '''''"Start in Safe Mode"''''' and see if this happen again, '''''if not''''' see: [https://support.mozilla.org/en-US/kb/troubleshoot-extensions-themes-to-fix-problems#os=win7&browser=fx17 Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]
    thank you
    Please mark "Solved" the answer that really solve the problem, to help others with a similar problem.

  • Turning Specific Char Characters into Numerical Values

    Hello Everyone,
    I was wondering if it is possible to turn a 'Y' char character into a number 1 and turn a 'N' char character into a 0?
    Thanks in advance,
    -N.S.N.O.

    Say for example i want to convert back to 'Y' and 'N'. Where 0 = 'N' and >0 = 'Y'. Would that be possible?
    I have tried
    case source
      when source>0 then 'Y'
      when 0 then 'N'
    endand
    decode(source, source>0, 'Y', 0, 'N')Thanks in advance,
    -N.S.N.O.

  • Preferance pane window keeps popping open when entering search or data into any fields. I'm also using 1Password and it happens when trying to enter a password

    I'm running on Mac OS X 10.7.4, Firefox 14.0.1. This issue didn't exist until this most recent Firefox update. Basically, a preference pane opens every time data is being entered into a field. It doesn't seem to be the same preference pane that you see when you open the preferences through the normal Firefox access ie. Firefox > Preferences. All of the choices listed in this particular preference pane are specific to Firefox though. I have a screen capture that I could include if wanted. When using 1Password the pane appears, when entering a search in the search bar near the address bar the pane pops up, when entering data into any field as I am now filling in this detail report the pane also pops up. It's quite annoying. Any advice? I'm going to systematically attempt to quit any add-ons and see if that makes a difference. I ave already tried doing a reinstall to no avail.

    I think a screen shot would be helpful. There is a box below the compose area of a reply to upload files.

  • Cannot insert Chinese character into nvarchar2 field

    I have tested in two environments:
    1. Database Character Set: ZHS16CGB231280
    National Character Set: AL16UTF8
    If the field type of datatable is varchar2 or nvarchar2, the provider can read and write Chinese correctly.
    2. Database Character Set:WE8MSWIN1252
    National Character Set: AL16UTF8
    The provider can not read and write Chinese correctly even the field type of datatable is nvarchar2
    I find that for the second one, both MS .NET Managed Provider for Oracle and Oracle Managed Data Provider cannot read and write NCHAR or NVARCHAR2 fields. The data inserted into these fields become question marks.
    Even if I changed the NLS_LANG registry to SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280, the result is the same.
    For the second situation, only after I change the Database Character Set to ZHS16CGB231280 with ALTER DATABASE CHARACTER SET statement, can I insert Chinese correctly.
    Does any know why I cannot insert Chinese characters into Unicode fields when the Database Character Set is WE8MSWIN1252? Thanks.
    Regards,
    Jason

    Hi Jason,
    First of all, I am not familiar with MS .NET Managed Provider for Oracle or Oracle Managed Data Provider.
    How did you insert these Simplified Chinese characters into the NVARCHAR2 column ? Are they hardcoded as string literals as part of the SQL INSERT statement ? If so, this could be because, all SQL statements are converted into the database character set before they are parsed by the SQL engine; hence these Chinese characters would be lost if your db character set was WE8MSWIN1252 but not when it was ZHS16CGB231280.
    Two workarounds, both involved the removal of hardcoding chinese characters.
    1. Rewrite your string literal using the SQL function UNISTR().
    2. Use bind variables instead of text literals in the SQL.
    Thanks
    Nat

  • Entering Scandinavian characters into AWT TextField

    I have a problem entering Scandinavian characters, ���, into AWT textfields. All I get is squares. The entered text, sent to a database, is not stored correctly either, so it is not just a display problem.
    But then, I can copy-paste (both select - middle button, and ctrl-c - ctrl-v) these characters without problems, both from other fields within the application and from other X11 applications.
    This is on Linux, I do not have a possibility to test on Windows.

    You can also use KeyListener. You can also search the forum as this question has been asked numerous times.

  • I'm having the oddest situation...  On my 13" MBP, when trying to enter text into a Facebook comment box; my delete key is totally non-functional.  I works just fine everywhere else, just not in the comment box.  Cannot delete characters.

    I'm having the oddest situation.  When I attempt to enter text into a Facebook comment box, my "delete" key doesn't work.
    It's just fine EVERYWHERE else, I just cannot delete characters from a comment box.
    What might I be missing?  I don't know what's up.
    JP
    MacBook Pro Retina 13"
    Safari 8.0.2
    Yosemite 10.10.1

    I'm having the oddest situation.  When I attempt to enter text into a Facebook comment box, my "delete" key doesn't work.
    It's just fine EVERYWHERE else, I just cannot delete characters from a comment box.
    What might I be missing?  I don't know what's up.
    JP
    MacBook Pro Retina 13"
    Safari 8.0.2
    Yosemite 10.10.1

  • Two fields, two scripts. User can enter data into field 1 or 2

    Hi all,
    New here, and to acrobat forms, so please bear with me!
    What I'm trying to achieve is a form that calculates total invoice value, based on a total number of hours worked, and a rate. The user fills in the total hours, but then the problem is that some people know their fixed rate, and others have a changing rate. Those with a changing rate simply know the amount they are invoicing for. What I'd like, is a way for the TotalInvoice value to be calculated by Rate*TotalHours when the user enters a value into the Rate field... OR ... for Rate to be calculated by TotalInvoice/TotalHours when the user enters a value into the TotalInvoice field.
    I can make it go one way or the other (so the script is only in TotalInvoice field or the Rate field), but I can't manage to get it to go both ways. Is this possible?
    To summarise: User can enter manually into Field1 and value of Field2 is calculated, or user can enter manually into Field2 and Field1 is calculated.
    Thanks!

    What you propose can be difficult, becuase you're describing a circular reference between the two fields. When the 1st value changes, you want the 2nd value to be calculated based on the 1st value. But when the 2nd value changes, you want the 1st value to be calculated based on the 2nd, ad infinitum. There are ways to short-circuit the loop, but it depends on whether you need to do the calculation only when there is manual entry, or whether you need it to work when either field value changes programmatically or by importing form data.
    Sometimes it's just easier to have the user press a button to calculate and set the other field value.

Maybe you are looking for

  • Installed Flashplayer 11, but Macromedia 8 defaults & doesn't work

    Please read this carefully as I'll try my best to explain my problem.  It's complicated! I have IE 8 and Microsoft Windows XP (Home Edition)  32bit (-86) First I deleted all prior versions of Flash Player on my computer.  This started out by me tryin

  • Jndi name conflict found in

    I have received a naming conflict when starting up App Server 7. I am using the Sun Studio Enterprise. The abstract schema name for the entity bean is Billercenter and everywhere else that the bean is referenced is billerCenter. I am thinking that th

  • Restrict WebI data sources

    Hi All, Is it possible to restrict data source access to a particular set of users in webi? For example: User A should see only excel as a data source. User B should see only Bex And so on. Thanks Vinayak

  • [iPhone] Autorotation and Problem Resizing UIWebView

    I'm loading a UIViewController with a UIWebView embedded in it. However, the UIWebView doesn't always resize correctly. Here are the steps I follow: a) I view the UIWebView in portrait mode... b) I autorotate to landscape mode... c) I load a new HTML

  • Verizon neglects Palm Pre?

    I would love to use the NFL Mobile app on a palm pre plus. Why does Verizon neglect the Pre and give everything to Droid? If the sales person would have told me that the Pre was the red headed step child I would have went Droid. What gives???? Post r