Faced with the difficulty to obtain the logic...

Hello..
I have a table called rate that contains...

RATE
PERKM FROMKM TOKM

0 0 15
2 16 100
1 101 300

Now, I want to create a procedure with the distance as a parameter and fareamount as OUTPUT parameter...

I tired logical creation for her... I managed, but whenever a user enters a new record in the table of rates... the logic below does not work...

3 301 400


PROCEDURE get_fare_amount)
v_i_ndistance IN route_master.ndistance%TYPE,
v_o_nfareamount ON fare_Master
)
AS
CURSOR c1
IS
SELECT nrateperkm, nfromkm, ntokm
OF fare_master
WHERE v_i_ndistance > = nfromkm AND nactive = 0;

nrate NUMBER;
fromkm NUMBER;
tokm NUMBER;
tot (NO.2): = 0;
BEGIN
FOR temp IN c1
LOOP
IF v_i_ndistance > = temp.nfromkm AND v_i_ndistance < = temp.ntokm
-If distance between fromkm tokm n...
THEN
IF = 2 tot
-If total archives digitized is 2... to get the rate and km for previous record...
THEN

-For the 100 first kms use 2 perkm rate and for remaining kms we 1rs perkm.
v_o_nfareamount: =.
(((v_i_ndistance-tokm) * temp.nrateperkm))
+ (nrate * (tokm))
);
ON THE OTHER
v_o_nfareamount: = v_i_ndistance * temp.nrateperkm;
END IF;
END IF;

tot: = tot + 1; -To get the number of records
-To store values of the last record analyzed variables
nrate: = temp.nrateperkm;
tokm: = temp.ntokm;
END LOOP;

Dbms_output.put_line (' Total fare for ")
|| v_i_ndistance
|| "" kms:-".
|| « R. »
|| v_o_nfareamount
);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
Dbms_output.put_line ('NO DATA FOUND');
WHILE OTHERS
THEN
Dbms_output.put_line (SQLERRM);
END get_fare_amount;

The logic that I gave took:
-The rate for the first 15 km 0
-The rate of 2 for between 16 and 100 km
-The rate of 1 for between 101 and 300 km
-The rate of 3 km between 301 and 319

Easy you need?

your sample data said rate = 0 for the first 15kms and not rate = 2 for the first 100 km as you said later.
For me, it would be:

Scott@my11g SQL>exec :nbkm := 303 ;

PL/SQL procedure successfully completed.

Scott@my11g SQL>with fare as (
select 0 perkm, 0 fromkm, 15 tokm from dual
union all select 2,16,100 from dual
union all select 1,101,300 from dual
union all select 3,301,400 from dual
)
select :nbkm nbkm, sum(perkm*(least(:nbkm,tokm)-fromkm)) total
from fare
where tokm <= :nbkm
or (fromkm <= :nbkm and :nbkm<=tokm)
/ 

      NBKM      TOTAL
---------- ----------
       303        373

373 = (rate0 * (15-0)) + (naturel2 * (100-16)) + (rate1 * (300-101)) + (revenu3 * (303-301))

Tags: Database

Similar Questions

  • faced with the front camera

    When the superior auto mode, you can not use hdr for the rear camera. But faced with the camera before the automatic mode allows you to choose hdr in the settings. Is this a bug problem or software?

    This isn't a bug. Unfortunately, the HDR is not available in this mode. If you want to use HDR for the rear camera, you must use the manual mode.

  • Problem connecting to the server by using the url with the logical name!

    Hi all!

    I looked for information on this subject, but have not seem to found a solution.

    I'm developing a Smartphone application that needs to connect to a server to retrieve data. Then I use a direct connection with the correct settings (I hope):

    URL = "url of the server" + "deviceside:true" + "AFN:...» »

    The problem is that the connection should be done without Hardcoding the "apn". These are the tests I've done so far (assuming I'm always add the ' deviceside: true ' parameter):

    URL (logical name) + AFN OK!
    FAILURE of the URL (logical name)
    URL (static IP) OK!

    * by logical name, I mean a url as www.google.com

    What I need is to use the logical name, without the parameter apn!  Maybe I'm missing another parameter that I don't know?

    Some additional info that might be useful! :

    -The server is a server of Vodafone, which, as has been explained to me, should be on the list of white of the RIM (not sure what that means, but I guess it has to do with the fact that BB connection through the RIM at one point servers, and be in this list gives a sort of 'privilege' when you browse servers of RIM) , and I don't know it is publicly accessible as (see following)

    -An android version of the application works fine without Hardcoding the AFN and using the logical name (I guess it has to do with the RIM servers!)

    Any help or ideas towards the solution that it is greatly appreciated!  If I'm missing some info that you think I should add! Please tell me!

    Thanks for your help!

    Juan

    Thanks Peter!

    I could solve it by looking at the code of the alternative of the Api network in the link sent you me!

    The solution was the addition of the ConnectionUID parameter to the url String!  as to why this solves the problem I still don't understand it! (If you can enlighten me with the reason, I would be very grateful)

    This value is found in the service books!, I have the zip code just in case it helps someone!

    Hogshead string = null;

    Full book sb = ServiceBook.getSB ();

    Reviews [] ServiceRecord = sb.getRecords ();

    for (int i = 0; i)< records.length;="">

    {

    String cid = records [i] .getCid () .toLowerCase ();

    String uid = records [i] .getUid () .toLowerCase ();

    If ((cid.indexOf ("wptcp")! = - 1) & (uid.indexOf ("wifi") ==-1) & (uid.indexOf ("mms") ==-1))

    {

    Hogshead = records [i] .getUid ();

    }

    }

    then add the parameter: ConnectionUID = Hogshead

    Once again, thank you!

  • Faced with the question to URI on jsp page

    I have a URI on my JSP and I found the tld with jar. JSP and tld has same URI but I get the following error

    Error (3.5): no tag library could not be found for this URI. Possible cause could be that the URI is incorrect, or there are errors during the analysis of the .tld file.

    In JSP, it looks like this

    < % @ taglib uri prefix = "http://xmlns.oracle.com/adf/faces/rich' = 'af' % >

    and tld sound like that

    tlib < version > 11.1.2.3.0 < / tlib-version >
    < short name > af < / short name >
    < uri > http://xmlns.oracle.com/adf/faces/rich < /uri >

    I'll you give more details for my application, see currently, I'm working on the kind of the migration of the thing, my current application is in JDEV TP4 and we use now ADF R1(release 1) jar with the same directory structure, I'm going to migrate my application with JDEV last 11.1.2.3.0 and I need to use the library with this last JDEV R1 not R2 , I tried with R2 I am able to resolve the error, but my requirement is that I must use R1 with JDEV last, and I am facing this error... what approach I need to follow it please suggest me... and also in the IDE, we can add jar from anywhere...

    Thanks in advance.

    Published by: 982899 on January 20, 2013 22:35

    Hello
    Check project properties > JSP tag libraries.
    more likely is that you have lost the library.

    You can´t use the libraries of adf R1 R2.

  • Faced with the question while with ATG Cybersource integration

    Hi all

    I am facing problem with address verification while integrating cybersource with ATG.
    Any integration with cybersource is still work correctly.

    If I used addressVerificationProcessor VerifyOrderAddresses and mention to use CyberSourceAddressVerify, I get the error associated with the below houseno. box not found
    addressVerificationProcessor = / atg/commerce/payment/CyberSourceAddressVerify

    Can someone help me on this please.
    It's urgent. Pls let me know if need more details
    TIA,
    MILIN

    Error log:

    12:03:01, 992 INFO [ShoppingCartModifier] DEBUG 0 gifts to collect there
    12:03:01, 993 INFO [ShoppingCartModifier] DEBUG add order credit card
    12:03:02, 075 INFO [ShoppingCartModifier] DEBUG error form - stay on the same page.
    12:03:04, 942 INFO [CyberSourceAddressVerify] DEBUG - request-
    12:03:04, 946 INFO [STDOUT] ship_to_state = CA
    bill_state = CA
    ship_to_city = San Jose
    bill_city = San Jose
    bill_country = we
    bill_zip = 95131
    ship_to_country = we
    ignore_avs =
    merchant_id = mykkaushik
    bill_address2 =
    ics_applications = ics_dav
    ship_to_zip = 95131
    bill_address1 = 1, Main Street
    ship_to_address2 =
    client_lib_version = Sun Microsystems Inc./1.6.0_31/Windows 7/6.1/-/Java/5.0.3
    ship_to_address1 = 1, Main Street
    merchant_ref_number = pg460011
    12:03:06, 320 INFO [CyberSourceAddressVerify] DEBUG - response -
    12:03:06, 320 INFO [STDOUT] dav_rcode = 0
    ics_rcode = 0
    ics_rmsg = number of House/box found on the street.
    request_id = 3539115850040180464524
    dav_us_info = S00000
    dav_us_error_info = E421
    request_token = AhijLwSRf7YylSTvL7cYIJ + 1EEDyqAJGlwtJMsXXwMhEAAAA/ED@BGF7'¢
    dav_rflag = DINVALIDADDRESS
    ics_rflag = DINVALIDADDRESS
    merchant_ref_number = pg460011
    dav_rmsg = number of House/box found on the street.
    12:03:06, 364 PipelineError DEBUG INFO [ShoppingCartModifier]: key = InvalidAddress; error = {pg460011 = home
    12:03:06, 367 INFO [ShoppingCartModifier] DEBUG add form exception: InvalidAddress: House/box number
    12:03:06, 367 DEBUG INFO [ShoppingCartModifier] origin of exception: null
    12:03:06, 368 INFO [ShoppingCartModifier] DEBUG Transaction marked as Rollback - redirect to: billing
    12:03:06, 369 DEBUG INFO [ShoppingCartModifier] afterSet sees currentTransaction TransactionImple < a
    nStatus.ABORT_ONLY >
    12:03:06, 369 INFO [ShoppingCartModifier] DEBUG afterSet validation transaction TransactionImple < ac, B
    TUS. ABORT_ONLY >
    12:03:06, 494 INFO [ShoppingCartModifier] DEBUG released the local write lock using id 270000

    There is a problem with the entry that you gave in the field: House / box

    Cybersource error return:
    Home/box number found on the street.

    could you please valid number here who is the number waiting to Cybersource service.

  • Faced with the installation of XP SP3 and XP SP2 on HP mini 210

    Hello

    I followed the steps on my computer, HP mini 210, which was completely unusable:

    (1) Mini Partition Master tool used to boot the system.

    (2) remove all partitions, including HP recovery and everything.

    (3) create a new primary partition NTFS and label c.

    (4) restart the system with the bootable XP SP3 or SP2 CD.

    (5) Windows copies all the files and go to "Start Windows"

    ((6) I select one) to install a new Windows XP

    After that XP is not able to identify the partition on the hard drive. It says no hard drive detected or something it starts and asks to press F3 to exit.

    I tried to enter F9 at startup, and it does not show the hard disk; I mean that the HARD disk is not damaged or corrupted.

    Can you get it someone please let me know what to do?

    Hello:

    You must integrate the NM10 chipset Sata driver controller that I zipped and attached below, then XP installs fine.

    Info on how to integrate the driver, please read the guide at the link below, read the Intel section, and read the document that is "slipstreaming" all drivers from Intel.

    http://h30434.www3.HP.com/T5/notebook-operating-systems-e-g-Windows-8-and-software/SATA-drivers-for-XP-solution-on-0x0000007B-BSOD/m-p/114120#M17758

  • Faced with the simple series comms

    Hi all - summer tweak something that should be simple for hours now, so I'll ask for help...

    I have a RS485 device connected to COM5 via a USB adapter, work at 9600 baud, 0,8,1, no - fundamentals of series. I can talk to the device using the terminal software native and even using hyperterminal with the above parameters. It seems obvious, and so I thought that LabVIEW and VISA would connect without too much effort.

    So I use the following simple sequence into LabVIEW:

    -VISA set up the serial port, 9600,0,8,1, none (no error)

    -VISA defined the size of buffer, 4096 with a mask of 48 (no error)

    -Stamps of Ras VISA, the two buffers (no error)

    -VISA write, chain of command is 'PR C2\r\n", which should be echoed and return a numeric value (normally 0)

    -check the bytes to the port property; returns 12

    -VISA read, returns the string of command only, 7 bytes

    why I can't read the full buffer?

    To be honest, I thought that it will work only with a trivial series program: set-read-write. But which still generates an error. I added the size of the buffer since then do a little research and makes without error at least, if not in one of the published examples.

    I don't think it's a matter of time, since I add a lot of late, when I'm debugging, and I tried to put delays read before. The fact that the number of bytes in the buffer is 12 seems to indicate that my answer is here somewhere...

    I also tried a second reading, but it returns nothing.

    Kind regards

    Lamb

    Just disable the tank of the termination.

    This is the reason why you get only one line.

    Or do a second reading at the end.

  • Faced with the form validation

    I tried a few days get my code works but I'm not entirely understand error messages.

    I want to do what follows but can't make it work:

    1. validate the fields defined and checkboxes

    2. Enter personalized messages to find errors in a table

    3 display an alert detailing any errors

    If the fields contain data and the checkboxes checked;

    4. save the form in a temporary folder with the name of requisition -' + this.getField("workOrderNumber") //(which contains a javascript script autonumbering)

    5. If all required is supplied attach the form to an email as provided for in the background code

    Event.RC = true;

    msgArray = new Array (errorMsg [0], errorMsg [1], errorMsg [2], errorMsg [3], errorMsg [4] errorMsg [5], errorMsg [6], errorMsg [7]);

    If (this.getField("workOrderNumber").value = "")

    {

    errorMsg [0] = ' you can not pass without an application number, please click in the field to the right top of the page to generate a number. "

    }

    ElseIf (this.getField("DelAddressRow1").value = "");

    {

    errorMsg [1] = 'Please enter the full delivery address;

    }

    ElseIf (this.getField("DeliveryContactName").value = "");

    {

    errorMsg [2] = "Please enter the contact of delivery."

    }

    ElseIf (this.getField("SupplierNameRow1").value = "");

    {

    errorMsg [3] = "Please enter the full name of the proposed supplier."

    }

    ElseIf (this.getField("SupplierAddressRow1").value = "");

    {

    errorMsg [4] = 'Please enter the street number, name and type. "

    }

    ElseIf (this.getField("SupplierAddressRow2").value = "");

    {

    errorMsg [5] = 'Please enter the suburb, State, and postal code. "

    }

    ElseIf (this.getField("SupplierContactName").value = "");

    {

    errorMsg [6] = 'Please enter the name of the supplier contact. "

    }

    ElseIf (this.getField("SupplierContactTelephone").value = "");

    {

    errorMsg [7] = "Please enter the phone number of suppliers."

    }

    else if (msgArray! == "");

    {

    var msgArray = 'there were some mandatory fields, you need to complete...\n ";

    for (var i = 0; i < errorMsg; i ++) {}

    numError = i + 1;

    MSG += "\n" + numError + "". "" + errorMsg [i];

    }

    Alert (MSG);

    }

    on the other

    {

    var cToAddr = [email protected];

    var cReqNum = this.getField("workOrderNumber").value;

    var cSubLine = "request:"+ this.getField("workOrderNumber").value; "

    var cbody = "thank you for submitting your form. \n' + 'save the attachment of the completed form for your records.

    Send the PDF as an attachment to an e-mail

    this.mailDoc ({bUI: true, cTo: cToAddr, bassujetti: cSubLine, CMSG: cbody});

    }

    OK, that makes more sense. The piece of information you miss, it's that the default value of a checkbox when it is not checked (a group or, if none are selected) is 'Off '. Another thing that you're doing wrong is your stop"" command. There is no such thing in JS. If you want to stop a bidding process then it should be part of the script. You can't stop a command to "Submit a form" (not directly, at least, you can stop it by clearing a required field).

    If your code should be something like this:

    if (this.getField("WO").value=="Off") {
        app.alert("Please check a checkbox");
    } else {
        this.mailDoc({cTo: "[email protected]"}); // replace with actual email address
    }
    
  • Faced with the hard disk installer...

    Hey, this is my first post.  I tried the trawling through the various forum posts, and other Web sites and videos however I am having a bit of trouble to the where I want to go regarding them have Windows Home Server up and it works perfectly in ESXi.  I have attached a diagram of installation old as running WHS on my HP Server but I wanted to upgrade to WHS 2011, I had and I thought that it is the best time to try virtualization as well.

    I have a physical machine with 3 hard disks.  1 x 250 GB, 1 x 2 TB and 1 x 100GB.  I intend use the 250 GB HD to install my s VM, IE.  WHS 2011 (already completed and running), Linux, XP etc.  However, what I want to do, is when you are logged in WHS, I want to be able to store all my music, photos, media, etc., on the 2 TB drive and to be able to access them in not only WHS, but other BONES as well.  I've read about RDM however, I get nowhere with her.

    On my old configuration, I also had a few runnign programs that would automatically download episodes of TV series for me and place them on the 100 GB hard drive, which was not part of the pool of storage in WHS.  I would then move them manually in the actions concerned.  Basically, I want to be able to do all this in the virtual environment.

    The scene, I am at this time, is that I have esxi installed with WHS 2011 installed on the hard drive of 250 GB.  I can log on and get the WHS Office ETC.

    Can someone help me with this?

    http://img638.imageshack.us/img638/8875/esxi.jpg

    Welcome to the VMware forums communities.

    With the RDM vSphere client are limited to SAN lun.  For a local SATA device, you'll want to use this method - http://vm-help.com/esx40i/SATA_RDMs.php.

  • Yet faced with the contact form

    Hey DWers-

    From another thread, I've added form osgood (thanks for posting that). The form appears on the page, but does not work and I do not know because I macerated the code along the way.

    I think it's clashes with the < html > tags existing, but I'm not sure what I can/can ' t get out existing code because it's a little more complicated that I'm used to. It's a delicate design, so I don't want to fix something (e-mail form) and destroy the other (the sensitivity).  I'm ready to knock a Facebook link on the page and say see ya!

    Anyway if anyone has some time, the link is http://www.dirtbikes101.com/contactform.php

    Thanks, thanks and thanks again!

    PS - the error message is

    Internal server error

    The server has encountered an internal error or misconfiguration and was unable to respond to your request.

    Please contact the administrator of the server, [email protected] and inform them of the time, is the error occurred and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Apache/2.2.3 (CentOS) Server at www.dirtbikes101.com Port 80

  • Faced with the issue in web log FDQM

    Hi Experts,

    I am facing problem connecting FDM Web Client, I don't think it's a browser problem... I am facing the same issue when tried with Mozilla.

    I'm not able to select any application from the drop down in the Web Client, but the same works fine when I connect through Workbench

    (I wish I could join silkscreen here for easy understanding , let me know if you know how to reach silkscreen here).

    Internet Explorer version 8, version 11.1.2.3 FDQM. Please let me know if you need more details.

    Thank you

    ~ RN

    Ideally weblog on URL should also work.

    Follow the response of SSN01-

    Yes, IISReset will reflect other user - it will stop services FDM and restart again.

    Thank you

    ~ KKT ~.

  • Faced with the conversion of an U8 2D array data in a Matlab file format?

    I'm trying to convert a simple 2D array of U8 (3 channels) data in a matlab file format.  I was manipulate the examples in the labview2matlabni record - but I can't read in Matlab - the matrix is not readable - said inconsistent number of columns.

    I have included my vi with a sample data as input.  I'm sure this shouldn't be so hard!

    Thanks in advance - all help is appreciated!

    If you have not already, doen

    You can check this site, http://matio-labview.sourceforge.net/. In my view, there are screws to back up or to import files dull.

    See you soon,.

    McDuff

  • Faced with the question to record Photoshop CS3

    123.png

    The registration of photoshop cs3 I think is no longer works, but if you really want to register, go here

    https://www.Adobe.com/sea/products/register.html

    Choose Photoshop the menu drop down and click Go

    We will ask you to sign in, then you will be redirected to a page with any adobe stuff, that you have registered before.

    If you do not see photoshop cs3 already there, at the bottom of the page under Save an older product

    Enter your serial number of photoshop cs3.

  • Faced with the question all by merging two variable result sets in BPEL 2.0

    I am facing problem while merging the response of the two variables (operations and list of objects) in BPEL 2.0

    My code snippet is as below:

    <assign name="AssignJobList">
      
    <extensionAssignOperation>
      
    <bpelx:copyList>
      
    <bpelx:from>$InvokeJobDetailsPSGetUpdatedJobObjectsResponse.JobProxyResponse/sfabmabo:Job</bpelx:from>
      
    <bpelx:to>$MergeJobListResponseMessage.JobProxyResponse/sfabmabo:Job</bpelx:to>
      
    </bpelx:copyList>
      
    <bpelx:insertAfter>
      
    <bpelx:from>$InvokeJobDetailsPSGetEffectiveJobObjectsResponse.JobProxyResponse/sfabmabo:Job</bpelx:from>
      
    <bpelx:to>$MergeJobListResponseMessage.JobProxyResponse/sfabmabo:Job[last()]  </bpelx:to>
      
    </bpelx:insertAfter>
     
    </extensionAssignOperation>
    </assign>


    For CopyList operation, its updates the target variable but for the insert after operation on its merger nor her raise an error.

    Could you please help me in the same.

    Thank you

    Hello

    The above problem can be solved by adding a tag for each operation of bpelx as shown below:

    $InvokeJobDetailsPSGetUpdatedJobObjectsResponse.JobProxyResponse / sfabmabo:Job

    $MergeJobListResponseMessage.JobProxyResponse / sfabmabo:Job

    $InvokeJobDetailsPSGetEffectiveJobObjectsResponse.JobProxyResponse / sfabmabo:Job

    $MergeJobListResponseMessage.JobProxyResponse / sfabmabo:Job [last ()]

    Kind regards

  • How to change the location of the log file in File Appender for log4j when used with the logic of the Web?

    I use log4j with weblogic

    I want to change the location of the log file in File Appender.

    I have tried providing another place but it will create the file in the same place in mydomain

    even if it has been changed in the log4j.xml.

    No idea why it's happening or what I can do to change the location of my log File? Thank you!

    Everything is perfect just replace '-' with "/" in the given file path.

Maybe you are looking for