Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
zsolt is currently offline  zsolt
Messages: 697
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 #4129 is a reply to message #4128] Mon, 24 July 2006 01:52 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I am no SQLite expert, but I guess "binary" is not OK there...

(Means either plugin/SQLite or SqlExp will need some fixing).


Mirek
Re: How to use Like() with SqlArray [message #4131 is a reply to message #4129] Mon, 24 July 2006 08:59 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 697
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 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 #4133 is a reply to message #4132] Mon, 24 July 2006 09:55 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Frankly we should throw out the binary operator from mysql version.. (or add to sqlexp LikeBinary..)
Re: How to use Like() with SqlArray [message #4135 is a reply to message #4133] Mon, 24 July 2006 11:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
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 Wink

Mirek
Re: How to use Like() with SqlArray [message #4137 is a reply to message #4135] Mon, 24 July 2006 12:39 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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 Wink
Mirek

I proposed removing binary because I thought like is case insesitive.. (I used it only once or twice)
Previous Topic: sqlite3 compile problems on fresh install
Next Topic: sqlite3 plugin documentation
Goto Forum:
  


Current Time: Mon Apr 29 09:03:40 CEST 2024

Total time taken to generate the page: 0.02706 seconds