I have been faced a problem on APEX. When I go to forms and try to schedule a hour with minutes, ex 09:15, it appers that APEX TRUNC minutes, and send email at trunced hours, ex 09:00, doesn't mind hours I set time... If I schedule to 11:37, it will be sent at 11:00 o'clock! Any idea what can be causing such problem? Thanks a lot!
Related
I want to give users a period of time in which they can undo their account deletion. Someone suggested that I should use a CRON job that (1) checks my Supabase table daily for users who deleted their accounts over 30 days ago and (2) deletes those accounts. I have never used CRON jobs and I have very little experience with SQL. I have enabled the pg_cron extension in the Supabase Database settings but I don't know how to schedule the job or what to use for the SQL code. Below is my attempt at this, using a slightly modified Supabase example.
NOTE: The deleted_time is formatted as milliseconds since epoch so I need to compare that as a date.
select cron.schedule (
'webhook-every-minute', -- name of the cron job
'0 3 * * *', -- every day at 3 A.M.
$$ delete from users where DATEADD(ss, deleted_time,'01 JAN 1970') >= DATEADD(month,-1,GETDATE())
);
EDIT: I do not want to change SYSDATE, now I understand this is not possible unless the Host of the DB changes, I would still like my data to be in Pacific Time so I guess the way to go is using TIMESTAMP WITH LOCAL TIMEZONE
I have a database for which I want to enforce SYSDATE to be Pacific Time. I cannot modify the date of the host for my DB due to business rules and currently SYSDATE is CDT.
I am aware that I can change the timezone for my session, however I cannot control that other users will alter their sessions as well
Is there a way I can enforce users to use PT without modifying the date of the host?
I was thinking maybe a sort of PL/SQL trigger that alters the session every time a new connection to DB is stablished.
Thanks1
I don't think you're asking the right question. You can't do what you're trying to do. SYSDATE returns the date and time of the operating system the database is running on. It returns a DATE value, and DATEs are not time zone aware. I guess you could change the time zone of the operating system, but you'd have to talk to your system administrator about that.
You might want to work more with CURRENT_TIMESTAMP which returns a TIMESTAMP WITH TIME ZONE value and the display of that can be modified with the session time zone.
I'd say the bigger question is why are you trying to change the time zone for SYSDATE?
You can use an "after logon" trigger to set time zone.
Include the following sentence inside trigger:
execute immediate 'ALTER SESSION SET TIME_ZONE=''-05:00''';
Change "-05:00" with time offset of "Pacific Time"
i got this error
timeout value expired. The timeout period elapsed prior to completion
of the operation or the server is not responding
i have a process, which do inserts and update at night, another process
which does query at nights too, (etl or dts) at sql server 2005 so, now we need to do a query to this table, and this doesn't work, i want to run my process again, and this never finish, and noneone can do a query to this table, (another tables could do) users commented me, yesterday they could do, but today, they coulden't is it posible, my process is execute at night has never finished, and it let a begin transaccion open?
how can i to be sure of this? and close it from ssms ?
this is not a problem of permissions we could do queries and inserts/updates yesterday.
it happens only with one table.
Try this:
SELECT TOP 1 * FROM Table (nolock)
Does that return results? If so, sounds like a locking issue..
I have one stored procedure in SQl Azure is calling periodically at 5 minutes and processing crore of data and it sometimes give Timeout error as per below as per my log.
Timeout expired. The timeout period elapsed prior to completion of
the operation or the server is not responding.
How can i increase Timeout of this query or whole Db? and what would be default Timeout?
Update
I think Time out is not due to connection to sql azure here as per answers of #Ming and #Ruchit because when i have checked the log then below error it will display message like
Warning: Null value is eliminated by an aggregate or other SET
operation.
It means query is being executed, above message because of i have used some aggregate function on NULL value. Am i thinking correct? what should be other possible cause?
Thanks in Advance.
According to http://social.msdn.microsoft.com/Forums/en-US/ssdsgetstarted/thread/7070c2f9-07d1-4935-82c2-b74a196908ee/, SQL Azure will close idle connections that are longer than 5 minutes. As you mentioned you’re calling the stored procedure every 5 minutes, thus you may be on the edge of timeout. I would like to suggest you to change to every 4 minutes to see whether it works.
In addition, when using SQL Azure, retry is very important. When a query fails, please close the connection, wait for a few seconds, and then create a new connection, try the query again. Usually the second time will work fine.
Best Regards,
Ming Xu.
Ming Xu is right. the cause of the error is most probably the 5 minute timeout.
If you can not change the time period to call the stored procedure, one option is to make dummy call to SQL Azure every 3 or 4 mins. This will keep the connection from being closed.
I'm doing some basic database learning on Oracle 11g over a Citrix client. The problem is, if I'm idle about 5 minutes, I get disconnected. What would be the simplest SQL statement or PL/SQL procedure for keeping a sort of ping of activity going every minute to stay connected?
If you have access to dbms_lock you can create an infinite loop that sleeps 60 seconds each time. If you don't have access to dbms_lock try user_lock.sleep instead, although that function is not installed by default. (And if you do use it, change the 60 (seconds) to 60000 (milliseconds)).
begin
for i in 1 .. 9999999 loop
dbms_lock.sleep(60);
end loop;
end;
/
How about select 1 from dual
Try dbms.sleep(0.1) or dbms.sleep(0.01). Works fine for me.