Home » U++ Library support » U++ SQL » How to use Like() with SqlArray
How to use Like() with SqlArray [message #4128] |
Mon, 24 July 2006 00:20 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Hello, I'm trying SQL parts of Ultimate++. It's seems to be very powerful and easy to use, but I have some problems yet.
I want to use Like() function, but the code below is not working for me:
String like_str;
like_str << ~m_edit_find << '%';
m_array.SetWhere(Like(PARTNER_NAME, like_str));
The error message is like this:
Preparing: select PARTNER_ID, PARTNER_NAME, PARTNER_ZIP, PARTNER_CITY, PARTNER_ADDRESS from PARTNER where PARTNER_NAME like binary 'a%' order by PARTNER_NAME
What is the problem? Im using sqlite with upp-605 Windows.
|
|
|
|
Re: How to use Like() with SqlArray [message #4131 is a reply to message #4129] |
Mon, 24 July 2006 08:59 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Thanks, you are right.
I have changed Like() in Sqlexp.cpp from
SqlBool Like(const SqlVal& a, const SqlVal& b) {
int sqld = GetSqlDialect(a, b);
return SqlBool(a, sqld == SQLD_MYSQL || sqld == SQLD_SQLITE3 ? " like binary " : " like ", b, SqlS::COMP);
}
to
SqlBool Like(const SqlVal& a, const SqlVal& b) {
int sqld = GetSqlDialect(a, b);
return SqlBool(a, sqld == SQLD_MYSQL ? " like binary " : " like ", b, SqlS::COMP);
}
and now it is working correcly. I have no idea why that "binary" was in sources. I tested "like binary" directly in sqlite and it produces an error. So this was a bug, I think.
|
|
|
Re: How to use Like() with SqlArray [message #4132 is a reply to message #4131] |
Mon, 24 July 2006 09:49 |
|
zsolt wrote on Mon, 24 July 2006 02:59 | Thanks, you are right.
I have changed Like() in Sqlexp.cpp from
SqlBool Like(const SqlVal& a, const SqlVal& b) {
int sqld = GetSqlDialect(a, b);
return SqlBool(a, sqld == SQLD_MYSQL || sqld == SQLD_SQLITE3 ? " like binary " : " like ", b, SqlS::COMP);
}
to
SqlBool Like(const SqlVal& a, const SqlVal& b) {
int sqld = GetSqlDialect(a, b);
return SqlBool(a, sqld == SQLD_MYSQL ? " like binary " : " like ", b, SqlS::COMP);
}
and now it is working correcly. I have no idea why that "binary" was in sources. I tested "like binary" directly in sqlite and it produces an error. So this was a bug, I think.
|
From mysql page:
The following two statements illustrate that string comparisons are not case sensitive unless one of the operands is a binary string:
mysql> SELECT 'abc' LIKE 'ABC';
-> 1
mysql> SELECT 'abc' LIKE BINARY 'ABC';
-> 0
http://dev.mysql.com/doc/refman/5.0/en/string-comparison-fun ctions.html
More about binary operator:
http://dev.mysql.com/doc/refman/5.1/en/charset-binary-op.htm l
|
|
|
|
|
Re: How to use Like() with SqlArray [message #4137 is a reply to message #4135] |
Mon, 24 July 2006 12:39 |
|
luzr wrote on Mon, 24 July 2006 05:21 | I think that we should rather apply zsolt's patch (binary for MySql) to keep Oracle and MySql and SQLite the same (case sensitive) (which is now done
Mirek
|
I proposed removing binary because I thought like is case insesitive.. (I used it only once or twice)
|
|
|
Goto Forum:
Current Time: Sat May 04 18:10:51 CEST 2024
Total time taken to generate the page: 0.03377 seconds
|