Solved

How do I create procedure that check current date and display all data with the date before current date?

Posted on 2008-10-17
4
350 Views
Last Modified: 2013-12-07
Create a procedure which displays the total cost of all appointments by month for all appointments with the date before current date.
Your select statement must have condition date < SYSDATE

How can I do this?
0
Comment
Question by:Zerysaish
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:Jankovsky
Jankovsky earned 60 total points
ID: 22747506
Do you mean something like:
Select trunc(date_column,'MM') as month, sum(cost_column)  as mtd_cost where date_column<sysdate group by trunc(date_column,'MM')
?
0
 

Author Comment

by:Zerysaish
ID: 22747866
yes, something like that, but I've to create user defined procedure. When the procedure is called, it'll display the total cost of all appointments by month for all appointments with the date before current date.
0
 
LVL 6

Expert Comment

by:Jankovsky
ID: 22749148
Which way to display? there are several possibilities such as DBMS_OUTPUT etc. Would you like see all total costs for months before current date or just the one last Month to day total value?
 
0
 
LVL 15

Accepted Solution

by:
Shaju Kumbalath earned 65 total points
ID: 22749164
i will just try to conert the sql given by Jankosky
-- Create the procedure
 
Create or replace procedure p_display_cost_app_month as
cursor cur_cost is
Select trunc(date_column,'MM') as cost_month, sum(cost_column)  as mtd_cost where date_column<sysdate group by trunc(date_column,'MM');
begin
 for myrec in cur_cost
 loop
dbms_output.put_line('Month ' || Cost_month||' Cost '||mtd_cost);
end loop;
end;
/
-- connect  to sql plus
set serveroutput on
exec p_display_cost_app_month ;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now