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
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

690 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