Hi friends,
how to see all the inserted rows of a particular date of a table.
regards
rohit
10 8155
ok.......need help
thanks
bye
ok.......need help
thanks
bye
For latest row, you can use MAX(ROWID)
For latest row, you can use MAX(ROWID)
where ROWID > 20
doesn't meant that the selected rows are inserted by today
where ROWID > 20
doesn't meant that the selected rows are inserted by today
If you use ROWID > 20 in your WHERE condition, the query will error out and will not work. I suggested you to make use of ROWID = MAX(ROWID) to get the last record inserted in to the table.
Saii 145
Expert 100+
Do you have any date column in your table that stores this information?
If you are running 10g or higher, you can use the ORA_ROWSCN pseudocolumn, which can be translated to a timestamp using the SCN_TO_TIMESTAMP function.
Note, however, that data that was imported from another instance have invalid SCN:s and will raise an exception. So, I wrote this little function that has proven quite handy; it just returns NULL whenever there's an imported row with an invalid SCN. -
CREATE OR REPLACE function rowdate( rowscn in number )
-
return date
-
as
-
l_rowts timestamp;
-
bad_scn exception;
-
pragma exception_init( bad_scn, -8181 );
-
begin
-
l_rowts := scn_to_timestamp( rowscn );
-
return cast( l_rowts as date);
-
exception when bad_scn then
-
return null;
-
end;
-
/
-
-
So, a "select * from mytab where rowdate( ora_rowscn ) > trunc( sysdate )" will return today's rows.
Note that this will give you not only rows inserted today, but also the updated ones.
Do you have any date column in your table that stores this information?
find pelle's reply and try to do more with SCN....
that what the result is....
If you are running 10g or higher, you can use the ORA_ROWSCN pseudocolumn, which can be translated to a timestamp using the SCN_TO_TIMESTAMP function.
Note, however, that data that was imported from another instance have invalid SCN:s and will raise an exception. So, I wrote this little function that has proven quite handy; it just returns NULL whenever there's an imported row with an invalid SCN. -
CREATE OR REPLACE function rowdate( rowscn in number )
-
return date
-
as
-
l_rowts timestamp;
-
bad_scn exception;
-
pragma exception_init( bad_scn, -8181 );
-
begin
-
l_rowts := scn_to_timestamp( rowscn );
-
return cast( l_rowts as date);
-
exception when bad_scn then
-
return null;
-
end;
-
/
-
-
So, a "select * from mytab where rowdate( ora_rowscn ) > trunc( sysdate )" will return today's rows.
Note that this will give you not only rows inserted today, but also the updated ones.
Thanks Pelle .....
Its a good reply....
If you are running 10g or higher, you can use the ORA_ROWSCN pseudocolumn, which can be translated to a timestamp using the SCN_TO_TIMESTAMP function.
Note, however, that data that was imported from another instance have invalid SCN:s and will raise an exception. So, I wrote this little function that has proven quite handy; it just returns NULL whenever there's an imported row with an invalid SCN. -
CREATE OR REPLACE function rowdate( rowscn in number )
-
return date
-
as
-
l_rowts timestamp;
-
bad_scn exception;
-
pragma exception_init( bad_scn, -8181 );
-
begin
-
l_rowts := scn_to_timestamp( rowscn );
-
return cast( l_rowts as date);
-
exception when bad_scn then
-
return null;
-
end;
-
/
-
-
So, a "select * from mytab where rowdate( ora_rowscn ) > trunc( sysdate )" will return today's rows.
Note that this will give you not only rows inserted today, but also the updated ones.
yes pelle, that will work. can you check with this one:
select * from mytab where scn_to_timestamp( ora_rowscn ) - 0 > sysdate - 1
The function "scn_to_timestamp" returns "systimestamp" type data.
And if you do:
select systimestamp - 1 from dual
it returns sysdate type data.
Thanks for the tip.
ORA_ROWSCN of very old row might be too old to be a valid SCN.
In that case, using scn_to_timestamp will give error:
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1
But, in case of a very recent row, this will work. @rohitbasu77 Sign in to post your reply or Sign up for a free account.
Similar topics
by: hshen |
last post by:
Hi All,
I have encountered a weird behavoir of embedded MySQL. Through a
simple program I made (in Delphi 6), I can insert rows to a table...
|
by: george |
last post by:
This is like the bug from hell. It is kind of hard to explain, so
please bear with me.
Background Info: SQL Server 7.0, on an NT box, Active...
|
by: serge |
last post by:
When i debug a trigger is it possible to add a WATCH
on the INSERTED or DELETED?
I think not, at least I couldn't figure out a way to do so....
|
by: Mark |
last post by:
Hey folks, I'm looking at making the following query more efficient
potentially using the ranking functions and I'd like some advice from
the...
|
by: sajithamol |
last post by:
Is there in any way to retrieve the values that are present in the recently inserted row in DB2?
|
by: JurgenvonOerthel |
last post by:
I want to replace one element in a list<stringby a list<stringand
I need to obtain an iterator to the first element in the inserted
list.
In code:...
|
by: Gabriel Genellina |
last post by:
En Mon, 05 May 2008 08:26:45 -0300, Vaibhav.bhawsar
<bhawsar.vaibhav@gmail.comescribió:
Use a Queue object to communicate between threads. The...
|
by: Tony Toews [MVP] |
last post by:
Thanks to a posting by fellow MVP Steve Foster
On a computer that is running Windows Vista, Windows Server 2008, or
Windows XP, an incorrect...
|
by: ghssal |
last post by:
how i can select the latest order for a customer in oracle forms and save this order as a new order whith new date.
i use GROUP BY customer_ID and...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
| |