SQL SQL
Runs one named read or write on a SQL Link.
How it works
When the rung turns on, it starts the query on the Link. While Busy is on, the rung turning on again is ignored. When it finishes, Done or Error turns on. Unknown means the database may have run it, so check before trying again.
In practice
Run one approved, named Read or Write operation of one SQL Link. Parameters come from tags or fixed values; Read result fields and the outcome land in tags. A Write publishes its affected-row count without result fields. No SQL text is written in ladder.
Configuration
- Drop SQL, pick a Link's read operation, bind the SKU tag to its parameter and the quantity field to a DINT tag.
Limits and status
- Each result field has a presence tag: 0 no result, 1 value, 2 NULL, 3 missing (the mapped row is not in the result). A NULL or missing field leaves its value tag unchanged.
- Write operations require the host's explicit Write approval. A changed Link or operation clears the bindings and never silently rematches another revision.
- Two SQL instructions on one Link do not queue: the second rise while the Link is busy ends in Error with a code.
Operands
Choose the Link and its command in the instruction. Map parameters and result tags there.
Common mistakes
- Repeating a write after an Unknown outcomeCheck whether the database made the change before trying again. A busy Link does not queue a second instruction.