To find the last record in cursor
hi
DECLARE
vCounter NUMBER;
-- Other variables...
BEGIN
vCounter:=0;
FOR .. IN cursor LOOP
IF vCounter=0 THEN
-- Here open file...
-- Here write one time data...
END IF;
-- Here write cursor data...
vCounter:=1;
END LOOP;
END;
hi all i am using above code to find the first record.
if vCounter =1 means its first record.
Now my question is how to find out the 'n'th record(last record).
please help me.
Thanks..
user13329002 wrote:
hi
DECLARE
vCounter NUMBER;
-- Other variables...
BEGIN
vCounter:=0;
FOR .. IN cursor LOOP
IF vCounter=0 THEN
-- Here open file...
-- Here write one time data...
END IF;
-- Here write cursor data...
vCounter:=1;
END LOOP;
END;
hi all i am using above code to find the first record.
if vCounter =1 means its first record.
Now my question is how to find out the 'n'th record(last record).
please help me.
Thanks..create a record type variable to store last record;
assign the fetch data to that variable
and when u exit from the loop ,the variable will have the last records value
since you are using cursor for loop , it will Implicitly open, fetch, exit, and close occur to cursor.
eg:-
DECLARE
type cur_type is record of yourcursorname%type;
rec_cur_type cur_type;
vCounter NUMBER;
-- Other variables...
BEGIN
vCounter:=0;
FOR .. IN cursor LOOP
IF vCounter=0 THEN
-- Here open file...
-- Here write one time data...
END IF;
-- Here write cursor data...
assign your fetched record from cursor to rec_cur_type
vCounter:=1;
END LOOP;
END;
Similar Messages
-
How to find the last records of the table in adventure work db
hi all,
i want to find out " how to receive a last records of the table (eg: person.emailaddress ) in sql 2008 and 2005"
ThanksIf you are looking for the latest record( the one which got inserted/modified last) then use this query
select top 1 * from person.emailaddress
Order by ModifiedDate desc
Satheesh
My Blog |
How to ask questions in technical forum -
How to find the last update date time and user of record field peoplecode
how to find the last update date time record field peoplecode?
Thank you.One can check the last update date time using the following query
SELECT LASTUPDDTTM FROM PSPCMPROG WHERE OBJECTVALUE1 LIKE 'RECNAME' AND OBJECTVALUE2 LIKE 'FIELDNAME' -
Only put the last record retreived into the item form
Hi All,
I am trying to show all the retreived records of a query in a multi-line formTEXT item. However, it seems to me that only the last record shows rather than all records. The code is below where DM_AR is a package and OPEN_R_TYPE, Fetch_data are two procedures which uses a cursor variable. The below code runs perfectly in SQLPLus if we replace the :RESULT_TEXT := .., with a DBMS_output.put_line build-in procedure.
Any suggestion Plz......
F
DECLARE
-- declare a cursor variable
RES DM_AR.ruleitem_type;
TEMP_row TEMP_TBL%ROWTYPE;
BEGIN
-- open the cursor using a variable
DM_AR.OPEN_R_TYPE(RES, :MODEL_NAME);
-- fetch the data and display it
LOOP
DM_AR.Fetch_data(RES, TEMP_ROW);
EXIT WHEN RES%NOTFOUND;
:RESULT_TEXT := 'RuleNo: ' || TEMP_ROW.RULE_ID || ' Conf: '|| TEMP_ROW.R_CONF || 'Supp: ' || TEMP_ROW.R_SUPP || ' IF: ' || TEMP_ROW.ANTECEDENT || ' THEN: ' || TEMP_ROW.CONSEQUENT;
END LOOP;
END;You are overwriting your item :RESULT_TEXT everytime in the loop. So, you only see the final result. You probably want this:
:RESULT_TEXT := :RESULT_TEXT || ' RuleNo: ' || ...
... -
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 -
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 to find the longest record in a table?
Hello,
Is there a function to find the longest record in a table? Or is there a data dictionary that would tell you which record contains the longest data?
I have a table with five columns and one million records. I want to find the record (5 columns combined) with the longest data. Thank you.Dear watson2000!
The function "VSIZE" tells you the number of bytes in the internal representation of a column which means the size of a value within a column. An example of vsize can be found here:
[http://www.adp-gmbh.ch/ora/sql/vsize.html]
So I think you should try it with this query to get the size of the longest record:
SELECT MAX(VSIZE(column1)) +
MAX(VSIZE(column2)) +
MAX(VSIZE(column3)) +
MAX(VSIZE(column4)) +
MAX(VSIZE(column5)) AS "Maximum Row"
FROM your_table;To identify the longest record try like this:
SELECT rowid
FROM your_table
GROUP BY rowid
HAVING (MAX(VSIZE(column1)) +
MAX(VSIZE(column2)) +
MAX(VSIZE(column3)) +
MAX(VSIZE(column4)) +
MAX(VSIZE(column5))) = (SELECT MAX(VSIZE(column1)) +
MAX(VSIZE(column2)) +
MAX(VSIZE(column3)) +
MAX(VSIZE(column4)) +
MAX(VSIZE(column5))
FROM your_table;)I hope that these two queries could be of help to you.
yours sincerely
Florian W.
Edited by: Florian W. on 23.04.2009 20:53 -
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 -
How to re-add the iPhone into the Find My iPhone and than to find the last known possition?
Hello,
I've got my iPhone stolen yesterday in the bar.
In the morning I tried find it by Find My iPhone app but I hit the "remove" button by mistake. Is it possible to reverse this acction even without the iPhone in the hand?
I need to re-add the iPhone into the iCloud (Find My iPhone) and than to find the last known possition. It's serial number is C3******39D
Thank you
Libor
<Edited bu Host>Ringtones are a one-time only download from the store. You will need to connect the device that you downloaded it on to your computer's iTunes and do File > Devices > Transfer Purchases to copy it over to the Tones part of your computer's iTunes library and you can then sync it to your other device(s).
-
How to restrict the last record and not moving to next reocrd
1) how to restrict the last record and not moving to next reocrd.
2) Also for the F6 key(for new record).When you are on the last record, next-record will create a new one, so that my question is do you want to forbid new record creation.
Francois -
Function in select statement need to be called only for the last record.
Select state,
local,
fun_state_loc_other_details(19) details
from state_local
where pm_key=19
resuts:_
State Local Details
AP APlocal details1
UP UPLocal details1
MP MPLocal details1
i) The above query returns 100 records
ii) fun_state_loc_other_details is also getting called 100 times. But I want this function to be called only for the last record that is 100th record.
is there any way to do that?Thanks amatu.
One more small query. Can I do it on condition based.
Select state,
local,
fun_state_loc_other_details(19) details
from state_local
where pm_key=19
Like if one state it need to be called once.
AP -- 50 records
UP - 20 records
MP -- 10 records.
fyi: this record no. varies
I want the function to be called for AP once, UP once, MP once. -
How to find the last login details of a Sharepoint SSRS user
How to /where to find the last login details of SSRS sharepoint user. Is there any table where we can check the last login details of user. This is because we are facing an issue of Subscription failure due to Sharepoint token expiration. If user logs in
before 24 hours of his last login time, he is able to get his report subscription. If not, below error is thrown.
The permission granted to user 'domainname\username' are insufficient to perform this operation.Hi,
According to your post, my understanding is that you want to monitor the last login user’s details.
There is no out of the box way to achieve it in SharePoint.
We can use cookie to be a flag for checking whether there is an user just log in. After the page loaded, if the cookie is null, it suggests that there is an user just log in our site, then we
can get this user’s information using JavaScript Object Model and add the information into a custom list. With this list, we can monitor user’s login details.
Refer to the following link:
https://social.technet.microsoft.com/Forums/en-US/0cd4d531-cb61-4d90-aa70-413267f4a735/how-to-know-login-and-logout-details-of-a-user-in-sharepoint-online-2013?forum=sharepointdevelopment
Besides, here are two similar posts for your reference:
https://social.technet.microsoft.com/Forums/sharepoint/en-US/1a35283e-0f2a-49b8-b330-801a3cfcd890/programatically-get-all-current-logged-in-users-list-for-a-sharepoint-site?forum=sharepointdevelopmentprevious
https://social.technet.microsoft.com/Forums/en-US/10953be3-cb1c-40c7-9454-545c8338b551/how-to-know-login-users-count-and-their-details-in-sharepoint-2010-web-application?forum=sharepointgeneralprevious
Best Regards,
Lisa Chen
Lisa Chen
TechNet Community Support -
How to get to the last record of an APEX report automatically?
In Oracle Forms there is a "lastrec" command which can be placed after a call to a multi-row form. The records called have the last record at the bottom of the page. For example, if there are 100 records and there are 10 rows on the form, record numbers 91 through 100 would be showing. Can this be done in APEX? I have a user who wants it this way. I set the report page up to be ordered descending, which gives her last record at the top of the page, but this is not acceptable to her. She wants to see the last record, but she wants it at the bottom of the page.
Hi,
Try this query, it should order your data as you want and the report pagination is not broken!
The number of row displayed must be the same as the divide by value (ie. 10)
select your_id
from your_table
order by trunc ((DENSE_RANK() OVER ( ORDER BY your_id desc) -1) /10)
, DENSE_RANK() OVER ( ORDER BY your_id desc) desc;
Page 1 displays 91 to 100
Page 2 displays 81 to 90
Also if your data set have 87 rows, Page 1 will display 78 to 87 (ie. the 10 last rows).
If you want more details regarding the sorting you can have a look on this query:
select your_id
, trunc ((DENSE_RANK() OVER ( ORDER BY your_id desc) -1) /10)
, DENSE_RANK() OVER ( ORDER BY your_id desc)
from your_table
order by 2, 3 desc;
Maybe you are looking for
-
Sharing a photo book project with family members
I created and purchased a photo book in iPhoto and I'd like to share with my family members so they can also buy the book. Is that possible?
-
What are the us holidays in the ics US holiday file?
what are the us holidays in the ics US holiday file?
-
Trouble with 1080p on MacOS but no Windows
the maximum I can get out of my intel 20" iMAC with MacOS is 720p. I get some flickering at 1080p. The 59.9HZ option is greyed out and only 60HZ can be used. (incidentally this used to happen with old powermac which had an ATI 9800 and it would flick
-
Is there a good but free word processor that's Mac compatible?
I don't know where else this question would belong so I just put it here. So, my question is: Is thier a free (but decent) word processor that's Mac compatible that I can download off of the internet? I've already used up my free trial of "Pages" tha
-
VERY URGENT - Adobe forms with email problems
I THERE - I AM A ADOBE FORMCENTRAL CLIENT I HAVE MY PAYEMENTS ON DAY BUT FOR SOME REASON THE ADOBE STOP RESENDING TO MY EMAUIL ACOUNT AND TO MY CLIENTS EMAIL ACCOUNT THE SUMARY OF THE FORM THAT IS SUBMITED. THIS IS VERY URGENT THAT BE FIXED FROM YOU