#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    3
    Rep Power
    0

    simple form, simple trigger, whats wrong ??


    hi ...
    i am new to oracle and PL/SQL ...

    i have a problem in a form ...its a non database form which i created using developer 6i ...i have wrote the codes but its not running ... i am not really sure about the codes although its VERY SIMPLE ...

    this is the code

    begin
    if : pay.hours_worked<40 then
    : pay.gross=Houres_worked*hourly_rate;
    end if;

    if : pay.hours_worked>=40 then
    : pay.gross=Houres_worked (hourly_rate*1.5);
    end if;

    if : pay.radio='member' then
    : pay.fee= -20;
    end if;

    if : pay.radio='non' then
    : pay.fee= 0;
    end if;

    if : pay.list='ohio' then
    : pay.bonus=50;
    else
    : pay.bonus=100;
    end if;

    : pay.net=: pay.gross+: pay.fee+: pay.bonus;

    end;

    i am sure that the codes for the radio buttons and the list is wrong ... also i dont know what to chenge in the properties of the tools ...i only change that database items into No ...

    please could anyone help me with this and tell me what is wrong ...

    i have attached the form i created
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Canada
    Posts
    308
    Rep Power
    11
    Try to use NVL function to calculate net payment, like that:


    : pay.net= NVL(: pay.gross,0)+NVL(: pay.fee,0)+NVL(: pay.bonus,0);

    The basic idea to use NVL function with numeric fields is, if numeric field does not contain any value then initialiaze it by 0. If you dont do it and try to use add, multiply, subtraction NULL with any value the result will be NULL. Let see the following example :
    Total := a + b + c;

    Here ,

    a= 10
    b = 40
    c = null

    what it should return? hmmm, you might think it should return you 50 but it will return NULL.

    If this does not resolve your problem then let me know. how did you defined this procedure? I mean as a trigger in form, or as a program unit in form etc.


    Regards
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    3
    Rep Power
    0
    hi dear shafique

    thanx for ur replay ...i apreciate it ...

    i have attached the form if you would like to check it for me ...

    i have done all what u have mantioned but it still gives me error ...
    Attached Files
  6. #4
  7. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Canada
    Posts
    308
    Rep Power
    11
    Ok, you need to define the initial value for the radio button, to do this double click on the RADIO item then select 'initial value' option under 'Data' node from its property pallete, and assign the value that should by either 'non' or 'member' (case restriction applied). Now pick up the one radio button 'NON' go to its property pallete, then select 'radio button value' option under the 'funtional' node, select another radio button 'MEMBER' goto its property and select 'radio button value' under 'functional node and aasign it to value 'member.
    also you should use NVL function with the numeric fields whenever you are performing calculations.

    I have also attached the modified for you to take a look.


    Regards
    Attached Files

IMN logo majestic logo threadwatch logo seochat tools logo