Mail for specific days of the user and specific and time
Hello Experts,I use the program below to email each daily hour. This was intended for one person.
Now I have to change my program to accommodate more than one person, and also, I should be able to send emails to people on time and different days. What is the best approach to
declare
x_val long;
x_cumm_val long;
x_title long;
x_cumm_title long;
x_footer long;
x_column_header long;
x_column_line long;
x_row_header long;
x_row_line long;
x_cumm_row_line long;
x_total_header long;
x_total_line long;
x_row long;
x_cumm_row long;
l_rec_time varchar2(25);
l_order_id number;
l_amt number;
l_cumm_amt number;
l_instant_cumm_amt number;
l_instant_game_id number :=-1;
l_instant_col_val number :=2;
l_instant_cumm_val number :=0;--keep cummalative amt for instant
l_product varchar2(25);
no_chance exception;
x_cnt number :=0;
l_date date := trunc(sysdate);
x_to long ;
c_cc long := '[email protected]';
x_recipient long := '[email protected]';
x_exec_recipien long := '[email protected]';
x_gamma_recipient long := '[email protected]';
CURSOR c_get_values IS
select nvl(sum(act_amt),0)
from hourly_sales
where trunc(sys_date) =l_date
and nvl(confirmed,'!') = 'Y'
and to_char(to_date(rec_time,'HH24:MI'),'HH24:MI') = to_char(to_date(l_rec_time,'HH24:MI'),'HH24:MI')
and order_id =l_order_id;
CURSOR c_get_Instant_val IS
select nvl(sum(act_amt),0)
from hourly_sales
where trunc(sys_date) =l_date
and nvl(confirmed,'!') = 'Y'
and to_char(to_date(rec_time,'HH24:MI'),'HH24:MI') = to_char(to_date(l_rec_time,'HH24:MI'),'HH24:MI')
and product='INSTANT';
CURSOR c_get_user IS
select email_address
from apex_user
where user_name =p_person
and default_schema ='LOTTO_BI';
begin
x_title := '<html><head> '
||'<body>'
||'<h3 align="left"><u><font color="#000080"> Hourly Sales for '||to_char(l_date,'FMMonth DD, YYYY')
||'</font></u></h3></body></html>';
x_cumm_title := '<html><head> '
||'<body>'
||'<h3 align="left"><u><font color="#000080"> Cumulative Hourly Sales for '||to_char(l_date,'FMMonth DD, YYYY')
||'</font></u></h3></body></html>';
x_column_header := '<table border="1" bordercolor="#000000" style="background-color:#ffffd2" width="400" cellpadding="3" cellspacing="3"> '
||'<TR> <TD> </TD> ';
x_footer := '<p>This Email is autogenerated. For any inquiry please '||
' Email on <a '||
'href="mailto:[email protected]">[email protected]</a>.</p>'||
'<p> </p>'||
'<p> </p></body></html>';
if p_person is not null then
OPEN C_GET_USER;
FETCH C_GET_USER INTO x_to;
IF C_GET_USER%NOTFOUND THEN
x_val := 'No email address defined for '||p_person;
raise no_chance;
END IF;
CLOSE C_GET_USER;
x_cc := null;--do n0t copy operations when testing mail
else
if ltrim(rtrim(to_char(SYSDATE,'DAY'))) in('FRIDAY','SATURDAY') then
x_to := x_recipient||' , '||x_exec_recipient;
if ltrim(rtrim(to_char(SYSDATE,'DAY'))) = 'SATURDAY' then
x_to := x_to||' , '||x_gamma_recipient;
end if;
else
x_to := x_recipient;
end if;
end if;
for c1 in( select game_id,product product_id,b.display_name product,b.ordering
from hourly_sales a,
games b
where a.game_id =b.id
and b.active = 'Y' --<< Addition of condtion for active games only
and trunc(a.sys_date) =l_date
and nvl(a.confirmed,'!') = 'Y'
group by a.game_id,a.product,b.display_name,b.ordering
UNION
select -1,'INSTANT','Instant',l_instant_col_val
from dual
order by 4
)
loop--c1
if c1.product is null then
x_val := 'Invalid or Unrecognized Product retrieved from database';
raise no_chance;
end if;
x_column_line := x_column_line|| '<TH> ' ||c1.product||' </TH>';
x_cnt := x_cnt +1;
update hourly_sales
set order_id = x_cnt
where trunc(sys_date) =l_date
and nvl(confirmed,'!') = 'Y'
and game_id =c1.game_id
and product =c1.product_id;
end loop;--c1
x_column_line := x_column_line||' </TR>';
if x_cnt =0 then
x_val := 'No Hourly sales data to send for '||to_char(l_date,'FMMonth DD, YYYY');
raise no_chance;
end if;
for c2 in(select rec_time
from rec_time
group by rec_time
order by 1
)
loop--c2
l_rec_time := c2.rec_time;
x_row_header := ' <TR> <TH>'||c2.rec_time||'</TH> ';
for i in 1..x_cnt
loop
l_order_id := i;
l_cumm_amt := null;--reset of cummulatice amt for each game
if l_order_id = l_instant_col_val then --INSTANT Total Sales
OPEN c_get_Instant_val;
FETCH c_get_Instant_val INTO l_amt;
l_instant_cumm_val := l_instant_cumm_val + l_amt;
IF c_get_Instant_val%NOTFOUND THEN
x_row_line := x_row_line||' <TD><p align="center"> - </p></TD> ';
l_cumm_amt := 0;
ELSE
x_row_line := x_row_line||' <TD><p align="center">'||to_char(l_amt,'999,999,999,999,999,999,999,999,999')||'</p></TD> ';
/* Assume @ this stage that if previous record <>0 for instant sales column
next record should have value else no hourly sales yet input.
*/
if l_amt = 0 then
l_cumm_amt := 0 ;
else
l_cumm_amt := l_instant_cumm_val;
end if;
END IF;
CLOSE c_get_Instant_val;
ELSE
OPEN c_get_values;
FETCH c_get_values INTO l_amt;
IF c_get_values%NOTFOUND THEN
x_row_line := x_row_line||' <TD><p align="center"> - </p></TD> ';
l_cumm_amt := 0;
ELSE
x_row_line := x_row_line||' <TD><p align="center">'||to_char(l_amt,'999,999,999,999,999,999,999,999,999')||'</p></TD> ';
if l_amt <> 0 then
--save values into temp table for cummulative
insert into cumm_hourly_sales
(game_id,
amt)
values
(l_order_id,
l_amt);
select (sum(amt))
into l_cumm_amt
from cumm_hourly_sales
where game_id = l_order_id;
else
l_cumm_amt := 0;
end if;
END IF;
CLOSE c_get_values;
end if;
x_cumm_row_line := x_cumm_row_line||' <TD><p align="center">'||to_char(l_cumm_amt,'999,999,999,999,999,999,999,999,999')||'</p></TD> ';
end loop;
x_row := x_row||x_row_header||x_row_line;
x_cumm_row := x_cumm_row||x_row_header||x_cumm_row_line;
--reinitialise variables
x_row_header := null;
x_row_line := null;
x_cumm_row_line := null;
end loop;--c2
x_total_header := ' <TR> <TH> Total </TH> ';
--Total count
for c3 in( select order_id,sum(act_amt)amt
from hourly_sales
where trunc(sys_date) =l_date
and nvl(confirmed,'!') = 'Y'
group by order_id
union all
select 2,sum(act_amt)amt--Total for Instant Sales (value 2 should be ok since order 2 do not exist on table)
from hourly_sales
where trunc(sys_date) =l_date
and nvl(confirmed,'!') = 'Y'
and product ='INSTANT'
group by 2
order by order_id)
loop
x_total_line := x_total_line||' <TD><p align="center"><strong><em>'||to_char(c3.amt,'999,999,999,999,999,999,999,999,999.99')
||'</em></strong></p></TD> ';
end loop;
x_row := x_row||x_total_header||x_total_line;
x_val := x_title||x_column_header||x_column_line||x_row||' </TABLE> '||x_footer;
x_cumm_val :=x_cumm_title||x_column_header||x_column_line||x_cumm_row||' </TABLE> '||x_footer;
apex_send_mail( l_from => '[email protected]',
l_to => x_to,
l_body => x_val ,
l_subject => 'Hourly Sales for '||to_char(l_date,'FMMonth DD, YYYY'),
l_cc => x_cc
);
apex_send_mail( l_from => '[email protected]',
l_to => x_to,
l_body => x_cumm_val ,
l_subject => 'Cumulative Hourly Sales for '||to_char(l_date,'FMMonth DD, YYYY'),
l_cc => x_cc
);
exception
when no_chance then
--send mail
IF c_get_values%ISOPEN THEN CLOSE c_get_values;END IF;
IF c_get_user%ISOPEN THEN CLOSE c_get_user;END IF;
apex_send_mail( l_from => '[email protected]',
l_to =>'[email protected]',
l_body => x_val ,
l_subject => 'Hourly Sales for '||to_char(l_date,'FMMonth DD, YYYY'),
l_cc => '[email protected]'
);
when others then
--send mail
IF c_get_values%ISOPEN THEN CLOSE c_get_values;END IF;
IF c_get_user%ISOPEN THEN CLOSE c_get_user;END IF;
x_val :='Unexpected Error '||sqlerrm;
apex_send_mail( l_from => '[email protected]',
l_to =>'[email protected]',
l_body => x_val ,
l_subject => 'Hourly Sales for '||sysdate,
l_cc => '[email protected]'
);
end;
/
Hey Kevin,
If I understand your condition, you could do this with two tables:
something like this:
Table 1: Recipients_lookup
DAY RECIPIENTS
MONDAY [email protected],[email protected],[email protected]
TUESDAY [email protected],[email protected],[email protected]
WEDNESDAY [email protected],[email protected],[email protected]
THURSDAY [email protected],[email protected],[email protected]
FRIDAY [email protected],[email protected],[email protected]
SATURDAY [email protected],[email protected],[email protected]
SUNDAY [email protected],[email protected],[email protected]
First, you must select the recipients in table 1 to help 'day' of sysdate. store in a global variable for that particular day.
Insert date time records in table 2, something like this:
Table 2: date_time_lookup
DATE TIME SENT_FLAG
30-Apr-10 10:00 AM Y
30-Apr-10 11:00 AM Y
30-Apr-10 12:00 PM Y
30-Apr-10 1:00 PM
30-Apr-10 2:00 PM
30-Apr-10 3:00 PM
30-Apr-10 4:00 PM
...
Once done, make your program (to generate/send by email) to run for the first hour of the day.
Use dbms_lock.sleep (3600) to sleep for 1 hour then call your procedure again
to do this, until you reach some "end time" (7 PM or so consider you want it to be sent only during working hours...) for the day, after which, your code still needs to wait until the next day.
Tip: just go through this link on dbms_lock.sleep and use accordingly:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:6019886867656
* This is based on my initial understanding of your condition. Could be too long :)
Concerning
Imran
Tags: Database
Similar Questions
-
first day of the month and time
Hello
Using oracle 11.2.0.3
A table with a column date
sample opening time data 04/08/2014-08:30 one single column, another column start date 04/02/2014
Want to have a sql that will go through an opening time table set on the first day of the month as well as existing time
for example expect times to be
04/01/2014 08:30
Code below will give the first day of the month
What is the best way to achieve this-date data type columns.
{code}
Select trunc(start_time,'MM))
of customer_hours ch
{code}
Select
SYSDATE - trunc (sysdate) + trunc (sysdate, 'MM')
of the double
resp.
Select
start_time - trunc (start_time) + trunc (start_time, 'MM')
of the double
-
How do you know the date and time of synchronization in the windows version?
Where can I see the date and time of synchronization?
Is there a toolbar button in the Palette to customize. Move this button to a toolbar or in the Menu box open. When you hover over this button, a ToolTip will appear with the day of the week and time of the last synchronization event.
-
I've implemented all the information for an email from the Charter and then when I click on get mail, it says there is a connection to the server error... Why?
Hello ChevyDriver10,
Thanks for your post. What email app do you use to receive your mail?
In the meantime, take a look at the Charter of General electronic installation instructions.
If you do not currently have an e-mail client, feel free to go on Windows Live Mail.
See you soon
-
Live Mail is not time on a bad/hung e-mail server connection automatically, which leaves the rest / other e-mail accounts unread for long without affecting the user.BTW, how to force Live Mail to jump/break current hung connection without restarting the Live Mail? It does appear that a stop button, but no jump to Live Mail key control winodw?
Hello
1. do you use the Windows Live Mail email client?
I recommend you ask your question on the dedicated Windows Live forums. Here is the link for the category Windows Live Mail.
http://windowslivehelp.com/product.aspx?ProductID=15I hope this helps.
-
Hello
I live in Iran.
Here access to the original windows is not easy.
I have ultimate edition (eternity) win 7.
He let me to use during 30 days three times use "slmgr-rearm" to extend the trial period.
Hereby, I can use and update.
I have two questions.
1. is legal to use "slmgr-rearm" extend with period?
2-may I have reinstall win 7 and use it for 30 days after the expiration date (29 days)?with speciall thank you
original title: Reinstall windows 7 ultimate
According to the software Microsoft Windows 7 license, you must activate Windows 7 within 30 days of installation. You are not allowed to circumvent or bypass the product activation. After 30 days, you must enter a genuine Windows 7 product key for the edition you have installed, or remove Windows 7 by reformatting the hard drive, on which it is installed.
In addition, you must respect Export Basics.
-
Home page by default for OBIEE 11 g based on the users and the wise group
Hi all
I'm using OBIEE 11 g.
I need set the page default dashboard for the user and the wise group.
EX:
User1 is belongs to Group1 and Role1 - they need to see the default homepage as Dashboard1.
User2 is belongs to the Group 2 and Role2 - they need to see the default homepage as Dashboard2.
Kindly guide me to achieve.
Please answer as soon as POSSIBLE.
Thanks in advance.
It is generally considered poor form to scream as soon as POSSIBLE to a question. http://www.CatB.org/ESR/FAQs/smart-questions.html
As far as your question goes, it is that the CHEMINPORTAIL variable is for:
http://docs.Oracle.com/CD/E23943_01/bi.1111/e10540/variables.htm#i1013436
-
calculate the time in seconds, the day of the year and year
I have a data file where they record three columns, the seconds elapsed since midnight, day of the year and the year. I am creating a timestamp of LabVIEW from these three numbers. Of seconds elapsed since midnight, I can create seconds, minutes and hours. If I feed in a cluster of time with the day of the year and the year, the timestamp of output is 0. Does not work. Although an input of the day of the year element, the Date and time with seconds function apparently requires day for months and months to work.
The only solution I can imagine at this stage is to calculate the month and the day of the day of the year, which would imply a choice of the month table and a check of the leap year.
Smart solutions, I'm missing?
DaveT
Dave,
I found a Julian Georgian so far.
-
I want to be able to allow user group to be able to reset passwords and create accounts in an organizational unit. I delegate control of the organizational unit for the group, but if I connect to the domain controller and try opening users and computers active directory, we wonder an administrator password. I have a mix of two domain controllers Server 2003 and a Server 2008 DC. Is there a way to give a group access to the users and computers active directory without being administrator?
For assistance, please ask for help in the appropriate Microsoft TechNet Windows Server Forum.
Thank you. -
Hi guys, my brand new Acer E 15 dies completely if I did not put on for 2 days, but the battery lasts 5 hours so I load it.
If you stop the way you do that, when you start it you see the Acer screen at startup until it starts to load windows? Go to Options to food and on the left, click on choose what the key power and closing the lid is set to make.
If it is in hibernation, chane button close and cover for sleep.
Hibernation can cause big problems.
-
In MMC, I created the group policy and found through web search that computers with mapped network drives can connect better if "always wait for network when starting the computer and logon" is enabled... So far, it has been very nice to have allowed. Is no longer mapped network drives see the place as disconnected. But what happens if the computer is not connected to a network? Say the wireless router will turn off and your computer always 'wait... '. "turned on, should the user could still log the computer timely?
Check these:Troubleshooting intermittent slow connection or slow start of http://blogs.technet.com/b/instan/archive/2008/04/17/troubleshooting-the-intermittent-slow-logon-or-slow-startup.aspxPriority and group policy processinghttp://TechNet.Microsoft.com/en-us/library/cc785665%28WS.10%29.aspx -
Easy question: router WRT54G: how to rename the user and give a new password?
Not very computer, but following the recommendations in the FAQ, I have reset my WRT54G router to the default settings by hitting the reset buttong and entering into the Web site. I got a new computer and I forgot the old password. After reset to defaults now the link is not secure. How can I go about renaming the user and giving it a new password of my own - it was a while that I have configured the router, and I don't have the CD. Any help that you can offer or the direction you can piont me is appreciated.
Try to proceed as following:
Open an Internet Explorer browser on your computer (desktop) wired page. In the address bar type - 192.168.1.1 and press ENTER... Let the empty user name & password use admin lowercase...
For wireless settings, follow these steps: -.
Click on the Wireless tab
-Wireless network mode must be mixed...
-Provide a unique name in the name box of the wireless network (SSID) in order to differentiate your network from your network of neighbors...
-Set the channel 11-2 wireless, 462 GHz... Wireless SSID broadcast should be enabled and then click on save settings...
Please take note of the name of the wireless network (SSID) because it's the network identifier...For wireless security: -.
Click the sub-tab under wireless > Wireless Security...
Change the mode of WEP wireless security, encryption must be 64-bit. Let the empty password, do not type in anything... Under type of WEP Key 1 in all 10 numbers please (numbers only and no mailbox for example: your 10-digit phone number) and click on save settings...
Please note the 1 WEP key as it comes to the security key for the wireless network...Click the settings advanced wireless
Change the interval of tag to 75 > change the Fragmentation threshold to 2304, change the RTS threshold to 2304 > click 'save settings '...
Now let's see if you can locate your wireless network and try to connect... -
My background: I can only see this dialog box titled WINDOWS SECURITY when I want to access my log to router with my office router connection. The dialog box refers specifically to my router, and asking a user and a password.
A long time ago that I asked to remember and, of course, I forgot it and the location that I wrote. Now I am unable to determine what I thought, would be a simple reset and the steps that allow me to perform a reset. After a series of search phrases on Bing, and in the community of the SP as well as Win 7 Pocket administrator index I can't find the steps because the dialog box, it seems with the title of the WINDOWS SECURITY is too general.
I need to install a new router and need to change the user and password. I don't know if user and password are unique to the company of router or Microsoft Win 7. Nevertheless, I can reset thinking them they are unique to me and Microsoft because there is no query such as, "you forgot your password?', whereby get you a temporary. These steps are already stationed in the community and I just can't get into the research phase right? (What is related to IE 11?) Thank you.
> I need to install a new router and need to change the user and password.
Do you want to connect to your old router? If Yes, most routers have built-in switch you tripping with a paper clip or similar to force a reset to the factory settings. You can then access the default connection.
If it's the new router, it should be accessible with the factory default login. If you don't know please post that make the exact and the model of the router.
-
It seems to me that this is not possible, but is there a way I can put a recurring appointment for a certain day of the week of each month in the calendar on the Surface RT? For example, a meeting Tuesday on two or one excursion each fourth Sunday? I know that this is possible in Outlook on a PC and I would like to do it on the Surface RT as well. Most of my recurring appointments are of this type. When I recur every month on the Surface, it just sets it for the same date (for example the 12th of each month) instead of the second Tuesday. Thank you!
Hi Lisa,
You were correct when you say that 'it seems to me that's not possible. ' The recurring appointment for some day of the week each month in the calendar on Surface RT cannot be done by date and not day.
Good day!
-
Change the attributes of the user and configuration of resources
Hello
For the first look, I have a simple question. Where can I see changing attributes of the user and information about the history that did? I can see a upa_fields of the table, but there is no information on directors who did it.
And the same question on resources. I need to get a way how to display information on the directors who provided resources for different users and administrators who have made changes in these resources. Y at - it all tables that can help me in it?
Is there other variants of this information?
I use OIM 11 g R1.
Thank you.If you need only to know which revoked a resource, you can use this:
Select usr.usr_login, obj.obj_name, ost.ost_status, rev.usr_login 'Revoker.
Ouedraogo, usr, obi, obj, ost, usr rev
where oiu.usr_key = usr.usr_key
and oiu.obi_key = obi.obi_key
and obi.obj_key = obj.obj_key
and oiu.ost_key = ost.ost_key
and oiu.oiu_updateby = rev.usr_key
and ost.ost_status = 'revoked '.-Kevin
Maybe you are looking for
-
iPhone 6 s not connet to tunes on computer
I can't get my iphone appears on itunes. I tried several threads and restart both without success. My phone is displayed on the computer and I can download my photos, but I can't see it on itunes. I want to just be synchronized.
-
Cancel firefox as default browser
I want to cancel Firefox as my default browser
-
Miss me my calendar after update to Thunderbird and search, I have installed the add-on lightning, straightened my program and Calendar tab does not appear. I have years of work and set up reminders and I NEED to recover - please help! I don't know j
-
can not sync between two computers of firefox
with synchronization problem in my firefox on imac and macbook. a compauter is already 'connected' and give me no option to add a new device on the synchronization page (lists of accounts, synchronization only options) and on the new computer to be s
-
Hello.I am a new user of g50-70 of lenovo. My phone is always in the AC network. (regular intake at home) According to the instructions on the battery life I should spend the energy conservation mode Manager. I did and recharge the battery stopped at