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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem with Command LIMIT in query of tDBRow for SQLite

Hello,

I have a problem with the word LIMIT in the Query of the tDBRow (for SQLite):

For example, I have the following Query:

"
UPDATE DOL
SET BlockedQuantityTotal = 200
WHERE IDG = '" + row3.IDG + "'
LIMIT 1
"

 

DOL is the Table,

 

When the Job is ran, I have the error: "near "LIMIT": syntax error"

 

I run this command in a SQLite Tool (for example SQLiteSpy) and this command works.

 

Could you pleas help me?

 

Thanks in advance...

Labels (1)
  • v7.x

1 Solution

Accepted Solutions
vapukov
Master II
Master II

you absolutely right - first SQL construction is wrong

 

case with MIN(id) is proper, 

 

with original query - it update ALL record with same IDG 🙂

View solution in original post

7 Replies
vapukov
Master II
Master II

hi,


as I know UPDATE and DELETE with LIMIT supported not by all sqlite (it must be defined as option when build) - SQLITE_ENABLE_UPDATE_DELETE_LIMIT

 

second,  what need to check - what in row3.IDG?

as I can guess it is string (char/varchar), but what possible values and what final SQL code will be in this case?

 

 

Anonymous
Not applicable
Author

First, Thanks for ypur answer.

Then, I'm not an expert with Talend, SQLite and SQL (sorry), where do I have to put this Option? In the Query "box" or somewhere else?

And, the Command I have written:

"
UPDATE DOL
SET BlockedQuantityTotal = 200
WHERE IDG = '" + row3.IDG + "'
LIMIT 1
"

 

Was an example and yes row3.IDG is a String.

what I want is to Update my Table only on the first row result of the query.

vapukov
Master II
Master II

this option must be used when sqlite driver compiled, and no any settings in Talend for this

 

try next:

"
UPDATE DOL
SET BlockedQuantityTotal = 200
WHERE IDG IN (SELECT IDG FROM DOL WHERE IDG = '" + row3.IDG + "' LIMIT 1) "
Anonymous
Not applicable
Author

Hello Vapukov,

Thanks for your answer but the result is that all the line with the row3.IDG are updated not only the first one.

 

I don't know why it doesn't not only update the first one.

 

I Have tried the following commnd:

"
UPDATE DOL
SET BlockedQuantityTotal = 200
WHERE id = (SELECT MIN(id) FROM DOL WHERE
IDG = '" + row3.IDG + "')
"

 

id is the column withe the unique auto-incremented key for each row of the table.

 

This seems to work.

vapukov
Master II
Master II

you absolutely right - first SQL construction is wrong

 

case with MIN(id) is proper, 

 

with original query - it update ALL record with same IDG 🙂

Anonymous
Not applicable
Author

Thanks for your support...
vapukov
Master II
Master II

welcome to the community! 🙂