Tamás' suggestion should fix it for you. In addition;
On 20/08/15 11:07, Stéphane phenetas wrote:
> Hello,
>
> I am trying to implement a command that UPDATE a value in a table if
> the value exist, or INSERT the value if the value does not exist at
> that moment.
>
> I have searched for how to do that, and I have come with this command "
>
> "UPDATE devicesInfos SET statusStack=statusStack+2, lastSeen="+ a +" WHERE macAddress="+ b +" AND statusStack<4;
> IF @@ROWCOUNT = 0 INSERT INTO
> devicesInfos(macAddress,currentStatus,statusStack,firstSeen,lastSeen)
> VALUES ("+ c +",1,3,"+ d +","+ e +")"
If there's a chance that user input might make it into your query, you
should use query placeholders. Even if not, it's a good habit that costs
you nothing.
>
> The program is compiling, it runs but the database is not updated. So I am pretty sure this is this command that is faulty.
> And the only "new" thing I am using here is the @@ROWCOUNT, so I am not sure if I am using it right ? Or if the library matte/go-sqlite3 can handle it ?
Drivers don't try to make sense of your query, only its results.
>
>
> Thank you.
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
golang-nuts...@googlegroups.com
> <mailto:
golang-nuts...@googlegroups.com>.
> For more options, visit
https://groups.google.com/d/optout.