Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tMysqlOutput insert or update

Hello,
I need to insert or update a mySQL table "SYPRM" depending of the result of a join between table "SYPRM" and string value of a CSV file
if the query returns no row => insert else update
SYPRM contains two strings columns :
PDESYPRM is the key
CPRSYPRM is a counter ... in string format
one column of the output file needs to be filed with "0001" if no row are returned from the query and value of CPRSYPRM + 1 on update

Can you give me an example of insert or update for my purpose ??
regards
Didier
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

actually I found the solution : I had an inner join in the input table linked to the tMySQLoutput "insert or update"
+
the evaluation condition triggering insert or update was based on a field of the tMySQLoutput so I always got null pointer exception ...

View solution in original post

3 Replies
Anonymous
Not applicable
Author

In Mysql there are several ways to do this and perhaps sometimes the simple way may be the easiest when using code in another product. What you could do is condition some code by something like
SET X_Count = Count(*) from table Y where A 'abcde'
I.e. get a count if there are no matching records
Remember that if there are no matching records then the count is likely to be the value of NULL and not 0.
however you could neatly structure either
IF X_Count = 0 then
Insert ........
ELSe
update ......
ENDIF
Anonymous
Not applicable
Author

@lesjar2509 : thanks for your answer but I want to use the component tMySQLoutput with the "insert or update" feature.
at the moment all the rows are inserted although the key already exists.
I have posted more screenshots
Anonymous
Not applicable
Author

actually I found the solution : I had an inner join in the input table linked to the tMySQLoutput "insert or update"
+
the evaluation condition triggering insert or update was based on a field of the tMySQLoutput so I always got null pointer exception ...