Temporal Database Update and Delete queries - sql

I need some help to resolve the problem that i wrote below,
UPDATE OYKUN_EMPLOYEE t1,table(t1.EMPMANAGER) t2 SET t2.value = 'ÖYKÜN' WHERE EMPNO=100
Its temporal database and I'm getting the error 'SET' keyword is missing. How can i handle this error.
EMPMANAGER is the column name which contains VT_LB, VT_UB, VALUE attributes. I'm using attribute timestamping approach

Related

"Ambiguous column name" in SQLite using update and set

First of all, I'm sorry because I know there are many questions regarding "Ambiguous column name" error here in Stack but I'm really newbie in SQL and doing my first queries using SQLite I found this error. After analyzing other several questions I didn't find a solution for my problem (maybe, it's here for sure but I couldn't find) and this is:
When I use update, set and doing any operation such as the example I put... Well, the error appears and I don't understand the problem. I tried some options but nothing.
update nota
set subtot=cantidad*precio
from nota inner join producto on producto.clave_prod=nota.clave_prod1;
"Cantidad" column is on table called "nota" and "precio" column is on table called "producto" and both are linked between foreign keys.
Thank you so much in advance!
Your syntax is wrong.
There is no need to refer to the updated table after FROM and the ON clause must be replaced with a WHERE clause.
This is the correct syntax (if your SQLite version is 3.33.0+) for a join-like UPDATE satement:
update nota
set subtot = nota.cantidad * producto.precio -- subtot must not be qualified with nota.
from producto
where producto.clave_prod = nota.clave_prod1;
or with aliases:
update nota AS n
set subtot = n.cantidad * p.precio -- subtot must not be qualified with n.
from producto AS p
where p.clave_prod = n.clave_prod1;

how to update in-memory table dynamically using dolphindb database

Is there any way to update an in-memory table dynamically using dolphindb? I need more suggestions to write a dynamic update function. Now I can only get the table name returned. I tried several methods to update the data for a specified table but failed.
Script 1:
table1=table(1..6 as id,2..7 as v, 3..8 as v1, 4..9 as v2, 5..10 as v3 );
share table1 as t1;
tableName ="t1";
update!(tableName, `v, 666);
Error report:
Read only object or object without ownership can't be applied to mutable function update!
Script 2:
updateSql = "update t1 set v = 999;";
parseExpr(updateSql).eval;
Error report:
Invalid expression: update t1 set v=999;
What's the correct syntax to update a specified table?
Use DolphinDB's function update! to update the columns in an existing table:
update!(table, colNames, newValues, [filter])
Here table is a DolphinDB table. The error occurs because your script defines the table type to be of STRING type. Use objByName to change it:
update!(objByName(tableName), `v, 666);
If you want to know more about dynamical expression generation, meta programming will be of help.

Delete from table Where date statement error

I'm trying to delete some information from a table that has a date < 16/16/2019 in C#. The query gave me an exception so I'm trying to do it directly in MS Access and even here it gave me error.
SELECT *
FROM TableName
WHERE (((TableName.Date)<= #16/06/2019#));
If I use the above, the query gives me the result that I expect which is all information which is stored before a specific date.
But if I use the DELETE statement:
DELETE
FROM TableName
WHERE (((TableName.Date)<= #16/06/2019#));
It gives me the error:
The search key was not found in any record
Why?
Given the information in the comments, I would suggest the following:
delete from TableName t where t.data <= #2019-06-16#

Update multiple values in an oracle table using values from an APEX collection

I am using APEX collections to store some values and pass them between pages in Oracle Application Express 4.2.3.
I would like to then perform an update statement on a table called "project" with the values from the collection.
My code so far is as follows:
update project
SET name=c.c002,
description=c.c007,
start_date=c.c004,
timeframe=c.c005,
status=c.c009
FROM
apex_collections c
WHERE
c.collection_name = 'PROJECT_DETAILS_COLLECTION'
and id = :p14_id;
where :p14_id is the value of a page item.
However, I am getting the following error:
ORA-00933: SQL command not properly ended
Anyone have any idea on how to approach this?
Thanks!
The UPDATE syntax you are using is not valid in Oracle; it does not allow you to use FROM in the way you are attempting.
The simplest way to do this in Oracle would with a subquery:
update project
set (name, description, start_date, timeframe, status) =
(select c.c002, c.c007, c.c004, c.c005, c.c009
FROM
apex_collections c
WHERE
c.collection_name = 'PROJECT_DETAILS_COLLECTION'
)
WHERE
id = :p14_id
;
Note that if the subquery returns no rows, the columns in the target table will be updated to NULL; this could be avoided by adding a similar EXISTS condition in the predicate for the update. It could also be avoided by using a MERGE statement instead of an UPDATE.
If the subquery returns multiple rows, the statement will throw an error. It looks like tthat should not be the case here.

Update A multi-valued field in Access

I have created a lookup table in Access to provide the possible values for a column. Now I need to update this column with the data it had before I converted the column. I am unable to figure out a SQL Query that will work. I keep getting the error "An UPDATE or DELETE query cannot contain a multi-valued field." My research has suggested that I just need to set the value of the column but this always updates 0 records:
UPDATE [table_name] SET [column_name].Value = 55 WHERE [table_name].ID = 16;
I know this query will work if I change it to update a text column, so it is definitely a problem with just this column.
If you're adding a value to your multi-valued field, use an append query.
INSERT INTO table_name( [column_name].Value )
VALUES (55)
WHERE ID = 16;
If you want to change one particular value which exists in your multi-valued field, use an UPDATE statement. For example, to change the 55 to 56 ...
UPDATE [table_name]
SET [column_name].Value = 56
WHERE [column_name].Value = 55 And ID = 16;
See Using multivalued fields in queries for more information.
I have figured this out! It certainly was counter-intuitive! You have to use an INSERT statement to do the update.
-- Update a record with a multi-valued field that has no value
INSERT INTO [table_name] ( [[column_name].[Value] )
VALUES(55)
WHERE [table_name].ID = 16;
This confused me because I was expecting an UPDATE statement. I think it actually inserts a record into a hidden table that is used to associate multiple values with this column.
I am working with Sharepoint, I created the tables as multi-value fields, ran into the error with my INSERT INTO statement, went back to Sharepoint to change to non-multi-value fields, but that didn't fix it.
Recreated the table without using multi-value fields, and the INSERT INTO worked just fine.
do not use the .value part
UPDATE [table_name] SET [column_name] = 55 WHERE [table_name].ID = 16;
INSERT INTO Quals (cTypes.[value])
SELECT Quals_ContractTypes.ContractType
FROM Quals_ContractTypes
WHERE (Quals.ID = Quals_ContractTypes.ID_Quals);
I gotta say I didn't understand very well your problem but I saw something strange in your query. Try this:
UPDATE [table_name] SET [column_name]= 55 WHERE [table_name].ID = 16;
UPDATE:
Look at this link: it has an example
UPDATE Issues
SET Issues.AssignedTo.Value = 10
WHERE (((Issues.AssignedTo.Value)=6)
AND ((Issues.ID)=8));
NOTES
You should always include a WHERE
clause that identifies only the
records that you want to update.
Otherwise, you will update records
that you did not intend to change. An
Update query that does not contain a
WHERE clause changes every row in the
table. You can specify one value to
change.
The Multi-Valued field refers to Access databases that have tables with columns, that allow you to select multiple values, like a Combo Checkbox list.
THOSE are the only Access types that SQL cannot work with. I've tested all Access lookup possibilities, including hard-coded values, and lookup tables. They work fine, but if you have a column that has the Allow Multiple select options, you're out of luck. Even using the INSERT INTO as mentioned below, will not work as you'll get a similar but different error, about INSERTing into multi-valued fields.
As mentioned it's best to avoid using such tables outside of Access, and refer to a table specifically for your external needs. Then write a macro/vba script to update the real tables with the data from the "auxiliary" table.