Solved

Changes in the range of dates for execution of store procedure

Posted on 2013-06-27
5
405 Views
Last Modified: 2013-07-03
Hi experts,
I need to change the date range that handles the execution of the store procedure.

His execution takes values from a table and then inserts or updates made on another board.

When I run, passing him an IN parameter (p_in_time DATE):
update_1dia_proc exec (TO_DATE ('30 / 05/2013 3:00:00 ',' DD / MM / YYYY HH24: MI: SS '));

Open in new window

takes data from:
a_hora_test

Open in new window

and the inserted or updated in:
a_1dia_test

Open in new window

The result is:
Processing -> 30/05/2013 00:00:00
A_HORA_TEST -> A_1DIA_TEST
Updating utchora = 30/05/2013 00:00:00, pointnumber = 330000
Updating utchora = 30/05/2013 00:00:00, pointnumber = 330001

Open in new window

But I need that the insert or update be conducted on:
Processing -> 30/05/2013 03:00:00
A_HORA_TEST -> A_1DIA_TEST
Updating utchora = 30/05/2013 03:00:00, pointnumber = 330000
Updating utchora = 30/05/2013 03:00:00, pointnumber = 330001

Open in new window

I can not find this variant and so I come to your experience.

Attachment tables, inserts and procedure.

Thankyou in advanced!
update-1dia-proc.sql
script-table-inserts-hora.sql
script-table-inserts-1dia.sql
0
Comment
Question by:carlino70
[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
  • 3
  • 2
5 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39281169
Check out this line:
v_in_time := TRUNC (p_in_time, 'DD');

This strips off the time portion of the date.
0
 

Author Comment

by:carlino70
ID: 39281259
slightwv, i changed that line, for example:
v_in_time := p_in_time;

Open in new window

And nothing made over the tables:
Processing -> 30/05/2013 03:00:00
A_HORA_TEST -> A_1DIA_TEST

Open in new window

never gets update lines or inserts.
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39281280
OK, look further down in the code.  You will need to adjust the following:
WHERE TRUNC ( utctime, ''DD'')+1 = :1)

Likely changing it from an '=' to a '>=' and '<'.

I cannot say for sure because I don't understand your exact requirements.
0
 

Author Comment

by:carlino70
ID: 39281384
Look here:

The table a_hora_test contains data inserted by hour.

The procedure take all data ( he takes max, min, average and date of each one ) of a_hora_test table, and then are inserted or updated the  a_1dia_test table.

That insert or update must be done over the mark of '03:00:00' at the next day.

Ej: In this case the table a_hora_test, have data of
'29/05/2013 10:00:00' and  '29/05/2013 11:00:00' 

Open in new window

Then that insert or update, must be done in a_1dia_test:
'30/05/2013 03:00:00'

Open in new window

But is done in:
'30/05/2013 00:00:00'

Open in new window

wrong way!

Please, tell me if you dont understand yet.

Thank you.
0
 

Author Comment

by:carlino70
ID: 39296288
I've requested that this question be closed as follows:

Accepted answer: 0 points for carlino70's comment #a39281384

for the following reason:

Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.

696 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