Subject | RE: [firebird-support] How do I read a specific range of records from a table in the database |
---|---|
Author | Rudy Popeszku |
Post date | 2013-01-22T20:51:13Z |
Thanks,
I don't have control over the server side software but the data being saved
is not normally deleted or changed by the server or client.
I am stuck with processing the data as it has been saved.
Rudy
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Thomas Steinmaurer
Sent: Tuesday, January 22, 2013 1:24 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How do I read a specific range of records
from a table in the database
when it is deleted. ;-)
You might consider a trigger-based server-side change data capture
mechanism, which inserts log records into a separate table. The beauty of a
trigger-based solution is, it doesn't force you to change the client code.
--
With regards,
Thomas Steinmaurer
http://www.upscene.com/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
I don't have control over the server side software but the data being saved
is not normally deleted or changed by the server or client.
I am stuck with processing the data as it has been saved.
Rudy
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Thomas Steinmaurer
Sent: Tuesday, January 22, 2013 1:24 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How do I read a specific range of records
from a table in the database
> Oh, ok. I wasnt aware that Firebird re-uses space that way. I need toA date/time field won't help in case of a DELETE, because the record is gone
> find out how the data is stored and deleted which is done by another
> program I am unfamiliar with.
>
> I only have access to a test database for my development. There is a
> date/time field in the table I am trying to use so I can ORDER BY that
> field.
when it is deleted. ;-)
You might consider a trigger-based server-side change data capture
mechanism, which inserts log records into a separate table. The beauty of a
trigger-based solution is, it doesn't force you to change the client code.
--
With regards,
Thomas Steinmaurer
http://www.upscene.com/
> Thanks for the additional information.then
>
>
>
> Rudy
>
>
>
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Svein Erling Tysvær
> Sent: Tuesday, January 22, 2013 7:56 AM
> To: 'firebird-support@yahoogroups.com'
> Subject: RE: [firebird-support] How do I read a specific range of records
> from a table in the database
>
>
>
>
>
>> Svein,
>>
>> I need unsorted data in the order it was stored so I tried the following
> and it works exactly as I
>> wanted.
>>
>> SELECT MyField1, ~ MyFieldn,
>>FROM MyTable
>> ROWS LastRow-1000 TO LastRow
>
> Do you ever update or delete rows in MyTable, Rudy? If you only INSERT,
> you may be lucky and get the last inserted rows (though it is notthe
> guaranteed), but if something has been changed, then Firebird will reuse
> space that the changed/deleted rows occupied and newly inserted recordsare
> likely not to be among the "last" 1000 rows.MUST
>
> Logically, Firebird returns sets of records and if there is no ORDER BY,
> then the order is random. Although I'm not surprised that the rows you
> inserted last happens to be the ones that are returned in the statement
> above, don't rely on it. If you care about which rows are returned, you
> use ORDER BY before ROWS.add
>
>>From what you've described so far, I'd recommend you to add another field
> containing a primary key (lets call it PK and assume it is an integer),
> a descending index on that field and populate it through a BEFORE INSERTadvance
> trigger. Then use
>
> SELECT MyField1, ~ MyFieldn,
> FROM MyTable
> ORDER BY PK DESC
> ROWS 1 TO 1000
>
> That would also be quicker than counting the total number of rows in
> (counting rows take time in Firebird).------------------------------------
>
> Set
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links