Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-dev] three-args LOCATE function replacement using STRPOS and SUBSTRING on Postgres

I suppose it doesn't cover the missing case, please log a bug for this for PostgreSQL.


-----Original Message-----
From: Dies Koper [mailto:diesk@xxxxxxxxxxxxxxxxxxx]
Sent: Monday, January 11, 2010 2:37 AM
To: Dev mailing list for Eclipse Persistence Services
Subject: [eclipselink-dev] three-args LOCATE function replacement using STRPOS and SUBSTRING on Postgres

Hi James,

As Symfoware also doesn't have a three-args LOCATE function I considered
doing something equivalent to what you implemented for Postgres:

LOCATE (a, b, i) ->
(STRPOS(SUBSTRING( a FROM i ), b ) + (i - 1))

But doesn't this give a wrong value when a does not include b?

Example:
a = "James"
b = "me"
i = 4

LOCATE (a, b, i) should return 0 as the search starts at 'e' in "James".
(STRPOS(SUBSTRING( a FROM i ), b ) + (i - 1)) would return 0 + (4 - 1) = 3.

So I figured it wouldn't work on Symfoware. Don't you have this issue on
Postgres?

I'm going to try the following on Symfoware, which is similar to what is
discussed on the mailing list:

COALESCE(NULLIF(POSITION(NULLIF(tofind,' ') IN SUBSTRING(string_exp FROM
startpos)), 0) - 1 + startpos, 0)

http://www.mail-archive.com/jboss-development@xxxxxxxxxxxxxxxxxxxxx/msg27548.html

Thanks,
Dies

_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top