--%>

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 : Determine incorrect tags in HTML What

    What is incorrect with my < br > Tags?

  • Q : When does a name clash take place in

    When does a name clash take place in programming?

  • Q : Overriding a base class method in

    Explain the way to overriding a base class method in Visual Studio .NET and in Visual Studio 2005.

  • Q : Define the term Boot Boot: Whenever a

    Boot: Whenever a computer is switched on it is said to be `boot up'. This word comes from the phrase, “Pulling yourself up by your bootstraps”. Before a computer is ready to be utilized, it should load the programs which it requires from i

  • Q : What are Logical operators Logical

    Logical operators: The operators, like &&, ||, &, | and ^ which take two Boolean operands and generate a Boolean outcome. Employed as part of a Boolean expression, frequently in the condition of the control structure.

  • Q : What is Datagram Datagram : It is a

    Datagram: It is a packet of information passed between the two communicating procedures across a network. Both the Transmission Control Protocol (abbreviated as TCP) and the User Datagram Protocol (abbreviated as UDP) are indirectly comprised in sendi

  • Q : What is Bandera Bandera: The main goal

    Bandera: The main goal of Bandera project is to integrate existing programming language processing methods with newly developed methods to provide automated support for the extraction of safe, compact, finite-state models which are suitable for verifi

  • Q : Define the term Host system Define the

    Define the term Host system: It is a computer system on which a process is executed or run.

  • Q : What is Bit Bit : It is a binary digit

    Bit: It is a binary digit that can take on two possible values: 0 and 1. The bits are basic building block of both data and programs. Computers regularly shift data around in multiples of eight-bit units (that is, bytes for the sake of effectiveness).

  • Q : Define Zip file Zip file : It is a file

    Zip file: It is a file employed to store compressed versions of the files. In connection with Java bytecode files, such have mostly been superseded by the Java Archive (abbreviated as JAR) files.