I'm not sure if this is what you are asking, but you could change your SELECT query to
select count(*) as recordcount from benutzer_hi_ma where chipnr = 20000123
Then the first two cases have msg.payload[0].recordcount == 0 or 1
I think that for the INSERT, msg.payload.affectedRows == 1 to indicate success, or else an error not a msg.payload.
I have now solved it as follows:
I swapped the SQL query with the select count(*).
Then I replaced the switch with a function node and put a "Convert to JavaScript-Object" in front of the function and built the function like this:
> // define topic
> msg.topic = "RMChipScan";
>
> // if insert success
> if (msg.payload.affectedRows == 1) {
> msg.payload = "entered";
> }
> // if chipnr isnt available
> else if (msg.payload[0]["count(chipnr)"] == 0) {
> msg.payload = "does not match";
> }
> // if chipnr is available
> else if (msg.payload[0]["count(chipnr)"] == 1) {
> msg.payload = "matches";
> }
>
> return msg;