|
Unfortunately conciseness isn't Google's primary strength.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Try...
select * from (
select top 10000 *, row_number() over (order by rownum) as rn
from productlist
) t
where rn between 9990 and 10000
modified on Monday, February 21, 2011 1:26 AM
|
|
|
|
|
Hi
Thanks for Query. It is reduce execution time. but when I try to access above 500000 (Top 500000) records then its taking 2 to 3 min exeuting any other solution.
For if 900000 it is taking 4 to 5 min.
Regards,
Nanda
|
|
|
|
|
SELECT *
FROM (
SELECT *
FROM Productlist pl
ORDER BY somefield
)
WHERE ROWNUM BETWEEN 9991 AND 10000 Note that you can never trust the DB to give you the records in the same order every time, so you need the order by clause.
The field you're ordering by should be indexed if you want to get any speed to your query
|
|
|
|
|
Thanks.
Problem is the table is too big it contains 10 lak to 90 lak data. while access perticular data (ex: 1500000 to 1501000) then it is taking so much time.
The Inner Query execute all records (90 lak) and the outer query filter 9991 to 10000. This is my problem.
Regards,
Nanda
|
|
|
|
|
That's why you need a index on the column you order by, it's already sorted. The optimizer will take care of the inner query.
Do you have an index on the column you're sorting by?
|
|
|
|
|
Hi,
If you do have an ascending surrogate key, one efficient way would be to use that. For example if you have a field called Id and the values are coming from ordered sequence your query could be something like:
select *
from ProductList a,
(select b.Id,
count(*) over (order by b.Id) as runcount
from productlist b
where b.Id > :lastFetchedId) subq
where a.Id = subq.Id
and subq.runcount <= 10
|
|
|
|
|
Hi Mika,
I done similarly in View. Add a new column unique ID and I am adding rownum. In this case I am executing query without any delay.
But one problem is there. In case if order by condition added the output of query is coming wrong(Bug) or a block of rows is order.
Regards,
Nanda
|
|
|
|
|
Hi,
Nanda_MR wrote: I am adding rownum
Just to check: Did you notice that I didn't use rownum at all because it's unreliable in this context (for many different reasons). The example I created shouldn't encounter any of the problems rownum has since the example is based on a running total count on an unique and ascending field.
|
|
|
|
|
Dear All
I have a form "report_test", and a single button "rptstart", when i click that button, i wrote a code, to start a report in printing preview with some viewing some records.
When i click print (printer icon) on the left top corner, the printer prints the form "report_test" with the button but not the actual report am viewing any body can can guide how to avoid this and print the report itself ???
regards,
0 will always beats the 1.
|
|
|
|
|
I am currently trying to code a variable into a SQL string that is used with ADO to create a record within a database. I though am having problems with the proper syntax for a variable. The string works fine with a number but when I try to code a variable I have problems. I need to find out how to code an array as well.
hr = rec2->Open("INSERT INTO mytable(id)VALUES("+ text +")",con2.GetInterfacePtr(), ADODB::adOpenForwardOnly, ADODB::adLockReadOnly, ADODB::adCmdText);
|
|
|
|
|
in SQL string literals need quotes, so I would suggest you try:
...VALUES('"+ text +"')"...
^ ^
Warning: make sure not to insert anything between the single and double quotes there!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
Thank you for your reply.
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
I am getting the error message: "error C2110: '+' : cannot add two pointers"
|
|
|
|
|
one cannot add pointers together, it doesn't make sense; adding house numbers wouldn't make sense either.
What is your code, and what is the exact line where the error occurs? and what language and IDE are you using?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc,
The error is occuring at VALUES('"+ text + "'). My VS2008 is giving me this error. I am trying to send a record to MS Access.
|
|
|
|
|
You need to enclose your varchar value in single quotes.
hr = rec2->Open("INSERT INTO mytable(id)VALUES('"+ text +"')",con2.GetInterfacePtr(), ADODB::adOpenForwardOnly, ADODB::adLockReadOnly, ADODB::adCmdText);
I find string.Format() to be VERY useful!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Suppose some one purchased a ticket online. [Here the value of a column is pending]
If the person does not pay the cash money within 24 hours than the ticket will be automatically cancelled. [The value of the status column will be cancelled after 24 hours]
So,
How can I do automatic update of a table after 24 hours???
|
|
|
|
|
Easiest way would be to run a job[^] at a specified interval that checks the table and does whatever it needs to do.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
You have done this using sql server. But How can I do this for oracle??
|
|
|
|
|
AhmedMasum wrote: Suppose some one purchased a ticket online. [Here the value of a column is pending]
If the person does not pay the cash money within 24 hours than the ticket will be automatically cancelled. [The value of the status column will be cancelled after 24 hours]
It's not pending, it's reserved from that moment forward. Otherwise you could run into the problem that there's more pending than there's actually available.
AhmedMasum wrote: How can I do automatic update of a table after 24 hours???
I'd run through it once an hour, processing the valid payments (sending out a ticket to an address) and the invalid ones.
I are Troll
|
|
|
|
|
I wouldn't; I'd design the system so that that isn't required. The Pending column should be a date column that is set to the time when it will expire if not Purchased. Then, when seeking available tickets, look for any where the Pending field is null or less than the current time and Purchased (another date field) is also null.
Or name them Ordered and Purchased or something, but I wouldn't put them in a single Status column, Status could be calculated from a number of fields, including Shipped.
|
|
|
|
|
Thanks for your nice suggestion!!!.
My above case is just an example.
Actually I need something that will do insert/update/delete on a table every week or after a specific period of time.
Is there any type of trigger can do this type of operation??
|
|
|
|