# Uwamp SQL ER\_PARSE\_ERROR when trying to send data from OPCUA to my local sql database

**URL:** <https://discourse.nodered.org/t/uwamp-sql-er-parse-error-when-trying-to-send-data-from-opcua-to-my-local-sql-database/16116>\
**Category:** General\
**Created:** [30 September 2019 23:49 UTC](https://discourse.nodered.org/t/uwamp-sql-er-parse-error-when-trying-to-send-data-from-opcua-to-my-local-sql-database/16116 "2019-09-30T23:49:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![echowhiskey94](https://avatars.discourse-cdn.com/v4/letter/e/c0e974/32.png) [@echowhiskey94](https://discourse.nodered.org/u/echowhiskey94)\
**Post date:** [30 September 2019 23:49 UTC](https://discourse.nodered.org/t/uwamp-sql-er-parse-error-when-trying-to-send-data-from-opcua-to-my-local-sql-database/16116/1 "2019-09-30T23:49:19Z")

</div>

Hey Everyone!

I've been trying to send a value from an OPCUA Server to my local database in Uwamp.

In my 'Insert Query' node, I want to send the value to the database when the payload is not equal to 0.

I tried using the IF statement and here the CASE statement but both kept giving me this ER\_PARSE\_ERROR after the INSERT part of the query.

The Insert query works without the case/if statement and I'm not sure what changes i can make to make it work.

 ![19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d8711629928f8d60a12962e7e8869fc5fccc86e1.png)  
Here is the picture of my flow and the full debug window.

The if function

```auto
if (msg.payload[1].value.value ==1) {
msg.payload=msg.payload[0].value.value;
}
else {
    msg.payload=0;
}
return msg;

```

The Insert Query

```auto
SELECT CASE
    WHEN ?=0
        THEN (SELECT 1)
        ELSE (INSERT INTO 'statankdatasd' ('tankLevel') VALUES (?))
END

```

Your help is highly appreciated
