Showing total of PRICE using 3 tables PROBLEM, please help URGENT??

Hi i am trying to calculate the order total in my database for a given order number.
I need to use 3 tables for this:
customer table:
CREATE TABLE customer
     (custid NUMBER(5),
     last VARCHAR2(30) CONSTRAINT customer_last_nn NOT NULL,
     first VARCHAR2(30),
     mid_initial CHAR(1),
     cadd VARCHAR2(30),
     town VARCHAR2(30),
     city VARCHAR2(30),
     postcode VARCHAR2(10),
     dphone VARCHAR2(10),
     ephone VARCHAR2(10),
     CONSTRAINT customer_custid_pk PRIMARY KEY (custid));
orders table:
CREATE TABLE orders
     (orderid NUMBER(8),
     orderdate DATE CONSTRAINT orders_orderdate_nn NOT NULL,
     methpmt VARCHAR2(10) CONSTRAINT orders_methpmt_nn NOT NULL,
     custid NUMBER(5),
     ordersource VARCHAR2(20),
     CONSTRAINT orders_orderid_pk PRIMARY KEY (orderid),
     CONSTRAINT orders_custid_fk FOREIGN KEY (custid) REFERENCES customer(custid),
     CONSTRAINT orders_ordersource_fk FOREIGN KEY (ordersource) REFERENCES           ordersource(ordersource));
And finally orderline table:
CREATE TABLE orderline
     (orderid NUMBER(8) CONSTRAINT orderline_orderid_nn NOT NULL,
     invid NUMBER(10) CONSTRAINT orderline_invid_nn NOT NULL,
     order_price NUMBER(6,2) CONSTRAINT orderline_order_price_nn NOT NULL,
     quantity NUMBER(4) CONSTRAINT orderline_quantity_nn NOT NULL,
     CONSTRAINT orderline_pk PRIMARY KEY (orderid, invid),
     CONSTRAINT orderline_orderid_fk FOREIGN KEY (orderid) REFERENCES orders(orderid),
     CONSTRAINT orderline_invid_fk FOREIGN KEY (invid) REFERENCES inventory(invid));
INSERT INTO CUSTOMER VALUES (107, 'HARRIS', 'PAULA', 'E', '1156 WATER STREET', 'KENSINGTON','LONDON', 'SW1 6DS', 02071555589, 02071555590);
INSERT INTO ORDERs VALUES (1057, TO_Date('05/29/2001 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'), 'CC', 107, '152');
INSERT INTO ORDERLINE VALUES (1058, 11824, 15.99, 1);
Here is my code:
SET SERVEROUTPUT ON;
DECLARE
v_odNum NUMBER(8):= &sv_orderNum;
v_price NUMBER(7,2);
v_quantity NUMBER(5);
v_fname VARCHAR2(30);
v_lname VARCHAR2(30);
v_add VARCHAR2(30);
BEGIN
SELECT first, last, cadd, order_price, quantity, SUM(order_price * quantity) AS TOTAL
INTO v_fname, v_lname, v_add, v_price, v_quantity
FROM customer c, orders o, orderline ordl
WHERE c.custid = o.custid AND o.orderid = ordl.orderid
AND v_odNum = o.orderid
DBMS_OUTPUT.PUT_LINE('The total order for' ||v_odNum|| ' '|| 'is' || TOTAL);
END;
Is there anyway of using the SUM function so that i can store the result in a variable and display it similar to the ouput code??
P.S sorry for the length coding, but there is no code tage in the thread that i can see to make it more managable.

A procedure with an OUT parameter which returns the total order cost should work.

Similar Messages

  • I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    If you have a rescue email address on your account then you can use that - follow steps 1 to 5 half-way down this page will give you a reset link on your account : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address (you won't be able to add one until you can answer your questions) then you will need to contact Support in your country to get the questions reset : http://support.apple.com/kb/HT5699

  • Starting tomcat problem, please help urgent

    I installed jwsdp on windowsXP . The log file gives this following error when i try to start tomcat:
    java.util.zip.ZipException: Access is denied
         at java.util.zip.ZipFile.open(Native Method)
         at java.util.zip.ZipFile.<init>(ZipFile.java:127)
         at java.util.jar.JarFile.<init>(JarFile.java:138)
         at java.util.jar.JarFile.<init>(JarFile.java:80)
         at org.apache.catalina.loader.StandardClassLoader.addRepositoryInternal(StandardClassLoader.java:1081)
         at org.apache.catalina.loader.StandardClassLoader.<init>(StandardClassLoader.java:200)
         at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:202)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:141)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
    Bootstrap: Class loader creation threw exception
    java.lang.IllegalArgumentException: addRepositoryInternal: java.util.zip.ZipException: Access is denied
         at org.apache.catalina.loader.StandardClassLoader.addRepositoryInternal(StandardClassLoader.java:1109)
         at org.apache.catalina.loader.StandardClassLoader.<init>(StandardClassLoader.java:200)
         at org.apache.catalina.startup.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:202)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:141)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
    PLEASE HELP ,URGENTLY NEEDED TO SHOW SOME WORK ON THIS.
    THANKS
    jim

    Hi,
    I have a similar problem, i try to deploy a JAR file built on AIX 5.2 platform (jvm 14.1) into Tomcat 5.5.7 running on Windows platform when i try start Tomcat it's fail with the fellowing message
    SEVERE: Error deploying web application directory usi
    java.lang.IllegalArgumentException
         at java.util.zip.ZipInputStream.getUTF8String(ZipInputStream.java:299)
         at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:238)
         at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:73)
         at java.util.jar.JarInputStream.<init>(JarInputStream.java:58)
         at java.util.jar.JarInputStream.<init>(JarInputStream.java:43)
         at org.apache.catalina.util.ExtensionValidator.getManifest(ExtensionValidator.java:368)
         at org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionValidator.java:187)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:3942)
         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
         at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:909)
         at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:872)
         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1106)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1019)
         at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440)
         at org.apache.catalina.core.StandardService.start(StandardService.java:450)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)

  • Triggers problem - please help - urgent !!

    To all experts, please help me with this problem - need answer
    urgently. Thanks in advance.
    Using Oracle 8 Rel 8.0.6
    I have 2 tables (table Y, table Z).
    In the 'after insert upd del on each row trigger' (lets call it
    AIUD trigger)on table Y, based on certain criteria, I insert a
    record in table Z.
    New requirement is that whenever a record is inserted in table Z
    (fyi, inserting any record in table Z is possible only when
    records are inserted in table Y as mentioned earlier thro the
    AIUD trigger - i.e. there is no frontend way to insert records
    in table Z), if certain (new) criteria is satisfied, I should
    insert 1 record in both, table Y and table Z.
    I tried to create meet the new requirement by adding code to
    existing AIUD trigger but ran into mutating tables error. So I
    dropped this idea.
    I have now created 'after insert on each row trigger' (lets call
    it NEW_TRIGGER) on table Z to meet the new requirement but have
    these 2 problems :
    1) the trigger always compiles with errors
    2) if I still go ahead and insert a record in table Y, I get the
    foll error msgs :
    ORA 4098 - NEW_TRIGGER is inv
    ORA 6512 at line xxx on AIUD
    ORA 4088 error during execution of trigger AIUD
    What is the best way to work on this requirement or what am I
    doing wrong ?
    Thanks again,
    AG.

    Your restatement of the problem merely confirms what the previous
    posting said. You cannot write a trigger on table Y that inserts
    a record into table Y: that's the mutating trigger problem
    (there's oodles of postings on the subject, not to mention
    online Oracle docs). You could write a trigger on table Z that
    inserts into table Y - but you need to be able to see the value
    I3 which (presumeable) you can't.
    One solution is to use code the trigger on table Y to submit a
    call to DBMS_JOB which initiates a procedure that inserts a
    record into table Y.
    You must remember that the new record in table Y must never
    include the value I3, otherwise you'll end up w/ an infinite
    loop.
    rgds, APC

  • Mac OS x/ finder/ hard drive/ start up.... problems PLEASE HELP URGENT!!

    Right
    firstly my finder icon on the dock the little triangle to show it on disapers. meaning all the icons on the desktop disapear! Then i restart to get them back but it loads the grey screen then goes to blue and nothing else. So i restart but hold down the ALT key to see drives and i calls my HD EMI drive or something so i boot from Backup cd 1 and have to reload Mac OS x Again for the second time today! what is going on and how can i fix it?

    Michael,
    First,Back up all important files.Then...
    Run Apple Hardware Test from OS X Install Disk #1.
    If it reports any problems,believe it and call AppleCare to have MacBook repaired.
    If AHT reports "No problems found",I'd recommend an Erase and Install of OS X.
    Let us know the outcome either way.
    Jim
    PowerBook G3 500 Mhz "Pismo"/ 2.0Ghz BlackBook 2GB OWC RAM   Mac OS X (10.4.8)  

  • D:\oracle\product\10.2.0-Console access problem-please help urgent.

    I have installed D:\oracle\product\10.2.0, each times i create a db on it the console work fine, but when I close my computer then restarts it I can get in to the console again.
    some people said that one shouldn't be on net while installing it, so I wasn't on net.
    Then I tried to start the service as windows service it can not start.
    where can I look in the oracle config ? to deal with the problem ?
    Thanks.

    Is your computer configured with DHCP? If so, did you configure the loopback adapter?
    http://download-east.oracle.com/docs/cd/B19306_01/install.102/b14316/reqs.htm#BABGCEAI
    Logs are written to ORACLE_HOME/<machine_name>.<dbsid>/sysman/log

  • Installation problem, please help, urgent needs,

    I have install the FCP 7 into my MBP, and updated, but in the "add behavior" tap i don't have those new behavior like "text-basic" "text-continuous" "text-energetic" etc..... how can i add it back?
    urgent needs, please help

    fixed

  • ZIP problem - Please help -URGENT

    Below there is a program which updates an OpenOffice file, in fact a zip file.
    It works fine on window but on Netware I receive an exception
    java.util.zip.ZipException: invalid entry CRC-32
    (expected oxffffffffc0f3d518 but got 0xc0f3d518)
    Any ideas is great appreciated. Thanks!
    ================
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.util.jar.*;
    class test {
    public static void main(String []args){
         test ob=new test();
         ob.updateZipEntry("data://test.sxw","content.xml","data:");
    void updateZipEntry(String jarName, String fileName, String location){
         try {
         File jarFile = new File(jarName);
         File tempJarFile = new File(jarName + ".tmp");
         JarFile jar = new JarFile(jarFile);
         boolean jarUpdated = false;
         try {
         Manifest jarManifest = jar.getManifest();
         JarOutputStream tempJar = new JarOutputStream(new FileOutputStream(tempJarFile));
         byte[] buffer = new byte[1024];
         int bytesRead;
         try {
         FileInputStream file = new FileInputStream(location+"//"+fileName);
         try {
         JarEntry entry = new JarEntry(fileName);
         tempJar.putNextEntry(entry);
         while ((bytesRead = file.read(buffer)) != -1) {
         tempJar.write(buffer, 0, bytesRead);
         finally { file.close(); }
         for (Enumeration entries = jar.entries(); entries.hasMoreElements(); ) {
         JarEntry entry = (JarEntry) entries.nextElement();
         if (! entry.getName().equals(fileName)) {
         InputStream entryStream = jar.getInputStream(entry);
         tempJar.putNextEntry(entry);
         while ((bytesRead = entryStream.read(buffer)) != -1) {
         tempJar.write(buffer, 0, bytesRead);
         jarUpdated = true;
         catch (Exception ex) {
         System.out.println(ex);
         tempJar.putNextEntry(new JarEntry("stub"));
         finally { tempJar.close(); }
         finally {
         jar.close();
         if (! jarUpdated) { tempJarFile.delete(); }
         if (jarUpdated) {
         jarFile.delete();
         tempJarFile.renameTo(jarFile);
    } catch(IOException e) {}
    } // end updateZipEntry
    }

    It's Netware for sure.
    That's the only error message I get:
    java.util.zip.ZipException: invalid entry CRC-32
    (expected oxffffffffc0f3d518 but got 0xc0f3d518)
    Why does it run on w2k?
    Thanks!
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.util.jar.*;
    class test {
    public static void main(String []args){
         test ob=new test();
         ob.updateZipEntry("data://test.sxw","content.xml","data:");
    void updateZipEntry(String jarName, String fileName, String location){
              try {
               File jarFile = new File(jarName);
               File tempJarFile = new File(jarName + ".tmp");
               JarFile jar = new JarFile(jarFile);
               boolean jarUpdated = false;
               try {
                  Manifest jarManifest = jar.getManifest();
                  JarOutputStream tempJar = new JarOutputStream(new FileOutputStream(tempJarFile));
                  byte[] buffer = new byte[1024];
                  int bytesRead;
                  try {
                     FileInputStream file = new FileInputStream(location+"//"+fileName);
                     try {
                        JarEntry entry = new JarEntry(fileName);
                        tempJar.putNextEntry(entry);
                        while ((bytesRead = file.read(buffer)) != -1) {
                           tempJar.write(buffer, 0, bytesRead);
                     finally { file.close(); }
                     for (Enumeration entries = jar.entries(); entries.hasMoreElements(); ) {
                        JarEntry entry = (JarEntry) entries.nextElement();
                        if (! entry.getName().equals(fileName)) {
                           InputStream entryStream = jar.getInputStream(entry);
                           tempJar.putNextEntry(entry);
                           while ((bytesRead = entryStream.read(buffer)) != -1) {
                              tempJar.write(buffer, 0, bytesRead);
                     jarUpdated = true;
                  catch (Exception ex) {
                     System.out.println(ex);
                     tempJar.putNextEntry(new JarEntry("stub"));
                  finally { tempJar.close(); }
               finally {
                  jar.close();
                  if (! jarUpdated) { tempJarFile.delete(); }
               if (jarUpdated) {
                  jarFile.delete();
                  tempJarFile.renameTo(jarFile);
         } catch(IOException e) {}
    } // end updateZipEntry
    }

  • Hi guys i have an ipad 1 and when i plug it in to my macbook pro picasa opens up and show its name but when i open itunes i cant find the name, ive been working my head out to solve the problem please help me:(

    hi guys i have an ipad 1 and when i plug it in to my macbook pro picasa opens up and show its name but when i open itunes i cant find the name, ive been working my head out to solve the problem please help me:(

    Pay no attention to iinami, the amount of replies to people saying their handsets must have been jailbroken everytime iTunes throws out an error is tremendous. (Clearly you don't need to have any real knowledge to get to level 3 on these forums, let's hope apple's geniuses know a lot more than some of their customers.)
    http://support.apple.com/kb/TS3694
    Solution below.
    Error 9
    This error occurs when the device unexpectedly loses its USB connection with iTunes. This can occur if the device is manually disconnected during the restore process. This issue can be resolved by performing USB troubleshooting, using a different USB dock-connector cable, trying another USB port, restoring on another computer, or by eliminating conflicts from third-party security software.

  • I am using an iphone 3g and when i connect my device to my laptop a dialog box appears saying that an update of 4.2 is available so went for it.after the firmware is downloaded via itunes it shows that the firmware is invalid!.please help.

    HEY GUYS I AM USING AN IPHONE  3g and when i connect my device to my laptop a dialog box appears saying that an update of 4.2 is available so went for it.after the firmware is downloaded via itunes it shows that the firmware is invalid!.please help.
    AND ALSO I HAVE HEARD THAT THE IPHONE 3G CANNOT BE UPDATED TO IOS 4.2!IS IT TRUE???
    PLEASE HELP ME.

    This means that the phone you have was software unlocked to use on any carrier, or hacked. When you installed the update it restored the lock that originaly came with your phone. Not much you can do now. Apple will not support hacked phones. You will need to find out the carrier your phone is locked to and see if they offer official unlocking, or start googling to see if you can find a way to unlock 4.2.

  • HT4623 My ios update keeps getting stuck on the Restoring iPhone software stage. I uninstalled iTunes and reinstalled it again, but still nothing. Now I can't even use my phone as it shows the plug into iTunes screen. Please help!!!! Thanks,

    My ios update keeps getting stuck on the Restoring iPhone software stage. I uninstalled iTunes and reinstalled it again, but still nothing. Now I can't even use my phone as it shows the plug into iTunes screen. Please help!!!! Thanks,

    A Restore first downloads a new copy of iOS to your computer. On a slow Internet connection this can take a long time. How fast is your connection? How long would you expect it to take to download 900 MB?
    That's assuming nothing is interfering with the download. Some firewalls and antivirus programs will block the download or slow it down. So you should temporarily disable your security software. Security software can also block the update after the iOS download is complete.

  • The volume up and down controls on my wireless keyboard show a no entry sign and do not respond when used...please help?

    The volume up and down controls on my wireless keyboard show a no entry sign and do not respond when used...please help?

    If you want to get a little more "exotic" you can try remapping the function keys.  I did a little google searching and the hits that looked promising are,
    Mapping volume and eject keys to 3rd-party keyboard Other Hardware
    Spark
    Spark is a powerful, and easy Shortcuts manager. With Spark you can create Hot Keys to launch applications and documents, execute AppleScript, control iTunes, and more...
    You can also export and import your Hot Keys library, or save it in HTML format to print it.
    Spark is free, so use it without moderation!

  • I am using firefox 3.6.17 i upgraded it to 4.1.but it does not work properly sometimes it opens every website and most of the time it does not work . so what is the problem please help . thank you

    i am using firefox 3.6.17 i upgraded it to 4.1.but it does not work properly sometimes it opens every website and most of the time it does not work . so what is the problem please help . thank you

    Did you check your security software (firewall)?
    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process.
    See:
    * [[Server not found]]
    * [[Firewalls]]

  • Hello sir my iphone screen turns off after using 2-5 minutes what would be the problem please help me out

    hello sir my iphone screen turns off after using 2-5 minutes what would be the problem please help me out

    To make sure that this is not software related, set it back to factory settings, without using any backup data afterwards. Set up the rest of the personal settings manually and test the phone. If it still does not work, this is a hardware issue and the phone has to be serviced by Apple or an Authorized Apple Service Provider:
    Use iTunes to restore your iOS device to factory settings - Apple Support
    Find an Apple Authorized Service Provider
    iPhone - Contact Support - Apple Support

  • I have iPhone 3gs. I was trying to update the software using itunes but it is showing Error "-3259" saying  connection timeout. Please help.

    I have just bought iPhone 3gs in Sept.11. I was trying to update the software using itunes but it is showing Error "-3259" saying  connection timeout. Please help.

    Did you already check your securit software settings? iTunes has to contact Apple during the update process.
    See this article: iTunes for Windows: Troubleshooting security software issues

Maybe you are looking for

  • HT204382 Quicktime 10.1 says I need a codec, yet Quicktime 10.2 plays it

    I have * .mpg files that Quicktime version 10.1 (501.29) [OSX 10.7.5 (Lion) on my mac-mini] complains it can't open the file "because a required codec isn't available" (It would be helpful if quicktime reported what media format/code it THINKS the .m

  • Mysteries behind Zen Micro on 2.20

    2.20.05 worked fine for a week, then the super drainage came back!!! I re-flashed it to 2.20.05 everytime I experienced this drain (at least 0 times now). Here's what i have discovered last night. Sleep Timer (off as usual) Idel shutdown (off for thi

  • Datapump between two databases

    I have two databases, by usıng datapump I would lıke to move package,procedures and views to other database. expdp live/live@rac DIRECTORY=my_dir DUMPFILE=plsql.dmp INCLUDE=VIEW,PROCEDURE,PACKAGE,FUNCTION impdp test/test@orcl DIRECTORY=my_dir DUMPFIL

  • Pivot help on an heirarchy query

    I've looked through the FAQs but I'm just not seeing it. I have the following: A query returning: o_id   oname            typ  prnt 118    Pension Admin    PRC    91 91     Retirement       LOB   218 218    Benefits         SEG    81 119    Plan Mgmt

  • Can't open Gmail or zip drives

    I cannot open Gmail on my MacBook Pro.  It opens fine on my I-Pad and I-Phone.  It says it is unable to verify account name or password. I also cannot open any zipfile attachments in any email on any of my Apple devices. Can anyone help me please?