Hi,
-- Sometimes it would be great to have teh ability to write a SELECT like this: myCollection := self someObjectsWithSpecialProperties collect: [:ea| ea id]. dbSession readManyOf: MyClass where: [:ea| (ea amount > 300) & (myCollection includes: ea id)]. Which then translates to: SELECT ... FROM MYTABLE WHERE AMNT > 300 and ID in (100,103,765,999, etc.) It seems like GLORP doesn't support this. Am I wrong? Looking at implementors of #initializeFunctions it seems like there is no IN-Function and to be honest, I can't see how I could add my own. Joachim You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
Hi Joachim,
1) If you want to build a query based on multiple criteria you can do something like.
myQuery := Glorp.Query readOneOf: ExceptionDay
you can also use OR:
2) the class GlorpExpressio contains the operator in: which does exactly what you want. I used to have code for that but that was many moons ago. The problem with using in is that the collection you give it is limited in size on certain platforms (notably ODBC) to a couple of thousand occurrences which caused me problems at that time. Maybe if you run all the test you will be able to find an example of how to use it in VW.
Regards,
@+Maarten
28 Av Alphonse Denis 83400 Hyères, France +33 676411296
Hi,
-- Sometimes it would be great to have teh ability to write a SELECT like this: myCollection := self someObjectsWithSpecialProperties collect: [:ea| ea id]. dbSession readManyOf: MyClass where: [:ea| (ea amount > 300) & (myCollection includes: ea id)]. Which then translates to: SELECT ... FROM MYTABLE WHERE AMNT > 300 and ID in (100,103,765,999, etc.) It seems like GLORP doesn't support this. Am I wrong? Looking at implementors of #initializeFunctions it seems like there is no IN-Function and to be honest, I can't see how I could add my own. Joachim You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
2015-10-05 10:36 GMT-03:00 <[hidden email]>:
The current Pharo version doesn't include the #in: operator and it's also buggy in its MessageArchiver, however I agree with Maarten about the use of IN, it's limited in many platforms. I ended up using OR expressions, or even better EXISTS whenever possible. It wouldn't be difficult to implement an IN operator using a collection of literals. Regards Esteban A. Maringolo pd: Maarten, which VW and GLORP version are you using? I downloaded the latest one (8.0.1) and all the sources of Glorp packages are decompiled. You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
If the first criterion is also going against the database, you can also do it as a subselect, which doesn't have size limits. But if the size of that collection is relatively small, or it's purely in-memory, then using in: would probably work best. On Mon, Oct 5, 2015 at 6:49 AM Esteban A. Maringolo <[hidden email]> wrote:
You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by jtuchel
Joachim,
You *can* do this... In Cincom Smalltalk, the Store GarbageCollector makes extensive use of this feature. Here is an example: Query read: StoreBundle where: [:each | each primaryKey in: bundleKeys]You may need to substitute #readManyOf: for #read. On 10/5/2015 1:40 AM, jtuchel wrote:
-- You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
Thanks all for your responses.
-- Seems I need to go back to a Smalltalk course. I always teach my scholars to search for implementers/senders. I should have listened to myself. I used the subselect thingie a lot because of this anticipated absence of in:, but this time I had a list of object IDs that could only be collected in the Smalltalk image (or at least a respective select statement would have been enormous and far beyond my SQL skills...), so I thought I'd ask. I was also wondering what would happen if I have thousands of IDs to pass into an SQL statement. And I guess not only ODBC has limits here. I am quite sure there is a limit to the sizre of an SQL String that can be passed to DB2 and Oracle as well. Luckily, in my case, the list would be no longer than a few dozen... Joachim You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
If you have thousands of IDs to pass to a SQL statement, it may be
faster to run the query multiple times with a subset of the IDs.
The number of elements in the subset depends on a couple of factors.
The ones that come immediately to mind are:
Another way to deal with thousands of values is to insert them
into a temporary table and join to the temporary table. This
assumes that the user's database id has permission to create temp
tables. Here are a couple of articles on this:
On 10/12/2015 12:11 AM, jtuchel wrote:
-- You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
Thanks, Tom!
-- cool links and good ideas. I won't need them for now, but chances are the next time I do a larger data migration, this issue bubbles up again. For now I am happy I can use #in: for my purposes. Joachim Am Montag, 12. Oktober 2015 19:01:28 UTC+2 schrieb Tom Robinson:
You received this message because you are subscribed to the Google Groups "glorp-group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/glorp-group. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |