yes, other than the `to_char` the queries are the same. oracle needs a hack to enable comparing CLOB columns to strings.

regarding reusing everything except the `uri` part. I very much prefer complete sql queries over a statement that is assembled by concatenating several parts for a reason: readability. Try to follow the sql queries that are used in the sharing code and you can see an example of sql that is well, cut to pieces. There it might even be necessary to handle different cases. Forthermore, some of the IDEs around allow you to execute SQL with prepared statements when they are written as a single string (some also allow concatenated strings, but they fail when adding $variables)