--%>

Compute Days Between Ordering and Shipping in SQL

An analyst in the quality assurance office reviews the time lapse between receiving an order and shipping an order. Any orders which have not been shipped in a day of the order being positioned are investigated. Build a function named ORD_SHIP_SF which computes the number of days between the date the basket was made and the shipping date. The function must return a character string which indicates “OK” when the order was shipped in a day or “CHECK” if it was not. The IDSTAGE column of the BB_BASKETSTATUS table ppoints out the item is shipped with a value of 5 and the DTSTAGE column is the shipping date. The TDORDERED column of the BB_BASKET table is the order date. Utilize the function in an anonymous block which uses a host variable to receive the basket id to check basket 3.

E

Expert

Verified

create or replace function "ORD_SHIP_SF"
(baskid in NUMBER)
return VARCHAR2
is
NUMDAYS NUMBER;
begin
SELECT TO_DATE(bs.DTSTAGE,'DD-MM-YYYY')-TO_DATE(bb.DTORDERED,'DD-MM-YYYY') INTO NUMDAYS FROM BB_BASKET BB,BB_BASKETSTATUS BS WHERE BB.IDBASKET=BS.IDBASKET and BB.IDBASKET=baskid;
IF NUMDAYS>0 THEN
   RETURN 'OK';
END IF;
RETURN 'CHECK';
EXCEPTION
   WHEN NO_DATA_FOUND THEN
      DBMS_OUTPUT.PUT_LINE('No Data Found');
      RETURN 'CHECK';
  WHEN OTHERS THEN
      RETURN 'CHECK';
 
end;

   Related Questions in Programming Languages

  • Q : New features in Microsoft AJAX library

    List the new features that are included in Microsoft AJAX library?

  • Q : Learning File system with operations

    Program 1. Purpose of this assignment is to learn to work with files.Assignment: The file, data.txt, is provided on the class website. Each line of the file consists of a binary operator followed by two operands. Your program wi

  • Q : Explain Polling Polling : It is the

    Polling: It is the process of repeatedly testing until a situation becomes true. Polling can be incompetent when the time between tests is little compared with the time it will take for the condition to become true or right. A polling thread must slee

  • Q : Automaton distributed in the class

    Write a code in a c++/java  for the automaton distributed in the class which accepts keywords(cat,bat,cab). Create an input file with these words may be two or three copies of these words scattered in a paragraph and show that your program does accept these words and gives an output to that

  • Q : Define the term RGB Color Model Define

    Define the term RGB Color Model: It is a color model based on representing a color as three components: green, red, and blue.

  • Q : Define Out of scope Out of scope : It

    Out of scope: It is a variable is in scope as long as the program's flow of control is in the variable's defining block. Or else, this is out of scope.

  • Q : What is MIME MIME : Multipurpose

    MIME: Multipurpose Internet Mail Extensions (abbreviated as MIME) are rules which make it possible to utilize electronic mail to send content other than the simple text.

  • Q : Define the term Class constant Define

    Define the term Class constant: A variable which is defined as both final and static.

  • Q : What is Dotted decimal notation Dotted

    Dotted decimal notation: The notation employed to symbolize the 4-byte values of an IP address. Each and every byte is symbolized as a value between 0 to 255, for instance 129.12.0.1. The most noteworthy byte is written at first.

  • Q : How is an external entity reference

    While constructing an XML DTD, how do you make an external entity reference within an attribute value?