<?xml version="1.0" encoding="ISO-8859-15"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns="http://purl.org/rss/1.0/">
<channel rdf:about="http://www.ultimatepp.org/forum/index.php">
	<title>Ultimate++ forum RDF feed</title>
	<link>http://www.ultimatepp.org/forum/index.php</link>
	<description>Ultimate++ forum RDF feed</description>
	<items>
		<rdf:Seq>
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35396&amp;th=6536#msg_35396" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35400&amp;th=6536#msg_35400" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35401&amp;th=6536#msg_35401" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35409&amp;th=6536#msg_35409" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35410&amp;th=6536#msg_35410" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35412&amp;th=6536#msg_35412" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35414&amp;th=6536#msg_35414" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35416&amp;th=6536#msg_35416" />
			<rdf:li rdf:resource="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35417&amp;th=6536#msg_35417" />
		</rdf:Seq>
	</items>
</channel>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35396&amp;th=6536#msg_35396">
	<title>questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35396&amp;th=6536#msg_35396</link>
	<description>Hello all, &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I have to revise an application somebody else wrote. The application is for sqlite databases and uses sqlArray a lot. I never used sqlArray before, therefore I need help concerning two problems. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
1. How can I detect if the sqlArray encountered an error so that the application can react according to the errror?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Reason: &lt;br /&gt;&#13;
If there was an sql error, I get an error message and after that the application crashes sometimes. As far as I understand it, there is an ClearError() in UPP after showing the error message so that I can't use WasError() after a query. My idea was to use WhenPostQuery because it seems not be invoked if there was an error. Is that a good idea or is there a better way? &lt;br /&gt;&#13;
And what about editing, appending, deleting in the sqlArray? How can I detect an error there? &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
2. Is there a way to use an exclusive transaction for the sqlArray? Like I can use BEGIN EXCLUSIVE to start an exlusive transaction when using sql commands without sqlArray? &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Reason:&lt;br /&gt;&#13;
In very rare cases it might happen that two applications try to write to the same database at the same time. So we decided that writing to the database always should be done in exclusive transactions, locking the database during the whole writing operation. Editing, appending, deleting in an sqlArray means writing to the database, so I have to find a way to lock the database during the operation. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I would be very glad, if somebody could help me with this problems. Thank you in advance. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Best regards, &lt;br /&gt;&#13;
Petra&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
 &lt;br /&gt;&#13;
</description>
	<dc:subject></dc:subject>
	<dc:creator>papascalientes</dc:creator>
	<dc:date>2012-02-09T09:24:29-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35400&amp;th=6536#msg_35400">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35400&amp;th=6536#msg_35400</link>
	<description>Hello papascalientes,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Perhaps you could have a look to the link below:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;a href="http&amp;#58;&amp;#47;&amp;#47;www.webmonkey.com/2010/02/manage_transactions_in_mysql_-_lesson_2/" target="_blank"&gt; http://www.webmonkey.com/2010/02/manage_transactions_in_mysq l_-_lesson_2/&lt;/a&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
This concerns MySql but could be extapolated to SqLite.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Regards &lt;img src="http://www.ultimatepp.org/forum/images/smiley_icons/icon_smile.gif" border=0 alt="Smile"&gt; &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes</description>
	<dc:subject></dc:subject>
	<dc:creator>BioBytes</dc:creator>
	<dc:date>2012-02-10T09:22:40-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35401&amp;th=6536#msg_35401">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35401&amp;th=6536#msg_35401</link>
	<description>&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;papascalientes wrote on Thu, 09 February 2012 04&amp;#58;24&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;&lt;br /&gt;&#13;
1. How can I detect if the sqlArray encountered an error so that the application can react according to the errror?&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Reason: &lt;br /&gt;&#13;
If there was an sql error, I get an error message and after that the application crashes sometimes. As far as I understand it, there is an ClearError() in UPP after showing the error message so that I can't use WasError() after a query. My idea was to use WhenPostQuery because it seems not be invoked if there was an error. Is that a good idea or is there a better way? &lt;br /&gt;&#13;
And what about editing, appending, deleting in the sqlArray? How can I detect an error there? &lt;br /&gt;&#13;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
SqlArray is 'high-level' widget that is supposed to manage all errors and transactions on its own.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
So I would rather concentrated on why the app is crashing after error message -  the most likely cause is that it expects some data to be somewhere where there are none (e.g. after emoty query).&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
That said, I am not really opposed to adding some finer control about these issues, perhaps by adding Callbacks to perform alternate transaction management and error reporting. Just nobody really needed this so far...&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;Quote:&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;&lt;br /&gt;&#13;
2. Is there a way to use an exclusive transaction for the sqlArray? Like I can use BEGIN EXCLUSIVE to start an exlusive transaction when using sql commands without sqlArray? &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Reason:&lt;br /&gt;&#13;
In very rare cases it might happen that two applications try to write to the same database at the same time.&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
But two application writing to same rows of single database, that is pretty much normal and that is what normal transactions are supposed to solve. No need and not really any advantage in most cases to lock the whole DB...&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
All that said, I would like to repeat that SqlArray is high-level thing, which imposes some restrictions.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Generally, I have to say that over years, I am gradually using it less and less and mostly for configuration dialogs (where normal users of my apps usually do not really visit) or only using it for queries, not doing any actual inserts/updates/deletes (which I then implement in my own code) - pretty standard approach for me now is to use dialogs for row content, with great help of SqlCtrls to manage inserts/updates.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Mirek</description>
	<dc:subject></dc:subject>
	<dc:creator>mirek</dc:creator>
	<dc:date>2012-02-10T10:47:16-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35409&amp;th=6536#msg_35409">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35409&amp;th=6536#msg_35409</link>
	<description>Hi papascalientes,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Mirek has given very good explanations as usual. Sure SqlArray can do some actions &amp;quot;magically&amp;quot; but cannot solve all your problems of errors that could happen in code. It is the way I go in my own applications.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The update, insert and delete operations are managed by SqlCtrls and generally, my application menu functions are written on the following basis:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;div class="pre"&gt;&lt;pre&gt;&#13;
void MainWin::DefineDevices()&#13;
{&#13;
	SQL.Begin();&#13;
&#13;
	DevicesDlgWin.FillList(); &#13;
        //Initialization of ctrls in the dialog window&#13;
	&#13;
	if(DevicesDlgWin.ExecuteOK())SQL.Commit();&#13;
	else SQL.Rollback();&#13;
}&#13;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
So if the user presses ok (validation) button, the transaction is committed. If cancel button is pressed, modifications are not recorded in database.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes</description>
	<dc:subject></dc:subject>
	<dc:creator>BioBytes</dc:creator>
	<dc:date>2012-02-10T17:26:58-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35410&amp;th=6536#msg_35410">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35410&amp;th=6536#msg_35410</link>
	<description>&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;BioBytes wrote on Fri, 10 February 2012 12&amp;#58;26&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;Hi papascalientes,&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Mirek has given very good explanations as usual. Sure SqlArray can do some actions &amp;quot;magically&amp;quot; but cannot solve all your problems of errors that could happen in code. It is the way I go in my own applications.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
The update, insert and delete operations are managed by SqlCtrls and generally, my application menu functions are written on the following basis:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;div class="pre"&gt;&lt;pre&gt;&#13;
void MainWin::DefineDevices()&#13;
{&#13;
	SQL.Begin();&#13;
&#13;
	DevicesDlgWin.FillList(); &#13;
        //Initialization of ctrls in the dialog window&#13;
	&#13;
	if(DevicesDlgWin.ExecuteOK())SQL.Commit();&#13;
	else SQL.Rollback();&#13;
}&#13;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
So if the user presses ok (validation) button, the transaction is committed. If cancel button is pressed, modifications are not recorded in database.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
BTW, this a bad practice. You should not use transactions whose length depends on user GUI interaction. Transactions should be short.&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
	<dc:subject></dc:subject>
	<dc:creator>mirek</dc:creator>
	<dc:date>2012-02-10T17:59:18-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35412&amp;th=6536#msg_35412">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35412&amp;th=6536#msg_35412</link>
	<description>Hello Mirek, &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
thank you very much for your answer. In the meantime I decided I don't need to know the kind of error because if there is any sql error the application should just close. The application is kind of a special database editor for the users (forgot to mention that in my first mail) and if something is wrong with the databases, it makes no sense to use the editor any longer. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
So I tested using WhenPrequery and WhenPostquery to detect an error. That works pretty well for my purposes: I have a boolean variable set true in prequery and set false in postquery. After a query I check the variable and if it is still true, there was an error. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Then I tried to close the application in case of error - and you were definitely right when you said: &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;Quote:&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;...why the app is crashing after error message - the most likely cause is that it expects some data to be somewhere where there are none (e.g. after emoty query).&lt;br /&gt;&#13;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
I always get an error from an asset in VCont.h - so far mostly one of the two following: &lt;br /&gt;&#13;
&lt;div class="pre"&gt;&lt;pre&gt; { ASSERT(i &amp;gt;= 0 &amp;amp;&amp;amp; i &amp;lt; items); return vector[i]; }&#13;
{ ASSERT_(items &amp;gt;= 0, &amp;quot;Broken pick semantics&amp;quot;); }&#13;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Most of the crashes appear in a grid control which I also didn't use so far. And I have not the slightest idea where to start looking for the problem and find a way how to close the application. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Revising under time pressure a big, complicated application without documentation really is one of my favorites &lt;img src="http://www.ultimatepp.org/forum/images/smiley_icons/icon_wink.gif" border=0 alt="Wink"&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Concerning your answer to my second question:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;Quote:&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;But two application writing to same rows of single database, that is pretty much normal and that is what normal transactions are supposed to solve. No need and not really any advantage in most cases to lock the whole DB...&lt;br /&gt;&#13;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&#13;
   &lt;br /&gt;&#13;
I know, but there is a policy and ....&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Anyway, if it is not possible, I can't help it. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thank you again for your help. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
	<dc:subject></dc:subject>
	<dc:creator>papascalientes</dc:creator>
	<dc:date>2012-02-10T18:22:25-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35414&amp;th=6536#msg_35414">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35414&amp;th=6536#msg_35414</link>
	<description>Thanks Mirek for your advice about transaction and GUI. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To go further, do you recommend to put the code in the close function of the dialog window so the user can choose to quit the dialog and save the modifications or discard these modifications ?  &lt;img src="http://www.ultimatepp.org/forum/images/smiley_icons/icon_confused.gif" border=0 alt="Confused"&gt; &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
</description>
	<dc:subject></dc:subject>
	<dc:creator>BioBytes</dc:creator>
	<dc:date>2012-02-11T08:19:32-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35416&amp;th=6536#msg_35416">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35416&amp;th=6536#msg_35416</link>
	<description>&lt;table border="0" align="center" width="90%" cellpadding="3" cellspacing="1"&gt;&lt;tr&gt;&lt;td class="SmallText"&gt;&lt;b&gt;BioBytes wrote on Sat, 11 February 2012 03&amp;#58;19&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="quote"&gt;&lt;br /&gt;Thanks Mirek for your advice about transaction and GUI. &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
To go further, do you recommend to put the code in the close function of the dialog window so the user can choose to quit the dialog and save the modifications or discard these modifications ?  &lt;img src="http://www.ultimatepp.org/forum/images/smiley_icons/icon_confused.gif" border=0 alt="Confused"&gt; &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Actually, I think it is usually best:&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
- load data, do not start trasaction&lt;br /&gt;&#13;
- GUI editing&lt;br /&gt;&#13;
- if user presses Cancel, do nothing&lt;br /&gt;&#13;
- if OK, update/insert to DB; only if there is more than single statement involved, use transaction (otherwise single statement is transaction of its own)</description>
	<dc:subject></dc:subject>
	<dc:creator>mirek</dc:creator>
	<dc:date>2012-02-11T08:55:23-00:00</dc:date>
</item>

<item rdf:about="http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35417&amp;th=6536#msg_35417">
	<title>Re: questions about sqlArray</title>
	<link>http://www.ultimatepp.org/forum/index.php?t=rview&amp;goto=35417&amp;th=6536#msg_35417</link>
	<description>Ok Mirek&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
That is clear for me and I understand that it is safer. &lt;img src="http://www.ultimatepp.org/forum/images/smiley_icons/icon_nod.gif" border=0 alt="Nod"&gt; &lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Thank you very much&lt;br /&gt;&#13;
&lt;br /&gt;&#13;
Biobytes</description>
	<dc:subject></dc:subject>
	<dc:creator>BioBytes</dc:creator>
	<dc:date>2012-02-11T09:04:02-00:00</dc:date>
</item>
</rdf:RDF>