0

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?

Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114

2 Answers2

0

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...

sticky bit
  • 36,626
  • 12
  • 31
  • 42
0

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
  • 7,248
  • 27
  • 27
  • 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 Mar 11 '09 at 09:38
  • 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 Mar 11 '09 at 11:23