I am very new to SQL, why does the code below give the error "operation not properly ended"? separately the 2 commands work, but when together it gives the error?
UPDATE sec0503_checking_accounts
SET balance = balance + 5000
WHERE customer = 'name';
UPDATE sec0503_savings_accounts
SET balance = balance -5000
WHERE customer = 'name';
i have tried removing the semicolons, and have looked around for some solutions, but none of them seem to work. either of these commands also give the same error when used in conjunction with other commands.
keep in mind, i am using apex oracle and this is just for practice.
In Oracle Apex, if you are using the SQL Workshop then you can only run a single command at a time.
If you try to run an entire script, consisting of multiple statements, then it will be passed in its entirety to the database's SQL engine which will then fail because it is expecting a single command and not multiple commands (and the
;
terminating the first statement is not expected syntax and so the operation is not properly ended and an error stating that is raised).Instead, what you should do is highlight the statement that you want to run and then click the run button.
This answer gives an example:
Alternatively, you can wrap multiple SQL statements in a single PL/SQL block (as described by @PaulW's answer) so that the single statement being evaluated is the entire PL/SQL block, within which each individual SQL statement will be evaluated in sequence.