correct query in DB SQL Executor

hi every one .
i wanna delete record base on name “sara” from my db oracle


i write this query and i get error every time .
where is the mistake??
i test multi query but not answered .
thanks for your help

Hi @alrz , I can’t see how the DB SQL Executor node fits into your workflow, but the #table# placeholder is normally associated with the “in database” nodes following a DB Table Selector node, and connected via the brown “DB Data” connector, rather than the pink “DB Session” connector which is how the DB SQL Executor node connects.

So firstly, I’d suggest you remove the #table# from the query, and try it like that.

If still not working… as this appears to be an oracle database, the syntax of your delete statement would normally be

delete from schemaname.tablename where ...

Additionally Oracle table names, in line with the ansi standard are uppercase by default unless they have been explicitly created as lowercase surrounded by double quotes. Do you know for certain that the table name is in the database in lowercase (“customer”)?

NB You can also expand the list of available tables (and see their actual names) in the left hand metadata browser, and double-click the required table to include it in your query

Unless your table is actually named “customer” (lowercase), you should refer to it as “CUSTOMER” or leave off the double-quotes. (But you may also need to check the Oracle Connector (advanced settings) to see if that is set to place double quotes around identifiers.

You may additionally need to include the name of the schema in your delete statement, but that depends on whether you are connected to the schema containing the table being referenced (or there is a public synonym defined).

So without knowing more details, it is not possible to state with certainty what your sql should be, but you could try one of the following variations:

delete from "customer" where fname = 'sara'

delete from "CUSTOMER" where fname = 'sara'

delete from CUSTOMER where fname = 'sara'
delete from customer where fname = 'sara'

(these last two are actually synonymous, as customer without doublequotes will be treated as CUSTOMER)

or again try any of the above with your schema name appended

e.g.
delete from A_HOSEINZADEH.CUSTOMER where fname = 'sara'

(I’m taking a guess at the one schema name that isn’t a standard schema in your above screenshot)

If that still isn’t doing what you require, please show more of your workflow, and give more details about the schema name and table name.

3 Likes

And in addition to @takbb remove all leading and trailing whitespaces from your sql code.

1 Like

Hello @alrz ,
have a look at the DB Delete (Filter) node which comes with a visual frontend that generates the query in the background for you.
Bye
Tobias

2 Likes

hi @takbb
i test your solution but still is not work .
i attach my workflow to see .


and query that i write

as you see i follow that step but not working

@alrz it seems your SQL syntax is still invalid:

  • if you have several SQL statements in one node you will have to separate them by ; (semicolon) and activate the support in the node
  • make sure you qualify the table you want to access in a correct way. You have several schemas
  • as has been said different databases have slightly different SQL styles with quotation marks and so on. You will have to match that
  • you can use knime specific DB nodes or you can write the code yourself but this will have to be on point

Then it might help to maybe toy around with some examples to get a better grip on the use of databases

2 Likes

tnx bro for your help .
i have a mistake and not comment go keyword .
after that its work

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.