<div dir="ltr">Hello,<div><div><br></div><div>I'm trying to do something with a dataset, but I think that isn't possible.</div><div><br></div><div>Assuming I have the following table:</div><div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">

create table users (</div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">    </span>id serial not null primary key,</div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="white-space:pre-wrap">     </span>email varchar(100),</div>
<div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">    </span>nickname varchar(20) not null</div><div style="font-family:arial,sans-serif;font-size:13px">);</div></div><div><br></div>

<div>And the following records:<br></div><div><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">id | email | nickname</div><div><div style="font-family:arial,sans-serif;font-size:13px">1 | <a href="mailto:user1@domain.com" target="_blank">user1@domain.com</a> | user1</div>

<div style="font-family:arial,sans-serif;font-size:13px">2 | <a href="mailto:user2@domain.com" target="_blank">user2@domain.com</a> | user2</div><div style="font-family:arial,sans-serif;font-size:13px">3 | <a href="mailto:user3@domain.com" target="_blank">user3@domain.com</a> | user3</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div><font face="arial, sans-serif">I want to clear the email of the second user, but using parameters:</font><br></div></div></div><div><font face="arial, sans-serif"><br>

</font></div><div><div style="font-family:arial,sans-serif;font-size:13px">id | email | nickname</div><div><div style="font-family:arial,sans-serif;font-size:13px">1 | <a href="mailto:user1@domain.com" target="_blank">user1@domain.com</a> | user1</div>

<div style="font-family:arial,sans-serif;font-size:13px">2 | <null> | user2</div><div style="font-family:arial,sans-serif;font-size:13px">3 | <a href="mailto:user3@domain.com" target="_blank">user3@domain.com</a> | user3</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div><font face="arial, sans-serif">But when I try this:</font><br></div></div></div><div><font face="arial, sans-serif"><br></font></div><div><div style="font-family:arial,sans-serif;font-size:13px">

  SQLQuery1.SQL.Add('update users set email = :email');</div><div style="font-family:arial,sans-serif;font-size:13px">  SQLQuery1.SQL.Add('where id = :id');</div><div style="font-family:arial,sans-serif;font-size:13px">

  SQLQuery1.ParamByName('id').AsInteger := 2;</div><div style="font-family:arial,sans-serif;font-size:13px">  SQLQuery1.ParamByName('email').Clear;</div><div style="font-family:arial,sans-serif;font-size:13px">

  SQLQuery1.ExecSQL;</div><div style="font-family:arial,sans-serif;font-size:13px">  SQLTransaction1.Commit;</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">

I got:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div><div style="font-family:arial,sans-serif;font-size:13px">"Project project1 raised exception class "EDatabaseError" with message:</div>

<div style="font-family:arial,sans-serif;font-size:13px">PQConnection1: Unknown fieldtype for parameter "email"."</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div><div><font face="arial, sans-serif">I know that I could solve easily via </font><span style="font-family:arial,sans-serif">literal </span><span style="font-family:arial,sans-serif">string, but I need to use parameters anyway.</span></div>

<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">How I solve this?</font><br></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Here in Brazil, a friend suggested this:<br>

</font></div><div><font face="arial, sans-serif"><br></font></div><div><div style="font-size:13px;font-family:arial,sans-serif">  VParam := SQLQuery1.ParamByName('email');<br></div></div><div style="font-size:13px;font-family:arial,sans-serif">

  VParam.DataType := ftString;</div><div style="font-size:13px;font-family:arial,sans-serif">  VParam.Clear</div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Is this the only way? '-'<br>

</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Thank you!</font></div></div></div><div><font face="arial, sans-serif"><br></font></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>