Reg: Getting the latest or last saved data from the table
Hi,
I'm having a table, which is getting updated whenever something is saved.
Now i want to get the latest or last saved details to be displayed or the details of the row with greatest Id.( i.e, the Id. will be greatest for the last saved)
please help me out with code to do this...
Thanks & Regards,
Suresh
Hi Suresh,
This could be done either through the webdynpro or the back end function module itself.
If another field of type date/time is present in the table, u can save the current date and time along with the data in the table, and sort it in descending order of time. so that whenever u refresh the page the latest record is always in the first row,
if u want to do it through webdynpro, u can also sort the table based on the date so that u get the latest record that was saved.
Another solution is that u can maintain a serial number sort of thing the table which helps u identify the latest record
Hope this helps u.
Regards,
Poojith M V
Similar Messages
-
How to get all rows of an attribute data from a table?
Hello.. I´m using Jdev 10.1.3.2
I have a table with 5 columns and N rows.
I need to create a backing bean method to count the value of all rows of a specifc column.
I use
JUCtrlValueBindingRef selectedRowData= (JUCtrlValueBindingRef)myTable().getSelectedRowData();
to get an attribute from a selected row. but How can get from all rows?
Thank you
VandréHi Vandré
I think this example of Steve Muench will help you.
"Recalc Sum of Salary at the View Object Level
This example illustrates a technique where a transient attribute of a view object is updated to reflect the total sum of some attribute of all the rows in the view object's default row set. The code to recalculate the sum of the salary is in the getSumOfSal() method in the EmpViewImpl.java class. The custom EmpViewRowImpl.java class for the view row implements the getter method for the SumOfSal attribute by delegating to this view object method. The EmpViewImpl class extends a base DeclarativeRecalculatingViewObjectImpl class that contains some generic code to enable declaratively indicating that one attribute's change should recalculate one or more other attributes. The EmpView defines the "Recalc_Sal" property to leverage this mechanism to recalculate the "SumOfSal" attribute. If you restrict the VO's results using the BC Tester tool, you'll see the sum of the salaries reflects the subset. If you add a new row or delete an existing row, the sum of sal is updated, too."
http://otn.oracle.com/products/jdev/tips/muench/recalctotalvo/RecalcTotalOfRowsInVO.zip
Good Luck -
Help find the Last run date from previous month
Hi all
I am stuck trying to find the Last Run Date from the previous month.
select distinct(date_ran) from TABLE X where date_ran like '%/11-%' order by date_ran desc gives
"03/30/11-06:19
"03/25/11-03:01
"03/24/11-03:00
"03/23/11-03:00
"03/22/11-03:00
"03/21/11-03:00
"03/18/11-03:00
"03/17/11-00:00
"03/16/11-06:31
"02/15/11-07:42
"02/15/11-06:00
"02/14/11-08:19
Here the result I am trying to acheive is 02/15/11-07:42 ;Note the column date_ran is a VARCHAR2(255) and not a TIMESTAMP
I tried
select ADD_MONTHS(to_date(max(date_ran), 'MM/DD/YYYY-HH24:MI'),-1)
from daily_tests_a
where date_ran like '%/11-%'
order by date_ran desc
which returns 2/28/0011 6:19:00 AM and that is not the result I am looking for
Regards
SMKWelcome to the forum!
user2931503 wrote:
Hi all
I am stuck trying to find the Last Run Date from the previous month.
select distinct(date_ran) from TABLE X where date_ran like '%/11-%' order by date_ran desc gives
"03/30/11-06:19
"03/25/11-03:01
"03/24/11-03:00
"03/23/11-03:00
"03/22/11-03:00
"03/21/11-03:00
"03/18/11-03:00
"03/17/11-00:00
"03/16/11-06:31
"02/15/11-07:42
"02/15/11-06:00
"02/14/11-08:19
Here the result I am trying to acheive is 02/15/11-07:42 ;Note the column date_ran is a VARCHAR2(255) and not a TIMESTAMPThat's a very bad idea. Points in time should always be stored in DATE (or maybe TIMESTAMP) columns. If not, you're going to waste resources converting them to DATEs whenever you need them to behave like DATEs, and risk run-time errors because of bad data.
Normally, the "previous" month means the month before the current month. In April, the previous month is March.
By "previous" month, do you mean the 2nd latest month in the table? That is, this data contains data from February and March, 2011; March 2011 is the latest of those months, February 2011 is the next-to-last, and so is that why you want a date from February?
I tried
select ADD_MONTHS(to_date(max(date_ran), 'MM/DD/YYYY-HH24:MI'),-1)
from daily_tests_a
where date_ran like '%/11-%'
order by date_ran desc
which returns 2/28/0011 6:19:00 AM and that is not the result I am looking for
Regards
SMKTry this:
WITH got_real_date AS
SELECT TO_DATE ( SUBSTR (date_ran, 1, 14)
, 'MM/DD/RR-HH24:MI'
) AS real_date
FROM table_x
-- WHERE ... -- If you need any filtering, put it here
SELECT TO_CHAR ( MAX (real_date)
, 'MM/DD/RR-HH24:MI'
) AS last_date
FROM got_month_num
WHERE real_date < (
SELECT TRUNC (MAX (real_date), 'MONTH')
FROM got_real_date
;Edited by: Frank Kulash on Apr 5, 2011 3:59 PM -
How to get the data from Pooled Table T157E.
Hi Experts,
How to get the data from Pooled Table T157E.
Any help.
Thanks in Advance,
Ur's Harsha.create some internal table similar to T157E and pass all data as per SPRAS.
After that use internal table in your program as per the requirement.
Regds,
Anil -
I lost my iphone. How can I get my saved data from back up on my new laptop?
Dear Friends,
I did a mistake as when selling my iphone I did not get my saved data from my iphone back up. Now I have a new laptop and I want to get my backed up data.
Is there any way I could get or as Apples traditional greed ... more money more money ...more .. more??????
Please help if I can get back my at least contacts and video for free. I do not are for my music. My God it is so difficult to get going with Apple.stedman1 wrote:
A warranty does not cover physical damage. Did you have AppleCare +?
AppleCare+ doesn't cover loss or theft, only accidental damage. -
How to get data from COSP table, field HRKFT as the key to data from PM?
Dear ladies and gentlemen!
I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
What should I do in this case?
Thank you very much in advance!From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
Of course, it's not a very good solution, but for now I know no other way to solve this problem.
Maybe someone knows better ways? In this case I will be very grateful for any help!
Moderator: You'd better post it on BI forums -
To get the table data into a file in pl/sql developer
Hi
i have table with 90k rows, i want to get the table data into a file like excel....
i executed the select statement it shows only 5k rows because of buffer problem.
can u please help me any alternative way to get the table data into a file.
using cursors like thatReally? excel for 90K rows :)
face/desk/floor/"Hi and sorry neighbours below, it's me again"
Err, I see you point, thanks Dang, I completely missed the 90k recs part, I must be getting old or modern ;)
@Ramanjaneyulu,
can u please help me any alternative way to get the table data into a file.You can always dump a query to a file, check these:
http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
How to create Excel file (scroll down when necessary)
http://forums.oracle.com/forums/search.jspa?threadID=&q=export+to+excel&objID=f137&dateRange=all&userID=&numResults=15&rankBy=10001
Depending on your database version ( the result of: select * from v$version; ) you might have some other options. -
Is it possible to view/get the table data from a dump file
I have dmp files generated using expdp on oracle 11g..
expdp_schemas_18MAY2013_1.dmp
expdp_schemas_18MAY2013_2.dmp
expdp_schemas_18MAY2013_3.dmp
Can I use a parameter file given below to get the table data in to the sql file or impdp the only option to load the table data in to database.
vi test1.par
USERID="/ as sysdba"
DIRECTORY=DATA
dumpfile=expdp_schemas_18MAY2013%S.dmp
SCHEMAS=USER1,USER2
LOGFILE=user_dump_data.log
SQLFILE=user_dump_data.sql
and impdp parfile=test1.par.Hi,
To explain more about my situation.
Target database has the dump files, where as the source database (cloud) doesn't have access to the target database.
However, I can request the target DB DBA team to run the par files and provide me the output like a SQL file which I can take and run it in my source database.
I got the metadata the same way, but is there any way I could get the data from the dump files on the target DB without actually accessing it? My question might sound weird, but please let me know.
<
1. export from the source into a dumpfile. You can do this on the source database and then copy the file over to your local database or you can do this from a local database if you have a database link defined on the local database that points to the source database. In the second case, your dumpfile will be created on your local database.
>
How can i access the dump using the database link? -
Select the last saved records in a table
I all
I have this struct in a table
create table INT_OBJ
IDOBJ NUMBER(15) not null,
IDERP NUMBER(15),
IDE NUMBER(15),
CPO VARCHAR2(20),
VLR VARCHAR2(2500),
VLRC VARCHAR2(2500)
How to Select the last saved records in a table. I think usea a temp table for put the last row read and begin to read in the next row.
The table is reading each four hours.Theoretically it can be done with ORA_ROWSCN and enabled ROWDEPENDENCIES, but there are so many nuances, so only adding column for ordering is right.
Regards,
Sayan Malakshinov -
How to get the table of value field? and can we expand the technical limits
Dear
I have created value field in COPA with KEA6. And now, I need the table which the value fields are saved. Yet, I have tried a lot to find it and get failure? Can any guy help me? Please tell me how to get the table of a value field.
And another question is that, can we extend the technical limits for the number of value field for ECC6.0?
We have a note for R.4.x Please see below:
OSS note 160892
You can display the length of a data record using Transaction KEA0 ('Maintain Operating Concern'). After you have navigated to the 'Characteristics Screen' or to the 'Value field Screen' choose menu path 'Extras -> Technical Limits'.
The maximum displayed here under 'Length in bytes on the DB' is the maximum length permitted by the Dictionary. The reserve required for the release upgrade must be subtracted from this value.
To increase the allowed number of the value fields, increase the value that is assigned to field ikcge-bas_max_cnt (FORM init_ikcge_ke USING fm_subrc, approx. line 165) in Include FKCGNF20. It specifies the number of the possible value fields. The corresponding part of the source code is attached to the note as a correction.
David Sun
Regards!how to extend the limit of value numbers? please see the original question.
-
Data from 3 tables having latest dates
Hi,
Need some help with PL/SQL code, I need to write a code which will get data from 3 tables all with the latest date.
For a particular ACT_CODE the output of the SQL query should show data having the latest dates from 3 tables, if there is no
date in the table, it should show the remaining data (think left join will do the trick here)
Table Names:
Institution_UPDT aiu
ASQ_CONTACT ac
GR_AUTHORIZE gr
All 3 tables have ACT_Code as common
Column Names
INSTITUTION_UPDT aiu -- aiu.ACT_CODE,aiu.project_id as proj,aiu.UPDT_TYPE_ID, aiu.USER_ID, aiu.UPDT_DATE
ASQ_CONTACT ac -- ac.ACT_CODE as contact_code,ac.project_id,ac.first_name, ac.middle_initial,ac.last_
name,ac.title,ac.status,ac.status_date
GR_AUTHORIZE gr --gr.ACT_CODE as grad_code,gr.name, gr.title AS grad_title, gr.submit_date
The date column names are
ac.status_date,
aiu.UPDT_DATE and
gr.submit_date
Thank you everyone
appreciate your help
JeshHi, Jesh,
user11095252 wrote:
That is correct, I want to include all the columns from ASQ_Contacts, Institution_UPDT and GR_AUTHORIZEOh! You want all columns from all three tables, not just ASQ_Contacts. That changes the problem considerably!
UNION requires that all prongs have the same number of columns, and that the datatypes of the columns match. That's no problem if we just need act_code and a date from each one. If we just need additional columns from one table, it's easy to add literal NULLs to the other prongs to serve as the additional columns. But if we need all (or even several) columns from all three tables, that's no good. So let's revert to your original idea: outer joins.
I want to display only one row which has the latest date with the most recently updated time (example:mm/dd/yyyy hr:min:sec am/pm)Yes, but what if there is a tie for the most recently updated time?
In case of a tie, the query below will pick one of the contenders arbitrarily. That may be fine with you (e.g., you may have UNIQUE constraints, making ties impossible). If you need a tie-breaker, yiou can add more columns to the analytic ORDER BY clauses.
WITH aiu AS
SELECT institution_updt.* -- or list columns wanted
, ROW_NUMBER () OVER ( PARTITION BY act_code
ORDER BY updt_date DESC
) AS r_num
FROM institution_updt
WHERE act_code = :p1_act_code
AND project_id = :p2_project_id
, ac AS
SELECT asq_contact.* -- or list columns wanted
, ROW_NUMBER () OVER ( PARTITION BY act_code
ORDER BY status_date DESC
) AS r_num
FROM asq_contact
WHERE act_code = :p1_act_code
AND project_id = :p2_project_id
, gr AS
SELECT gr_authorize.* -- or list columns wanted
, ROW_NUMBER () OVER ( PARTITION BY act_code
ORDER BY submit_date DESC
) AS r_num
FROM gr_authorize
WHERE act_code = :p1_act_code
SELECT * -- or list columns wanted
FROM aiu
FULL OUTER JOIN ac ON ac.act_code = aiu.act_code
AND ac.r_num = 1
AND aiu.r_num = 1
FULL OUTER JOIN gr ON gr.act_code = NVL (ac.act_code, aiu_act_code)
AND gr.r_num = 1
;That's a lot of code, so there may be typos. If you'd post CREATE TABLE and INSERT statements for a few rows of sample data, I could test it.
In all places where I said "SELECT *" above, you may want to list the individual columns you want.
If you do that in the sub-queries, then you don't have to qualify the names with the table name: that's only required when saying "SELECT *" with another column (r_num, in this case).
It's more likely that you won't want to say "SELECT *" in the main query. The three r_num columns, while essential to the query, are completely useless to your readers, and you might prefer to have just one act_code column, since it will be the same for all tables that have it. But since it may be NULL in any of the tables, you'll have to SELECT it like this:
SELECT COALESCE ( aiu.act_code
, ac.act_code
, gr_act_code
) AS act_codeThe query above will actually work for multiple act_codes. You can change the condidition to something like
WHERE act_code IN (&act_code_list)If so, remember to change it in all three sub-queries. -
ALV OOps report- getting data from two tables and adding issue
Hi,
This is sales employee performance report.
I need to select all the fields from two tables based on user input ie VKorg, sales employee .
There is one field callled " Net sales"in both the tables.
Based on sales employee number, i need to add that net sales which i get from two tables.
I need to generate single report.
Can you give some inputs reg. the select query.
My idea is select all the data from both tables using join statement.
ThanksHi,
I have written like this:
select * from S002 as a join S006 as b
into table ME->SS002_RAW[]
where vkorg in me->select_parameters->SO_VKORG[] = vkorg in me->select_parameters->SO_VKORG[]
and ZZSLSEMP01 in me->select_parameters->SO_so_empl[] = ZZSLSEMP02 in me->select_parameters->SO_so_empl[].
when i do like that,
I am getting error
Incorrect structure of FROM clause . . . .
If you give some idea on this
Edited by: Raja on Apr 22, 2009 11:19 AM -
Not able to get the tables in crystal report 2008
Hi,
I am using crystal report 2008 and trying to connect MS SQL using OLE DB (ADO) connection. After giving all DB credentials data base tables are not appearing in the connection. how to get the tables for selection in crystal report 2008.
Regards,
SreeIn the CR Designer, select the connection and press the right mouse button. Select Options in the context menu and check if there is an entry in the Table name fiel. Maybe you have a placeholder there that does not match the names of the tables in the database. Just remove it, close the window by pressing OK and refresh the connection browser (press F5). Unfold the connection again and check if you can see the tables now.
Regards,
Stratos -
Copying large amount of data from one table to another getting slower
I have a process that copies data from one table (big_tbl) into a very big archive table (vb_archive_tbl - 30 mil recs - partitioned table). If there are less than 1 million records in the big_tbl the copy to the vb_archive_table is fast (-10 min), but more importantly - it's consistant. However, if the number of records is greater than 1 million records in the big_tbl copying the data into the vb_archive_tbl is very slow (+30 min - 4 hours), and very inconsistant. Every few days the time it takes to copy the same amount of data grows signicantly.
Here's an example of the code I'm using, which uses BULK COLLECT and FORALL INSERST to copy the data.
I occasionally change 'LIMIT 5000' to see performance differences.
DECLARE
TYPE t_rec_type IS RECORD (fact_id NUMBER(12,0),
store_id VARCHAR2(10),
product_id VARCHAR2(20));
TYPE CFF_TYPE IS TABLE OF t_rec_type
INDEX BY BINARY_INTEGER;
T_CFF CFF_TYPE;
CURSOR c_cff IS SELECT *
FROM big_tbl;
BEGIN
OPEN c_cff;
LOOP
FETCH c_cff BULK COLLECT INTO T_CFF LIMIT 5000;
FORALL i IN T_CFF.first..T_CFF.last
INSERT INTO vb_archive_tbl
VALUES T_CFF(i);
COMMIT;
EXIT WHEN c_cff%NOTFOUND;
END LOOP;
CLOSE c_cff;
END;
Thanks you very much for any advice
Edited by: reid on Sep 11, 2008 5:23 PMAssuming that there is nothing else in the code that forces you to use PL/SQL for processing, I'll second Tubby's comment that this would be better done in SQL. Depending on the logic and partitioning approach for the archive table, you may be better off doing a direct-path load into a staging table and then doing a partition exchange to load the staging table into the partitioned table. Ideally, you could just move big_tbl into the vb_archive_tbl with a single partition exchange operation.
That said, if there is a need for PL/SQL, have you traced the session to see what is causing the slowness? Is the query plan different? If the number of rows in the table is really a trigger, I would tend to suspect that the number of rows is causing the optimizer to choose a different plan (with your sample code, the plan is obvious, but perhaps you omitted some where clauses to simplify things down) which may be rather poor.
Justin -
How to get the table name in the trigger definition without hard coding.
CREATE TRIGGER db.mytablename
AFTER UPDATE,INSERT
AS
INSERT INTO table1(col1)
SELECT InsRec.col1
FROM
INSERTED Ins
--Below i am calling one sp for which i have to pass the table name
EXEC myspname 'tablename'
In the above trigger,presently i am hard coding the tablename
but is it possible to get the table name dynamically on which the trigger is defined in order to avoid hard coding the table nameI really liked your audit table concept. You inspired me to modify it so that, the entire recordset gets captured and added a couple of other fields. Wanted to share my end result.
USE [YourDB]
GO
/****** Object: Trigger [dbo].[iudt_AutoAuditChanges] Script Date: 10/18/2013 12:49:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[iudt_AutoAuditChanges]
ON [dbo].[YourTable]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
Declare @v_AuditID bigint
IF OBJECT_ID('dbo.AutoAudit','U') IS NULL BEGIN
CREATE TABLE [dbo].[AutoAudit]
( [AuditID] bigint identity,
[AuditDate] DateTime,
[AuditUserName] varchar(128),
[TableName] varchar(128) NULL,
[OldContent] XML NULL,
[NewContent] XML NULL
ALTER TABLE dbo.AutoAudit ADD CONSTRAINT
PK_AutoAudit PRIMARY KEY CLUSTERED
[AuditID]
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [idx_AutoAudit_TableName_AuditDate] ON [dbo].[AutoAudit]
( [TableName] ASC,
[AuditDate] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
Select * Into #AuditDeleted from deleted
Select * Into #AuditInserted from inserted
While (Select COUNT(*) from #AuditDeleted) > 0 OR (Select COUNT(*) from #AuditInserted) > 0
Begin
INSERT INTO [dbo].[AutoAudit]
( [AuditDate], [AuditUserName], [TableName], [OldContent], [NewContent])
SELECT
GETDATE(),
SUSER_NAME(),
[TableName]=object_name([parent_obj]),
[OldContent]=CAST((SELECT TOP 1 * FROM #AuditDeleted D FOR XML RAW) AS XML),
[NewContent]=CAST((SELECT TOP 1 * FROM #AuditInserted I FOR XML RAW) AS XML)
FROM sysobjects
WHERE
[xtype] = 'tr'
and [name] = OBJECT_NAME(@@PROCID)
Set @v_AuditID = SCOPE_IDENTITY()
Delete from AutoAudit
Where AuditID = @v_AuditID
AND Convert(varchar(max),oldContent) = Convert(varchar(max),NewContent)
Delete top(1) from #AuditDeleted
Delete top(1) from #AuditInserted
End
END
Maybe you are looking for
-
Problem with table cell editors - Dropdown by Index, getting lead selection
Hi experts, I have a table editor with 5 columns 1st column is a Drop Down byIndex. My contex looks like this AS_DATA(Parent Node cardinality 1.1, selection 0-1) HEADER (NODE) DETAILS(NODE cardinality 0..n, selection 0-1) ACTIVIT
-
Can I link to a table in another Numbers file?
I have searched through the documentation and on support and cannot find a way that I can reference a cell belonging to another Numbers file. I essentially want to use one Numbers file to store a very large amount of data and have separate smaller fi
-
Commit never reaches the DB (BC4J)
When I perform changes on view object row (BC4J) or add a new row, the changes never reaches the database. The locks in the database are never released and the database remains unchanged after commit. The application works just fine in local mode, bu
-
Missing guest in Failover Cluster
I have a 3 node Server 2012R2 Hyper-V failover cluster with 18 guests. Today, I migrated a guest from VMWare using my normal method to one of the nodes in the cluster. Upon completion I added a role to the cluster, the guest appeared in the list of a
-
Showing input in a label control
Ok, so I'm using actionscript really for the first time, but I do have a solid background in PHP. I am basically trying to recreate a file that we lost the original for. Basically, a person enters a single or two-digit number and then it prints out i