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
352 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PAYER_ID has both atributes 4 39
Extract the first word (before the , ) 2 48
execute immediate plsql block 5 46
Can't Access My Database 57 66
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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 information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to take different types of Oracle backups using RMAN.

772 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