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 » SQL problem
icon4.gif  SQL problem [message #35546] Tue, 28 February 2012 17:43 Go to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello all

From now my old production non MT code does not work. It raises an exception here:
bool Sqlite3Connection::Fetch() {
	ASSERT(NULL != current_stmt);	// Exception

I do not know where current_stmt is set.

Do you now if there is any change in the code?


Best regards
Iñaki
Re: SQL problem [message #35549 is a reply to message #35546] Wed, 29 February 2012 00:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello all

I have tried to reduce the problem as much as possible.

What is wrong with this code?
	SqlId TABLE("TABLE");
	SqlId FIELD("FIELD");	
	SqlId TEXTSEARCH("TEXTSEARCH");	
	SqlVal set(Coalesce(FIELD, "_"));
	SqlSelect select(SqlAll(), set.As(TEXTSEARCH));
	select.From(TABLE);
	select.OrderBy(FIELD);

Thank you very much in advance.


Best regards
Iñaki
Re: SQL problem [message #35569 is a reply to message #35549] Wed, 29 February 2012 18:16 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Finally the problem is solved

Something changed that made that "Ye olde reliable" Smile source went broken.

From now all string expressions like "_" inside Sql expressions have to be changed to SqlId("'_'"). With this everything works as expected.


Best regards
Iñaki
Re: SQL problem [message #35570 is a reply to message #35569] Wed, 29 February 2012 20:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 29 February 2012 12:16

Finally the problem is solved

Something changed that made that "Ye olde reliable" Smile source went broken.

From now all string expressions like "_" inside Sql expressions have to be changed to SqlId("'_'"). With this everything works as expected.


I am sorry about this, frankly this is the biggest flop I have made in years.

The primary motivation was adding quites to column names, but it has gone bad, as many places in U++ code and more importantly client code make assumption about what can and cannot be done with SqlId... So it is now only optional, but still cases a trouble here and there (because I want to keep quotes as option so I cannot remove it completely).

Hopefully, this one will be the last issue... It is fixed and coalesce and SqlVal::As (which was the real cause of problems) is added to SqlExp unit testing package.

My apologies.

Mirek
Re: SQL problem [message #35571 is a reply to message #35570] Wed, 29 February 2012 21:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Mirek

For a Sql dummy like me Smile, does it mean that SqlId("'text'") is the solution to get 'text' inserted into Sql expression?


Best regards
Iñaki
Re: SQL problem [message #35574 is a reply to message #35571] Wed, 29 February 2012 22:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 29 February 2012 15:12

Hello Mirek

For a Sql dummy like me Smile, does it mean that SqlId("'text'") is the solution to get 'text' inserted into Sql expression?


No. Well, in the past it was and it should work still when using default "backward compatibility" mode.

If you activate new "SqlId::UseQuotes", it will not work. Instead, you should use SqlTxt("'text'") to insert things into SQL (works in both modes).

Mirek
Re: SQL problem [message #35576 is a reply to message #35574] Thu, 01 March 2012 08:30 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Ok, it works.

What does "SqlId::UseQuotes" mean?


Best regards
Iñaki
Re: SQL problem [message #35577 is a reply to message #35576] Thu, 01 March 2012 08:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 01 March 2012 02:30

Ok, it works.

What does "SqlId::UseQuotes" mean?


If activated, it starts adding quotes around all SqlIds, when put to SQL. It is to allow column names like "FROM".

select "COLUMN", "FROM" from "TABLE"....

Mirek
Re: SQL problem [message #35581 is a reply to message #35577] Thu, 01 March 2012 13:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Ok, I understand.

So I will use SqlTxt("'text'") to insert texts and I will not use SqlId::UseQuotes.


Best regards
Iñaki
Re: SQL problem [message #35584 is a reply to message #35581] Thu, 01 March 2012 13:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I recommend UseQuotes for new code...
Re: SQL problem [message #35586 is a reply to message #35584] Thu, 01 March 2012 16:02 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Ok.

Best regards
Iñaki
Previous Topic: Is it possible to call a stored procedure with an output parameter?
Next Topic: Added partial support for ODBC output parameters, but the solution is ugly
Goto Forum:
  


Current Time: Sat Apr 20 11:55:17 CEST 2024

Total time taken to generate the page: 0.05214 seconds