views:

72

answers:

2

I need to synchronize an SQL Server database to Oracle through an Oracle Transparent Gateway. The synchronization is performed in batches, so I need to get the next set of data from the point where I left off.

The problem I'm having is that the only field I have in the source, to help me, is a GUID. If it were a number I could just order by it, keep the last one processed and restart the process by getting the records which are > my recorded number. This won't work with a GUID.

Any ideas?

A: 

Apparently this works: SELECT * FROM v_source_supplier_prices WHERE HEXTORAW(REPLACE(ID,'-','')) > HEXTORAW(REPLACE('0022F17B-24B3-43EC-8D81-FFD3149950E7','-','')) ORDER BY HEXTORAW(REPLACE(ID,'-',''))

ID is the GUID field on the source system.

I'm not sure at what cost...

Something to be added to the "list of things not to trust". :)
Nick Pierpoint
A: 

You can sort strings (varchar, varchar2) too so why do you need a number? Isn't it faster to convert the guids to strings. Maybe they are already stored as strings?

tuinstoel
I think the issue is that new records can not be guaranteed to be added "after" a particular GUID where the last synch finished off. If he ordered by GUID he may miss a record inserted "before" the "highest" GUID.
Nick Pierpoint
It is true that one can interpret the question differently. "if it where a number". You think that the OP means a number that increases with time like a sequence. Could be.
tuinstoel