Knowee
Questions
Features
Study Tools

Write a PL/SQL simple procedure named display_dates with 2 input parameter. The first input parameter is d1 of type date. The second input parameter is d2 of type date. This procedure will display the dates between d1 and d2(exclusive), each in a newline.Use the below skeleton:Procedure name: display_datesInput parameter: d1 of type date, d2 of type dateNote:Do not change the procedure nameDo not change the argument count and orderDo not change the output text.Instructions:1. Create the procedure successfully2. Once the procedure is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PROCEDURE query.

Question

Write a PL/SQL simple procedure named display_dates with 2 input parameter. The first input parameter is d1 of type date. The second input parameter is d2 of type date. This procedure will display the dates between d1 and d2(exclusive), each in a newline.Use the below skeleton:Procedure name: display_datesInput parameter: d1 of type date, d2 of type dateNote:Do not change the procedure nameDo not change the argument count and orderDo not change the output text.Instructions:1. Create the procedure successfully2. Once the procedure is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PROCEDURE query.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is the PL/SQL procedure you requested:

CREATE OR REPLACE PROCEDURE display_dates (d1 IN DATE, d2 IN DATE) IS
  v_date DATE;
BEGIN
  v_date := d1 + 1;
  WHILE v_date < d2
  LOOP
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(v_date, 'DD-MON-YYYY'));
    v_date := v_date + 1;
  END LOOP;
END display_dates;
/

This procedure starts by setting v_date to the day after d1. It then enters a loop that continues until v_date is not less than d2. Inside the loop, it uses DBMS_OUTPUT.PUT_LINE to print v_date, and then increments v_date by one day. The TO_CHAR function is used to format the date in 'DD-MON-YYYY' format.

Please note that you need to enable server output to see the result of DBMS_OUTPUT.PUT_LINE. You can do this by running SET SERVEROUTPUT ON in SQL*Plus or by configuring your SQL client accordingly.

Also, remember that this procedure does not include d1 and d2 in the output. If you want to include them, you should initialize v_date with d1 instead of d1 + 1, and change the condition in the WHILE loop to v_date <= d2.

This problem has been solved

Similar Questions

Write a PL/SQL anonymous block which will perform date and time operations. Declare a variable ‘d’ of type DATETIME and initialize with the value '25-Jan-2020'. And then perform below date and time  operations and print the result:1. Print the date after adding 4 months to the date d2. Print only the year part present in the date d3. Print the last day of the month based on the date d4. Assume that the current date is ‘2020-10-25’. Display the number of month between the current date and the date dNote:Do not change the value of the date d.Display the result in the same order. Do not change the order of operations.

Write a PL/SQL simple procedure named display_custommessage with 2 parameters. The first input parameter is name of type varchar. The second output parameter is custmsg of type varchar. This procedure will set the output parameter message with ‘Hi <name>, You’re learning PL/SQL’.Use the below skeleton:Procedure name: display_custommessageInput parameter: name of type varcharOutput parameter: custmsg of type varcharNote:Do not change the procedure nameDo not change the argument count and orderDo not change the output text.Instructions:1. Create the procedure successfully2. Once the procedure is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PROCEDURE query.Sample Input and Output:If the input parameter is 'Alice', then the sample output will be below:

Single File Programming QuestionProblem StatementFrom the following table, write a query to count all the orders generated on "2012-08-17." Return the number of orders.Table name: ordersNote: Table names are case sensitive.Input format :The input table is already created, and records are already prepopulated, as mentioned in the problem statement.Output format :The output displays the count of all the orders generated on '2012-08-17' as shown below.Count2Refer to the sample output for the column header.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.

SB - Date OperationsWrite a PL/SQL anonymous block which will perform date and time operations. Declare a variable ‘d’ of type DATETIME and initialize with the value '25-Jan-2020'. And then perform below date and time  operations and print the result:1. Print the date after adding 4 months to the date d2. Print only the year part present in the date d3. Print the last day of the month based on the date d4. Assume that the current date is ‘2020-10-25’. Display the number of month between the current date and the date dNote:Do not change the value of the date d.Display the result in the same order. Do not change the order of operations.Sample output:SubmitPreviously Executed QueriesSaveExecutePrevious Submission1SET SERVEROUTPUT ON;2DECLARE 3 d DATE := '25-Jan-2020';4BEGIN 5 --Write your code here6END;7​

You would like to display the system date in the format "Monday, 01 June, 21". Which SELECT statement should you use?SELECT TO_DATE(SYSDATE, 'FMDAY, DD Month, YYYY') FROM dual;SELECT TO_CHAR(SYSDATE, 'FMDD, DY Month, 'YYY') FROM dual;SELECT TO_CHAR(SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;SELECT TO_CHAR(SYSDATE, 'FMDY, DDD Month, YYYY')

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.