This question already has answers here:
SQL Oracle LEFT JOIN and SUBQUERY error: ORA-00905: missing keyword
(2 answers)
Closed 9 months ago.
I have the following query:
SELECT *
FROM DELUSR.AGREEMENT AS agreement
WHERE agreement.MASTER_AGGREMENT_ID = 4;
After trying to run it, I get this error:
Error code 933, SQL state 42000:
ORA-00933: SQL command not properly ended
Line 1, column 1
Execution finished after 0 s, 1 error(s) occurred.
I am not sure how to decode this error message. The statement looks fine to me. Any insights into whats wrong with it?
Oracle accepts no AS for table aliases:
SELECT * FROM DELUSR.AGREEMENT agreement WHERE agreement.MASTER_AGGREMENT_ID = 4;
Related
This question already has an answer here:
Replacement for Left command in SQLite SQL
(1 answer)
Closed 7 months ago.
How to remove all characters from / to &.
UPDATE bal SET Perevod=substr(Perevod, INSTR(Perevod, '/.+&')-1)
WHERE INSTR(Perevod, '/.+&')>0;
You can use this because I believe there is no LEFT function in SQLite:
UPDATE bal
SET Perevod = substr(Perevod, 1, INSTR(Perevod, '/')-1)
WHERE INSTR(Perevod, '/')>0;
DEMO
I am trying to do an update in 2 tables, but i have this error:
Error SQL: ORA-00933: "SQL command not properly ended".
Could you help me please? The query is:
UPDATE a
SET a.ACTORID_ = SUBSTR(a.ACTORID_, 2, LENGTH(a.ACTORID_)),
b.TASKACTORID_ = SUBSTR(b.TASKACTORID_, 2, LENGTH(b.TASKACTORID_))
FROM jbpm_taskinstance AS a
INNER JOIN jbpm_log AS b
ON b.TASKACTORID_ = a.ACTORID_
WHERE a.ACTORID_ = b.TASKACTORID_
AND b.TASKINSTANCE_ IN (
SELECT ID_
FROM jbpm_taskinstance
WHERE a.PROCINST_ =b.PROCINST_)
AND b.TASKACTORID_ = a.ACTORID_;
Welcome to the world of strange and misleading Oracle error messages!
With experience, you can spot the error by sight, as #a_horse_with_no_name has done.
If you don't see the error immediately, I'd recommend to make the query simpler step by step until the error disappears. In your case, I would remove the AND b.taskinstance_ IN () subquery and check if the same error comes up. Then I'd remove the SUBSTR with a simple constant, like SET a.ACTORID_ = 'a'. Then I'd remove the JOIN, updating only table A. This will run ok, so you need to read up Oracle's documentation on UPDATE.
This question already has answers here:
Why can't I use an alias in a DELETE statement?
(2 answers)
Closed 2 years ago.
Below is the section of code that is getting an error. I am not sure why I am getting an error.
Delete from TblProcessCurrency C
where Not Exists (
Select PRCSchedule
from tblProcess P
where P.PrcSchedule = C.PCXSchedule and P.PRCOlsn = C.PCXOlsn and P.PRCRelease = C.PCXRelease
);
and here is the error I am getting
Msg 102, Level 15, State 1, Line 32
Incorrect syntax near 'C'.
You want:
DELETE C
FROM TblProcessCurrency C
WHERE Not Exists...
You can't alias the table that is the target for the DELETE, unless you state you want to DELETE from said alias.
I am making a UNION between these two queries:
$first =
DB::table('pedido')
->select(DB::raw('date(fecha_pago) as fecha'),DB::raw('sum(subtotal) as ingreso'),DB::raw('0 as egreso'))
->where('idestado','=','2')
->groupBy(DB::raw('date(fecha_pago)'));
$second =
DB::table('egreso')
->select(DB::raw('date(fecha) as fecha'),DB::raw('0 as ingreso'),DB::raw('sum(monto) as egreso'))
->groupBy(DB::raw('date(fecha)'));
$final_query=
DB::select(DB::raw('date(fecha),sum(ingreso) as ingreso,sum(egreso) as egreso'))
->union($first)->union($second)
->groupBy(DB::raw('date(fecha)'))
->get();
I get the error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'date(fecha),sum(ingreso) as ingreso,sum(egreso) as egreso' at line 1 (SQL: date(fecha),sum(ingreso) as ingreso,sum(egreso) as egreso)
DB::select() executes a raw query, unlike DB::table()->select() which is used to define fields for the query builder to select.
You're missing the DB::table() in your final query, without it, you won't be using the query builder and you'll actually be running a query of just date(fecha),sum(ingreso) as ingreso,sum(egreso) as egreso.
https://laravel.com/docs/5.6/queries#selects
Using Advantage Database Server 8.1 I am having trouble executing a successful query. I am trying to do the following
SELECT * FROM Persons
WHERE LastName IN ('Hansen','Pettersen')
To check for multiple values in a column. But I get an error when I try to execute this query in Advantage.
Edit - Error
poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2115; [iAnywhere Solutions][Advantage SQL Engine]Expected lexical element not found: ( There was a problem parsing the
WHERE clause in your SELECT statement. -- Location of error in the SQL statement is: 46
And here is the SQL i'm executing
select * from "Pat Visit" where
DIAG1 IN = ('43644', '43645', '43770', '43771', '43772', '43773', '43774',
'43842', '43843', '43845', '43846', '43847', '43848', '97804', '98961',
'98962', '99078')
Done
Does anyone have any Idea how I could do something similar in advantage that would be efficient as well?
Thanks
You have an extraneous = in the statement after the IN. It should be:
select * from "Pat Visit" where
DIAG1 IN ('43644', '43645', <snip> )