Last record entered
hi all,
In the detail block i have 5 records to be entered.Now i want retieve the last recordentered wherever primary key in the detail is
codes only,(i mean no serial).
Best Regards,
Hany
Hi Hany,
Well i am not sure abt this but plz try if it works out your problem.
select PK_col from Detail
where rowid=(select max(a.rowid)from Detail a,
(select translate(PK_col,'1234567890',' ') ID from Detail
where PK_col is not null) b
where a.PK_col=b.PK_col)
Well plz if it works out or u modify it and get the results right
do mail me the query at [email protected]
Navneet Jain
Similar Messages
-
Formula to get last record entered for a specific code in a field
I work at an inpatient facility where our patients experience several movement actions -- transfers from unit to unit, Leaves, return from leaves, and change in commitment status. We collect all of these actions in one table. For our census report we use a subreport to show the list of patients who are on leave. The problem I am having is pulling the most current movement that was a leave if the last movement action code entered was a change in commitment status. We really should not have put the change in commitment in this table as it is not a movement. When a change in commitment occurs and the patient is on leave, they drop off my report because the last change was not a leave. We have to enter the leave again so it is the last record entered to fix.
The table contains these fields:
Doc_ID
Parent_ID
Folder_ID
Effective Date
From_Unit
To_Unit
Time_of_Change
Leave_status_Code
Move_Action_Code
Commit_Status_Code
The Move_Action_Code field contains these codes:
L = Leave
C = Change in Commitment Status
B = Return From Leave
I = Initial Admission
D = Discharge
R = Recommitment
V = Unit to unit transfer
A patient may have several leaves in the same admission (home visit, then back, etc.). I need a formula to show only most current leave if they haven't returned from leave and need to totally ignore any change in commitment status.
Thanks in advance to everyone for your help in this forum!Hi Jerri,
To identify a patient, I assume it would be Folder_ID. Create a group on this field. Also create a group on Effective Date.
Hide the Detail section and the Group Headers for both of these. You can also hide the Group Footer for Effective Date.
In the Group Footer for Folder_ID, drop in the Move_Action_Code and any other fields you want.
When you look at your report, this will show you the last Move_Action_Code for that patient.
If you can group your data properly, the Group header will always show the first record and the Group Footer will always show the last record.
Hope this helps,
Brian -
How to retrieve last record entered into database
Hi all,
I want to retrieve the last resord entered into a database table.
I have a MS Access database.
This code does not return the last record but its my nearest attempt to.
Can anyone suggest the correct SQL or Solution.
Help is greatly appriciated.
Thanks.
String str = "SELECT * FROM Missions WHERE Mission = (SELECT MAX(Mission) FROM MISSIONS)";
ResultSet rs = null;
String f1 = null, f2 = null, f3 = null, f4 = null;
try{
rs = statement.executeQuery(str);
txtMissionInformation.setText("");
int row = 0;
while(rs.next()){
f1 = rs.getString(1);
f2 = rs.getString(2);
f3 = rs.getString(3);
f4 = rs.getString(4);
System.out.println(f1 + " " + f2 + " "+f3+" "+f4);
txtMissionInformation.append(f1 + ", "+ f2 + ""+","+f3+","+f4);
System.out.println("Query Complete !");
} catch(Exception e){
e.printStackTrace();
}I fixed my problem, i aded an autonumber field to my database set it as primary key and called it ID. i then used the syntax from before and it worked.
-
How to get the last record??
Hi, I now have to get only the last record from one table
from MS Access.
I was looking for the useful method from API, however,
I cannot get it.
How to get only the last record from one table ???
Please help, thanks.In RDBMS, row order is really not relavent by iteself. Meaning there is no such thing as 'last record' unless it's in the context of a column (e.g. timeStamp).
Of course, rows are inserted and stored in some natural order, but you cannot assume they'll come back the same way in a 'Select *' as they were entered.
So, if you mean last row as in last inserted row, I would add a timestamp field that's set at insert, or use a autonumber column. Either way, have a column that will always contain the highest number or newest timestamp, and then you can build your where clause from that.
For instance, in Access, I have an autonumbered field called 'fred', with other columns. If I want the last record, I simply use the following:
select * from atable where fred in (SELECT max(fred) AS Max FROM atable);
the 'where in' clause will filter to only those records in the subsequent select statment, which of course is only one, the max of the column fred.
bRi -
Cursor not working properly.. Gives every record last records' entry.
hi all.
a simple one for someone I'm sure...
Ive just added the cursor:
-- Cursor to get Oracle_Loc_Code from SU CHRIS vs ORACLE Locations Table into a variable..
CURSOR csr_ora_loc_code IS
SELECT sil.ORACLE_LOC_CODE
FROM SU_TEMPLOYEE_DETAILS std, SU_IEXP_LOCATIONS sil
WHERE std.STD_LOCATION_ID = sil.CHRIS_LOC_code;
..to the script I'll paste below in order to populate every record with whats in sil.ORACLE_LOC_CODE field.
But, although it works fine when you have 1 record to run in, when several records are to be loaded in together, the script, although enters the records into ORACLE fine, populates every record with the same location code - whatevers in the last record (instead of treating each one individually). How can I fix this?
Thanks for looking..
The code..
/* Formatted on 2009/04/29 11:52 (Formatter Plus v4.8.7) */
SET serveroutput ON SIZE 1000000 FORMAT WRAPPED
SET verify OFF
SET feedback OFF
DECLARE
-- Debugging/error handling
-- Work variables
ora_loc_code number := 0;
p_emp_number VARCHAR2 (14);
v_rec_cnt NUMBER := 0;
insert_flag VARCHAR2 (8);
err_num NUMBER;
err_msg VARCHAR2 (150);
err_line VARCHAR2 (350);
err_seq NUMBER := 0;
l_validate BOOLEAN DEFAULT FALSE;
l_std_business_group_id NUMBER := '0';
l_default_code_comb_id NUMBER := '217269';
l_organization_id NUMBER := '0';
l_set_of_books_id NUMBER := '1';
l_job_id NUMBER := '10';
l_obj NUMBER;
l_datetrack_update_mode VARCHAR2 (30) := 'CORRECTION';
l_assignment_sequence NUMBER;
l_name_combination_warning BOOLEAN := FALSE;
l_assign_payroll_warning BOOLEAN := FALSE;
l_org_now_no_manager_warning BOOLEAN;
l_other_manager_warning BOOLEAN;
l_spp_delete_warning BOOLEAN;
l_entries_changed_warning VARCHAR2 (30);
l_tax_district_changed_warning BOOLEAN;
l_person_id NUMBER;
l_assignment_id NUMBER;
l_special_ceiling_step_id NUMBER;
l_per_effective_end_date DATE:= TO_DATE ('11-Jul-2049', 'DD-MON-YYYY');
l_people_group_id NUMBER;
l_group_name VARCHAR2 (30);
l_assignment_number VARCHAR2 (35);
l_effective_end_date DATE := TO_DATE ('11-Jul-2049', 'DD-MON-YYYY');
l_date DATE := SYSDATE;
ip_p_address_id per_addresses.address_id%TYPE;
ip_p_object_version_number NUMBER;
ip_p_party_id per_addresses.party_id%TYPE;
l_per_object_version_number NUMBER;
l_asg_object_version_number NUMBER;
l_full_name VARCHAR2 (240);
l_per_comment_id NUMBER;
l_per_effective_start_date DATE;
l_concatenated_segments VARCHAR2 (240);
l_soft_coding_keyflex_id NUMBER;
l_comment_id NUMBER;
l_no_managers_warning BOOLEAN;
-- Get employee details info from work table
CURSOR get_employee_details
IS
SELECT std_hire_date, std_last_name, std_sex, std_date_of_birth,
std_email_address,
LPAD (std_employee_number, 8, '0') std_employee_number,
std_first_name, std_marital_status, std_middle_names,
std_nationality, std_title, std_national_identifier,
std_address_line1, std_address_line2, std_address_line3,
std_address_line4, std_post_code, std_telephone_1, std_country,
std_region, std_location_id, std_organization_id,
std_supervisor_id, std_person_id, std_position_id
FROM SU_TEMPLOYEE_DETAILS;
-- checks employee details info from PER_ALL_PEOPLE_F table
CURSOR c_check_employee (p_emp_number VARCHAR2)
IS
SELECT per.person_id, per.business_group_id, per.last_name,
per.start_date, per.date_of_birth, per.email_address,
per.employee_number, per.first_name, per.marital_status,
per.middle_names, per.nationality, per.national_identifier,
per.sex, per.title, padd.address_id, padd.primary_flag,
padd.address_line1, padd.address_line2, padd.address_line3,
padd.town_or_city, padd.postal_code, padd.telephone_number_1,
paas.assignment_number, paas.object_version_number
-- padd.telephone_number_2, padd.telephone_number_3, paas.job_id, paas.location_id,
-- paas.organization_id, paas.assignment_type, paas.supervisor_id,
-- paas.default_code_comb_id, paas.set_of_books_id, paas.period_of_service_id,
FROM per_all_people_f per,
per_all_assignments_f paas,
per_addresses padd
WHERE per.employee_number = p_emp_number
AND per.person_id = padd.person_id
AND paas.person_id(+) = per.person_id;
emp_rec c_check_employee%ROWTYPE;
-- Cursor retrieves latest Object Version Number from per_assignments_f table..
CURSOR csr_ovn (cp_person_id IN per_all_people_f.person_id%TYPE)
IS
SELECT MAX (paas.object_version_number)
FROM per_assignments_f paas, per_all_people_f per
WHERE paas.person_id = per.person_id
AND per.employee_number = paas.assignment_number
AND per.person_id = cp_person_id;
-- Cursor to get Oracle_Loc_Code from SU CHRIS vs ORACLE Locations Table into a variable..
CURSOR csr_ora_loc_code IS
SELECT sil.ORACLE_LOC_CODE
-- INTO ora_loc_code
FROM SU_TEMPLOYEE_DETAILS std, SU_IEXP_LOCATIONS sil
WHERE std.STD_LOCATION_ID = sil.CHRIS_LOC_code;
BEGIN
-- Process each record in the work table
FOR v_emp IN get_employee_details
LOOP
-- determine whether customer already exists
OPEN c_check_employee (v_emp.std_employee_number);
FETCH c_check_employee
INTO emp_rec;
IF c_check_employee%NOTFOUND
THEN
insert_flag := 'I';
DBMS_OUTPUT.PUT_LINE ('Employee No: ' || v_emp.std_employee_number);
ELSE
DBMS_OUTPUT.PUT (CHR (10));
insert_flag := 'X';
RAISE_APPLICATION_ERROR (-20001, 'Employee No: ' || v_emp.std_employee_number || ' already
exists - please UPDATE manually..' );
END IF;
CLOSE c_check_employee;
-- Obtain the most recent Object Version Number..
OPEN csr_ovn (v_emp.std_person_id);
FETCH csr_ovn
INTO l_obj;
-- IF csr_ovn%NOTFOUND THEN RAISE NO_DATA_FOUND; END IF;
CLOSE csr_ovn;
-- Open Oracle Location Code cursor
OPEN csr_ora_loc_code; -- (v_emp.std_person_id);
FETCH csr_ora_loc_code
INTO ora_loc_code;
CLOSE csr_ora_loc_code;
-- Create new PER_ALL_PEOPLE_F and PER_ADDRESSES record from
-- info in table record
IF insert_flag = 'I'
THEN
-- BEGIN -- Importing Employee Procedure --
Hr_Employee_Api.create_gb_employee
(p_validate => l_validate,
p_hire_date => v_emp.std_hire_date,
p_business_group_id => l_std_business_group_id,
p_date_of_birth => v_emp.std_date_of_birth,
p_email_address => v_emp.std_email_address,
p_first_name => v_emp.std_first_name,
p_middle_names => v_emp.std_middle_names,
p_last_name => v_emp.std_last_name,
p_sex => v_emp.std_sex,
p_ni_number => v_emp.std_national_identifier,
p_employee_number => v_emp.std_employee_number,
p_person_id => l_person_id,
p_title => v_emp.std_title,
p_assignment_id => l_assignment_id,
p_per_object_version_number => l_per_object_version_number,
p_asg_object_version_number => l_asg_object_version_number,
p_per_effective_start_date => l_per_effective_start_date,
p_per_effective_end_date => l_per_effective_end_date,
p_full_name => l_full_name,
p_per_comment_id => l_per_comment_id,
p_assignment_sequence => l_assignment_sequence,
p_assignment_number => l_assignment_number,
p_name_combination_warning => l_name_combination_warning,
p_assign_payroll_warning => l_assign_payroll_warning
Hr_Person_Address_Api.create_person_address
(p_validate => l_validate,
p_effective_date => v_emp.std_hire_date,
p_pradd_ovlapval_override => NULL,
p_validate_county => NULL,
p_person_id => l_person_id,
p_primary_flag => 'Y',
p_style => 'GB_GLB',
p_date_from => SYSDATE,
p_date_to => NULL,
p_address_type => NULL,
p_comments => NULL,
p_address_line1 => v_emp.std_address_line1,
p_address_line2 => v_emp.std_address_line2,
p_address_line3 => v_emp.std_address_line3,
p_town_or_city => v_emp.std_address_line4,
p_region_1 => NULL,
p_region_2 => NULL,
p_region_3 => NULL,
p_postal_code => v_emp.std_post_code,
p_country => v_emp.std_nationality,
p_telephone_number_1 => NULL,
p_telephone_number_2 => NULL,
p_telephone_number_3 => NULL,
p_party_id => ip_p_party_id,
p_address_id => ip_p_address_id,
p_object_version_number => l_obj
Hr_Assignment_Api.update_emp_asg
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => l_assignment_id,
p_object_version_number => l_obj,
p_supervisor_id => v_emp.std_supervisor_id,
p_default_code_comb_id => l_default_code_comb_id,
p_set_of_books_id => l_set_of_books_id,
p_concatenated_segments => l_concatenated_segments,
--IN/OUT
p_soft_coding_keyflex_id => l_soft_coding_keyflex_id,
--IN/OUT
p_comment_id => l_comment_id,
--IN/OUT
p_effective_start_date => l_date, --IN/OUT
p_effective_end_date => l_effective_end_date,
--IN/OUT
p_no_managers_warning => l_no_managers_warning,
--IN/OUT
p_other_manager_warning => l_other_manager_warning
--IN/OUT
Hr_Assignment_Api.update_emp_asg_criteria
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => l_assignment_id,
p_object_version_number => l_obj,
p_organization_id => l_organization_id,
p_location_id => ora_loc_code,
p_job_id => l_job_id,
p_position_id => v_emp.std_position_id,
p_special_ceiling_step_id => l_special_ceiling_step_id,
p_effective_start_date => l_date,
--per_effective_start_date,
p_effective_end_date => l_effective_end_date,
--IN/OUT
p_people_group_id => l_people_group_id,
--IN/OUT
p_group_name => l_group_name, --IN/OUT
p_org_now_no_manager_warning => l_org_now_no_manager_warning,
--IN/OUT
p_other_manager_warning => l_other_manager_warning,
--IN/OUT
p_spp_delete_warning => l_spp_delete_warning,
--IN/OUT
p_entries_changed_warning => l_entries_changed_warning,
--IN/OUT
p_tax_district_changed_warning => l_tax_district_changed_warning
--IN/OUT
v_rec_cnt := v_rec_cnt + 1;
DBMS_OUTPUT.PUT (CHR (10));
DBMS_OUTPUT.PUT_LINE ( 'There were '
|| v_rec_cnt
|| ' records read in..'
DBMS_OUTPUT.PUT (CHR (10));
-- End of customer related details
END IF;
END LOOP;
COMMIT;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
ROLLBACK;
WHEN OTHERS
THEN
ROLLBACK;
err_num := TO_CHAR (SQLCODE);
err_msg := SUBSTR (SQLERRM, 1, 150);
err_line := 'ORACLE error occurred processing record.. ' || err_msg;
DBMS_OUTPUT.PUT_LINE (err_line);
INSERT INTO SU_SL_ERRORS VALUES (err_num, err_msg, SYSTIMESTAMP);
END;
EXIT;CURSOR csr_ora_loc_code IS SELECT sil.ORACLE_LOC_CODE
-- INTO ora_loc_code
FROM SU_TEMPLOYEE_DETAILS std, SU_IEXP_LOCATIONS sil
WHERE std.STD_LOCATION_ID = sil.CHRIS_LOC_code; OPEN csr_ora_loc_code; -- (v_emp.std_person_id);
FETCH csr_ora_loc_code
INTO ora_loc_code;
CLOSE csr_ora_loc_code;Obviously yes.It will select one sil.ORACLE_LOC_CODE, as you are fetching one. That can be any one of the sil.ORACLE_LOC_CODE, as you didn't tell Oracle to pick a particular one.
If you want to get some particular sil.ORACLE_LOC_CODE, you need to put some filter on that. CURSOR csr_ora_loc_code(p_your_parameter NUMBER) IS -- whatever datatype you wan to pass
SELECT sil.ORACLE_LOC_CODE
-- INTO ora_loc_code
FROM SU_TEMPLOYEE_DETAILS std, SU_IEXP_LOCATIONS sil
WHERE std.STD_LOCATION_ID = sil.CHRIS_LOC_code
AND your_column = p_your_parameter;
OPEN csr_ora_loc_code(v_emp.std_person_id); -- (v_emp.std_person_id); -- I'm not sure why did you comment this out.
FETCH csr_ora_loc_code
INTO ora_loc_code;
CLOSE csr_ora_loc_code;By
Vamsi -
Problem on forms for serial number generation with last record next_record.
Hi Experts,
currently i'm facing one problem like :
i'm populating one receipt detail in Multi block , like when user key in one receipt number that time record should go in first record ,and if they key in second receipt number then record should go in second record . mean to say every time record go in last record ..but the problem is i want to generate Serial no correspondence to every last record ..
here is my approch :
cursor c1 is
select * from table
where cname =:blk_name.clm_name.
Last record;
next_record;
for v1 in c1 loop
processed record;
next_record;
end loop;
last_record;
go_block(___);
first_record;
:sno := system.cursor_record ;
next_reocrd;
end loop;
first_record;
And in block level i'm writing code for Serial number generation when user key in manual entry for receipt detail:
:blk_name.coulumn_name := :system. cursor_record;
so in this approach their is no problem it is working properly but the problem is that
when user fetch one receipt automatically and then after he want to enter next record manually and he decided to go in detail block ,
and once he reached in detail block that time block level trigger i firing .ans serial number 2 generated and then suddenly he came to know no i want to fetch next record automatically mean to say now user going again master block and fetching next receipt detail ,
but the problem is when user leaving seccond sr no and going in master block and population next receipt detail that time cursor going on 3 record
but logically have to replace the second Serial no and generate the again serial number 2 record population .mean to say its not refreshing last_record..
so i'm appreciating is anyone if came accoross this type of issue please corrrect my code and send updated code ..plsssssssssssssssssssssssssssssss
Thanks
Abhishek
[email protected]hi
I put this below code on when_new_record_instance on block level..
:blk_name.column_name :=system.cursor_record;
so can you please help me.....
Thanks
Abhishek -
Need Help On Oracle form side for serial no genretion for every last record
Hi Experts,
currently i'm facing one problem like :
i'm populating one receipt detail in Multi block , like when user key in one receipt number that time record should go in first record ,and if they key in second receipt number then record should go in second record . mean to say every time record go in last record ..but the problem is i want to generate Serial no correspondence to every last record ..
here is my approch :
cursor c1 is
select * from table
where cname =:blk_name.clm_name.
Last record;
next_record;
for v1 in c1 loop
processed record;
next_record;
end loop;
last_record;
go_block(___);
first_record;
:sno := system.cursor_record ;
next_reocrd;
end loop;
first_record;
And in block level i'm writing code for Serial number generation when user key in manual entry for receipt detail:
:blk_name.coulumn_name := :system. cursor_record;
so in this approach their is no problem it is working properly but the problem is that
when user fetch one receipt automatically and then after he want to enter next record manually and he decided to go in detail block ,
and once he reached in detail block that time block level trigger i firing .ans serial number 2 generated and then suddenly he came to know no i want to fetch next record automatically mean to say now user going again master block and fetching next receipt detail ,
but the problem is when user leaving seccond sr no and going in master block and population next receipt detail that time cursor going on 3 record
but logically have to replace the second Serial no and generate the again serial number 2 record population .
so i'm appreciating is anyone if came accoross this type of issue please corrrect my code and send updated code ..plsssssssssssssssssssssssssssssss
Thanks
Abhishek
[email protected]Friend, If you forward this question in forms forums , It will be better for you.
Abishek Go this link and post there friend.
Link:Forms -
Cursor Jumping to last record when query mode for Multi-record block.
I have a multi-record block. the seq field has this validation to check that there should not be a gap
in sequence for S_type and cer_dl field.The program unit is as below.
PROCEDURE seq_validation IS
--Validation to check that there is no gaps in sequence for S_TYPE and cer_dl fields
l_value_to_check varchar2(100);
l_seq_found number;
l_curr_sequence number;
l_new_value varchar2(100);
l_found boolean:=FALSE;
l_new_set boolean := FALSE; --s_type and cer_dl are different from previous set.
begin
if trim(:b1.s_type) is not null
or trim(:b1.cer_dl) is not null
then
-- Program continues here only if all the items are not null
-- Get information from record that needs to be validated
l_value_to_check := trim(:b1.s_type) || ':'|| trim(:b1.cer_dl) ;
l_curr_sequence := :sequence;
if :SYSTEM.CURSOR_RECORD = '1' then
---to check sequence is entered as 1 in the first record
message('Error:Sequence should start with 1');
raise form_trigger_failure;
end if;
go_item('b1.XYZ');
else
FIRST_RECORD;
while :SYSTEM.LAST_RECORD != 'TRUE'
loop
l_found := FALSE;
l_new_value := trim(:b1.S_type) || ':'|| trim(:cer_dl) ;
if l_new_value = l_value_to_check then --
l_new_set:= FALSE;
l_seq_found := :seq;
if l_seq_found >= l_curr_sequence then
go_item('b1.seq');
l_new_set := FALSE;
elsif l_seq_found < l_curr_sequence - 1 then
go_item('b1.sequence');
l_found := FALSE;
elsif l_seq_found = l_curr_sequence - 1 then
l_found:= TRUE;
go_item('b1.xyz); --go to next item
end if;
else
l_new_set := TRUE;
end if;
NEXT_RECORD;
end loop;
if l_new_set then
go_item('b1.xyz'); -- go to next item
else
if not l_found then
message('Error:Sequence should be in order.');
go_item('b1.seq');
raise form_trigger_failure;
end if;
end if;
go_item('b1.xyz'); ---go to next item
end if;
end if;
end;
In the insert mode its working fine(unless you gurus feel to change to make it more perfect.
When I say enter-query and put 'IAS' in the s_type field and then do a execute query it brings all the records of 'IAS'.
Now as I want to update the records, and when I navigate across field(s_type,cer_dl,Seq,xyz) using tab and move the cursor down on second
record(IAS N 2 N), what happens is when I navigate to sequence field the cursor jumps to LAST RECORD( IAS Y 3 N ) of LAST field XYZ.
I am putting the sample record
s_type cer_dl seq xyz
IAS N 1 N
IAS N 2 N
IAS N 3 N
IAS N 4 N
IAS Y 1 N
IAS Y 2 N
IAS Y 3 N
The cursor moves to last record --IAS -Y -3-N when I tab across the second record.When I say enter-query and put 'IAS' in the s_type field...For your validation to work you must not allow users to enter records in the middle of a block, clear records from the block or query specific records. If you allow the users to enter a query then you are allowing 2 of the rules to be broken.
-
Copy the Last Record queried to the new record in a Multi - Record Block
Hi Team
When i enter a new record in a Multi - Record Block the last record should get copied to the new record.
Please help me.
ThanksHi
pls use...
DUPLICATE_RECORD;Amatu Allah -
Getting the last record from the internal table
When we use a READ statement it always picks up the first record which fulfill its condition but in my case I want to pick up the last record that fulfills it condition
I have a internal table like
id type
N1 A
N1 T
N1 A
N1 6 ----> LAST RECORD
my code is
read table itab wIth key id = netobjid.
for eg if netobjid = N1 , then I want to read the last record that corresponds to N1 ie ID N1 TYPE - 6...
How to do that?HI
actually i have done same requirement like this ...
Take one count variable into your internal table ..you pass the number of records into cont variable for every time u enter the loop .
Sort the internal table with count variable descending . ( AS we cant sort the internal table with sy-tabix)
Then use read statement with sy-index = 1 .
USe below logic ,............
data : count type i value '0'.
LOOP at int .
count = count + 1 .
endloop.
sort int count descending .
read int with index = 1 . -
How to get the last record from the database
I am using MS Access database and Swings as GUI. I want to get the last record of a particular column from the table and store it as a varaible.
Hi
To get Last record of resultset, you have pass some parameter in constructor of CreateStatement.In such case Resultset should be scrollable and Readonly
Example
objStatement=objCon.createStatement ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
mwwResultSet=cwwStatement.executeQuery(mwwSqlQuery);
while(mwwResultSet.next())
if(mwwResultSet.isLast())
//Fetch the required column record.
String abc=mwwResultSet.getString(1);
I think this will work. Try it.
bye -
How to get the last record of an internall table ....
Hi All..
i want to get the last record of an internal table itab, and i want the the value of the last record.Hi,
Use describe statment.
data: lv_line type i.
Describe table itab lines lv_line.
read table itab into wa_itab index lv_line.
regards,
Santosh Thorat -
Not enough space to print the last record on each page
Hello,
My report looks like a simple list table, with the first row as the column header, followed by rows of records.
The fields are placed on the Detail section and they're set with "Can Grow" property. That means, records may have different row height, some may take 1 row per record, some may take 3 rows per record, depending on the data length. I use some vertical lines on the Detail section as the column seperators, and a horizontal line as the record seperator.
I've a Page Footer to show the page number and print date.
My problem is:
When the space of the last record on the current page isn't big enough, the record will be printed automatically on the second page, which is fine. But the vertical seperation lines are still displayed even though the details are printed on the second page. I got some "empty rows with vertical seperation lines" or I'd say an open-end table at the end of some pages then.
Is there a way to avoid this?
Your help is much appreciated. Thank you.
AgnesYou could draw an outline box from page header to page footer, then your internal lines would run from page header to page footer
so if the document extends to 2 pages, the page footer will print on the 1st page and therefore the bottom line of the box
only problem now would be that on the 2nd page the box will extend to the bottom of that page also, even if there is only 1 record -
How do I display last record in database?
I have a asp guestbook form that I finally have working only
when the info is sent to me via email, it shows me the first entry
in the database each time. How do I get it to select/email only the
last entry?
Any advice is appreciated!"innovationlab" <[email protected]> wrote in
message
news:e8u951$1ll$[email protected]..
> Can't really be sorted, it just has name, email and
message.
Then you have no way of knowing which is the last record. You
need an
autonumber field or a date/time field in order to be able to
sort the
records so you know which one is the last.
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/
Cartweaver Development Team
http://www.cartweaver.com
Extending Knowledge Daily
http://www.communitymx.com/ -
How to get the first and the last record of every month within a time range in sql
I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
SELECT PurOrderNum,
OrderDate
FROM Purchasing.PurOrder
WHERE OrderDate >= '2013-02-28'
AND OrderDate <= '2014-12-29'SELECT PurOrderNum,
OrderDate
FROM
SELECT PurOrderNum,
OrderDate,
MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
FROM Purchasing.PurOrder
WHERE OrderDate >= '2013-02-28'
AND OrderDate <= '2014-12-29'
)t
WHERE OrderDate = MaxDate
OR OrderDate = MinDate
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
K7N2 Delta ILSR & Netgear MA311
Please help! K7N2 Delta ILSR AMD 2500+ not over clocked ATI 9600 Pro 256Mb graphics not over clocked 768Mb RAM - not labelled 300Watt PSU Netgear MA311 PCI Wireless network card Win XP Everything works fine bar the Netgear wirless network card. I am
-
Displaying the contents of JCombo in JTable
<Re-post from 'New To Java' forum> Hi, I have created a JTable which loads a list of Strings into one of its fields as a JComboBox. The JComboBox defaults to one of the items in the list of String when the frame is loaded. Problems: 1. When the frame
-
Change the Page Title for all the pages when viewing the Reports in Bi Publisher
Hello , I have a requirement for changing the Page Title for all the report displayed pages on the browser window.
-
How to change name of a logical system
Hi SDN, I am trying to customizing intial download data transfer from ECC to CRM. But in outbound queue of ECC it is showing an error of SYSFAIL with description of logical system name changed. Given note 558701. But I don't know old nam
-
Do BOTH the Black & White AND Color cartridges have to be full of ink to print ONLY in Black and White? I have no desire or need to print color documents, but with the color ink light blinking, NOTHING will print even though I have replaced the blac