?
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
Medium Priority
?
357 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 240 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 260 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

765 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