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 : Describe Overriding for restriction

    Overriding for restriction: It is a form of method overriding in which the sub-class version of a method calls the super-class version first of all and then employs or manipulates the outcome or consequences of that call in some manner.

  • Q : What is Hash code Hash code : It is a

    Hash code: It is a value returned by a hash function. A hash code can be employed as an index into a random-access data structure, offering a proficient mapping between an object and its position. Employed by classes like HashMap.

  • Q : State the term GPC and GPT State the

    State the term GPC and GPT.

  • Q : Why is Java pure object oriented

    Explain the reasons that Java is pure object oriented programming language.

  • Q : State the term INODE State the term

    State the term INODE. Answer: It is a pointer to a block upon the disk and is a unique number. This holds metadata of files.

  • Q : Basic programming help In C Language 1.

    1. In what ways are the initialization, repetition test, and update steps alike for a sentinel-controlled loop and an endfile-controlled loop? How are they different? 2. Rewrite the program segment that follows using a for loop: count = 0;

  • Q : Reducing state space of code What is

    What is the way to reduce the state space of the code during model checking?

  • Q : Explain Message passing Message passing

    Message passing: We characterize the object interactions as message passing. The client object sends a message to a server object by invoking a technique from the server's class. Arguments might be passed with the message, and a outcome is returned by

  • Q : Explain Method overloading Method

    Method overloading: Two or more techniques with similar name stated within a class are said to be overloaded. This exerts to both constructors and other methods. The overloading applies via a class hierarchy, thus a sub class may overload a method sta

  • Q : State the term multi tasking State the

    State the term multi tasking.

©TutorsGlobe All rights reserved 2022-2023.