<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does.]]></title><description><![CDATA[<p dir="auto">i am trying to get stuff from my ui into a databse. so first i do a check if the entry already exists.</p>
<ol>
<li>
<p dir="auto">if it exists i'll do an UPDATE SET WHERE clause.</p>
</li>
<li>
<p dir="auto">If not i'll do an INSERT INTO VALUES clause.</p>
</li>
</ol>
<p dir="auto">in both of these cases, the last part (WHERE / VALUES) a :placeholder does not work.</p>
<p dir="auto">so here the 2 cases with both examples and how i tried them. with the one working and the other one not working.</p>
<p dir="auto">1:<br />
//(with ?)<br />
q.prepare("UPDATE my_table SET column1 = :val1 WHERE column2 = ?");<br />
q.bindValue(":val1", ui-&gt;my_line_edit-&gt;text());<br />
q.bindValue(1, ui-&gt;my_line_edit_2-&gt;text());<br />
q.exec();<br />
//WORKS</p>
<p dir="auto">//(with :placeholder)<br />
q.prepare("UPDATE my_table SET column1 = :val1 WHERE column2 = :val2");<br />
q.bindValue(":val1", ui-&gt;my_line_edit_1-&gt;text());<br />
q.bindValue(":val2", ui-&gt;my_line_edit_2-&gt;text());<br />
q.exec();<br />
//DOES NOT WORKS</p>
<p dir="auto">2:<br />
//(with ?)<br />
q.prepare("INSERT INTO my_table (column1) VALUES (?)");<br />
q.bindValue(0, ui-&gt;my_line_edit-&gt;text());<br />
q.exec();<br />
//WORKS</p>
<p dir="auto">//(with :placeholder)<br />
q.prepare("INSERT INTO my_table (column1) VALUES (:val)");<br />
q.bindValue(":val", ui-&gt;my_line_edit-&gt;text());<br />
q.exec();<br />
//DOES NOT WORK</p>
<p dir="auto">I hope i made the point clear.</p>
]]></description><link>https://forum.qt.io/topic/124065/query-placeholder-does-not-work-but-does</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 01:07:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/124065.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Feb 2021 07:50:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:43:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtnoob420">@<bdi>qtnoob420</bdi></a> said in <a href="/post/645874">Query ":placeholder" does not work, but "?" does.</a>:</p>
<blockquote>
<p dir="auto">I hope i got it this time :D</p>
</blockquote>
<p dir="auto">Yes, that's correct.<br />
I think you problem is link to this ticket <a href="https://bugreports.qt.io/browse/QTBUG-48471" target="_blank" rel="noopener noreferrer nofollow ugc">QTBUG-48471</a>.<br />
It seems that PostgreSQL do not support prepare statements.</p>
]]></description><link>https://forum.qt.io/post/645877</link><guid isPermaLink="true">https://forum.qt.io/post/645877</guid><dc:creator><![CDATA[KroMignon]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 09:02:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtnoob420">@<bdi>qtnoob420</bdi></a> said in <a href="/post/645878">Query ":placeholder" does not work, but "?" does.</a>:</p>
<blockquote>
<p dir="auto">i suppose there is nothing i can do about it...</p>
</blockquote>
<p dir="auto">As you can see, it is a limitation of PostgreSQL itself.</p>
<pre><code>if(!q.prepare("UPDATE my_table SET column1 = :val1 WHERE column2 = :val2"))
{
   qDebug() &lt;&lt; "Prepare statement error:" &lt;&lt; q.lastError().text();
}
</code></pre>
]]></description><link>https://forum.qt.io/post/645881</link><guid isPermaLink="true">https://forum.qt.io/post/645881</guid><dc:creator><![CDATA[KroMignon]]></dc:creator><pubDate>Tue, 23 Feb 2021 09:02:05 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:50:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kromignon">@<bdi>KroMignon</bdi></a> as soon as i use my example with the :placeholder i get a syntax error returned from my query. but there is no syntax fault. as i said in my post, i just switched the ":placeholder" with a "?" and the it works fine again.</p>
<p dir="auto">i suppose there is nothing i can do about it...</p>
]]></description><link>https://forum.qt.io/post/645878</link><guid isPermaLink="true">https://forum.qt.io/post/645878</guid><dc:creator><![CDATA[qtnoob420]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:43:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtnoob420">@<bdi>qtnoob420</bdi></a> said in <a href="/post/645874">Query ":placeholder" does not work, but "?" does.</a>:</p>
<blockquote>
<p dir="auto">I hope i got it this time :D</p>
</blockquote>
<p dir="auto">Yes, that's correct.<br />
I think you problem is link to this ticket <a href="https://bugreports.qt.io/browse/QTBUG-48471" target="_blank" rel="noopener noreferrer nofollow ugc">QTBUG-48471</a>.<br />
It seems that PostgreSQL do not support prepare statements.</p>
]]></description><link>https://forum.qt.io/post/645877</link><guid isPermaLink="true">https://forum.qt.io/post/645877</guid><dc:creator><![CDATA[KroMignon]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:34:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kromignon">@<bdi>KroMignon</bdi></a><br />
Desktop Qt 5.12.10 MingGW 64-Bit.</p>
<p dir="auto">I hope i got it this time :D</p>
]]></description><link>https://forum.qt.io/post/645874</link><guid isPermaLink="true">https://forum.qt.io/post/645874</guid><dc:creator><![CDATA[qtnoob420]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:33:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtnoob420">@<bdi>qtnoob420</bdi></a> said in <a href="/post/645872">Query ":placeholder" does not work, but "?" does.</a>:</p>
<blockquote>
<p dir="auto">QT Creator 4.13.1 (Community)</p>
</blockquote>
<p dir="auto">This is your IDE, but why Qt Kit you are using to build your application (cf. Tools/Options/Kits)?</p>
]]></description><link>https://forum.qt.io/post/645873</link><guid isPermaLink="true">https://forum.qt.io/post/645873</guid><dc:creator><![CDATA[KroMignon]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:30:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
QT Creator 4.13.1 (Community)</p>
<p dir="auto">PostgreSQL 9.5.25</p>
]]></description><link>https://forum.qt.io/post/645872</link><guid isPermaLink="true">https://forum.qt.io/post/645872</guid><dc:creator><![CDATA[qtnoob420]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:30:18 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:23:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/qtnoob420">@<bdi>qtnoob420</bdi></a> said in <a href="/post/645864">Query ":placeholder" does not work, but "?" does.</a>:</p>
<blockquote>
<p dir="auto">in both of these cases, the last part (WHERE / VALUES) a :placeholder does not work.</p>
</blockquote>
<p dir="auto">to complete <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> questions: did you check <code>q.prepare()</code> returned value? If returning false than the query could <strong>not</strong> be prepared (cf <a href="https://doc.qt.io/qt-5/qsqlquery.html#prepare" target="_blank" rel="noopener noreferrer nofollow ugc">documentation</a>)</p>
]]></description><link>https://forum.qt.io/post/645870</link><guid isPermaLink="true">https://forum.qt.io/post/645870</guid><dc:creator><![CDATA[KroMignon]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:23:22 GMT</pubDate></item><item><title><![CDATA[Reply to Query &quot;:placeholder&quot; does not work, but &quot;?&quot; does. on Tue, 23 Feb 2021 08:17:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Which version of Qt are you using ?<br />
Which database backend ?</p>
]]></description><link>https://forum.qt.io/post/645867</link><guid isPermaLink="true">https://forum.qt.io/post/645867</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 23 Feb 2021 08:17:59 GMT</pubDate></item></channel></rss>