I have a below code which is giving error when I changed the sSQL parameter to join query. Earlier select command on v_d_investigation view was there. I changed the query to join v_d_investigation on v_d_memo views. Error i am getting "One or more error occurred during processing of command. From keyword not found where expected". Please suggest on this...
sSQL += "order by opened_dt Desc "
fDataSet = gConn.getDataSet(sSQL, "v_d_investigation")
'fDataSet = gConn.getDataSet(sSQL)
totalRecords = Me.lvList.AddItems(fDataSet, "v_d_investigation")
Related
Simple straightforward example:
I have two similar tables containing Key and Val fields.
Then I try to update one table with the values from the other:
docmd.RunSQL "UPDATE [t-dest] SET [t-dest].val = [t-source].val " & _
" FROM [t-source] WHERE [t-source].key = [t-dest].key"
and receive this Syntax Error message:
Syntax error (missing operator) in query expression
'[t-source].val FROM [t-source]'
Please help to find the cause of this error!
DoCmd.RunSQL "UPDATE [t-dest] INNER JOIN [t-source] " & _
"ON [t-source].key = [t-dest].key " & _
"SET [t-dest].val = [t-source].val"
I think I'm at a loss here. I'm trying to open a recordset with the given SQL-String, but all I get is an Error ORA-00933 SQL Command not properly ended.
I already tried to circle in the error and it seems I made a mistake in the WHERE-clause, but I'm kinda stuck and don't get it where the mistake's at.
strsql = "SELECT QSYS.DOKUMENTE.SDATEINAME
FROM QSYS.DOKUMENTE
INNER JOIN QSYS.RQMS_STAMM
ON QSYS.DOKUMENTE.NLFD = QSYS.RQMS_STAMM.NRQNR"
& _ "WHERE QSYS.DOKUMENTE.NLFD = QSYS.RQMS_STAMM.NRQNR
AND QSYS.RMQS_STAMM.SRQNR = '"& Me.lstReklamenummern.Value &"'"
objrcrd.Open strsql
I have just upgraded to V2.0.0 and tried the following code ..
SqlQuery diffSql = new SqlQuery(PendingAvGroup.class,
" from PendingAvGroup as pnd " +
"where not exists(select 1 from " +
"\"Processed_PendingAvGroup_cache\".PendingAvGroup prc " +
" WHERE prc.resourceGroupId = pnd.resourceGroupId)"
);
But i get the following error ..
Caused by: org.h2.jdbc.JdbcSQLException: Column "Pending_PendingAvGroup_cache.PENDINGAVGROUP._KEY" not found;
SQL statement:
SELECT "Pending_PendingAvGroup_cache".PendingAvGroup._key, "Pending_PendingAvGroup_cache".PendingAvGroup._val from PendingAvGroup as pnd where not exists(select 1 from "Processed_PendingAvGroup_cache".PendingAvGroup prc WHERE prc.resourceGroupId = pnd.resourceGroupId) [42122-195]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.195.jar:1.4.195]
Its appears that when ever I provide a FROM clause I get '._KEY" not found;' error ... even for a single table.
Id really appreciate anyones help on this ..
Thanks
Paul
This is actually a quirky thing of SQL (I'm not sure if it is a standard or just H2). By default Ignite generates query with the original table name in select clause "Pending_PendingAvGroup_cache".PendingAvGroup, but it must actually use your alias pnd there.
To solve this you have to set the alias on SqlQuery and Ignite will generate correct query:
SqlQuery diffSql = new SqlQuery(PendingAvGroup.class, "...").setAlias("pnd");
Another option is to use SqlFieldsQuery:
new SqlFieldsQuery("select _key, _val from ....")
I have been getting the SQL Server error '80040e14' saying Incorrect syntax near the keyword 'ORDER'. However, the line it is pointing is the next line to the line where there is the word "ORDER" Can someone point out the syntax mistake I did in the following sql code? ASP is the language I have been using for this project.
SQL = " SELECT TS.ID, types"&_
" FROM tblTickets TS"&_
" WHERE TS.ID = "& Request("ticketid") &" ORDER BY dateof DESC"
SET RSticket = objConn.Execute(SQL)
So,it points error in the last line whereas "ORDER" is in different line.
If Request("ticketid") returns a string value then you need to add single quotes around it:
SQL = " SELECT TS.ID, types"&_
" FROM tblTickets TS"&_
" WHERE TS.ID = '"& Request("ticketid") &"' ORDER BY dateof DESC"
the ORDER BY will fail, because dateof isnt a selected field
try " WHERE TS.ID = "& Replace(Request("ticketid"),"'","''") &" ORDER BY 1 DESC"
Thank you all, ya I was just missing single quote wrap for & Request("ticketid").Now it works fine.
I'm trying to execute below query but error occur like
Syntax error (missing operator) in query expression 9 ORDER BY empSalary.ID DESC.
cmd.CommandText = "UPDATE EmpSalary SET emp_Advance=" & TextBox7.Text & ",emp_salary=" & TextBox4.Text & " ORDER BY empSalary.ID DESC"
First, you should never concatenate strings directly to your sql. This is a security risk. Google sql injection.
Instead, you should use parameterized queries or stored procedures.
Second, the oreder by part has no meaning in this type of query, and perhaps is the reason you get this exception.