delete statement raises an error in DolphinDB - sql-delete

why and how the delete syntax is supported in DolphinDB?
delete from t where date = min(date) context by symbol
Why my statement raises an error?

Related

DB2 Error while creating CURSOR - [Code: -84, SQL State: 42612] UNACCEPTABLE SQL STATEMENT. SQLCODE=-84, SQLSTATE=42612, DRIVER=4.28.11

I am getting error while I create CURSOR for a select statement.
declare mycursor cursor for
select count(*) FROM BOM_LINK
WHERE TEST_OBJECT_OID IN (SELECT DISTINCT TESTOBJECT_OID FROM TESTOBJECT WHERE TESTOBJECT.TESTOBJECTTYPE_OID = 3);
Basically my requirement is different,- I should be deleting the records. In place Select it should Delete, for that again I am getting error as mentioned in the below Stackoverflow - Question, DB2 Error Code -495 while we try deleting records counts more than 400k , so I am trying to delete records row-by-row by creating CURSOR
Can someone assist us on the issue concerns to CURSOR. Over that we could make a progress.
Here is error with the code,
Code: -84, SQL State: 42612] UNACCEPTABLE SQL STATEMENT. SQLCODE=-84, SQLSTATE=42612, DRIVER=4.28.11

Redshift Correlated Subquery within copy command

I am trying to query from a table within a copy command however, I have continually gotten errors. Here is the example SQL statement.
copy schema.table
from 's3://bucket/folder`
iam_role (select value from roles.iam where key = 'IAMRole');
The inner select statement on its own returns a value however, when I run the above, I get the following error:
SQL Error [500310] [42601]: [Amazon](500310) Invalid operation: syntax error at or near "("
The COPY command, as you must suspect, does not support embedded SQL.
If you want to do something like this, you can, but you'll need a procedure.

How to create a trigger before insert in db2

I have three tables below:
I need to create a trigger to disallow students to take a class without completing their pre-requisites (must use a trigger). The trigger must return an error message "Missing Pre-req" when trying to insert a class without its proper pre-req.
So far, I wrote a command below:
create trigger checkPrereq
before insert on HW3.SCHEDULE
referencing new as newRow
for each row
When
(
select GRADE
from HW3.SCHEDULE
where HW3.SCHEDULE.ClassId =
(
select PrereqId from HW3.CLASS_PREREQ
where newRow.ClassId = HW3.CLASS_PREREQ.ClassId
)
) in ('F', null)
begin atomic
set newRow.Semester = null;
signal sqlstate 'KILLED' set message_text = ('Missing Pre-req');
end
but I got a warning:
DB21034E The command was processed as an SQL statement because it was
not a valid Command Line Processor command. During SQL processing it
returned: SQL0104N An unexpected token "GRADE" was found following
"ach row When (select". Expected tokens may include: ")". LINE
NUMBER=1. SQLSTATE=42601
I can not understand what was happening here. Could you please help fix this? Any help is appreciated!

update column of a table in PostgreSQL

I have some issue regarding update column of a table in PostgreSQL
My PostgreSQL version is 9.3
Eg:
In below example jifileresource is the table and column name is DATA
public is the schema
bytea_import is the function to retrieve the content of a file
UPDATE jifileresource
SET DATA=(SELECT public.bytea_import('D:/BOB_XML/BOB.xml')
WHERE ID=2235;
i am getting error like this:
ERROR: syntax error at end of input
LINE 4: WHERE ID=2235
^
********** Error **********
ERROR: syntax error at end of input
SQL state: 42601
You are opening two parentheses and closing only one.
UPDATE jifileresource
SET DATA = (SELECT public.bytea_import('D:/BOB_XML/BOB.xml')) <-- here a ")" was missing
WHERE ID=2235;

"No current record for fetch operation" for select insert

Can anyone see why I'm getting the "No current record for fetch operation" below?
I'm successfully skipping duplicate records by catching and not re-throwing the unique key violation exception below. There is another error however.
FOR SELECT
...
FROM
P_SELECT_CLAIM_FILE cf
ORDER BY
cf.DATESBM, cf.TIMESBM, cf.TRANSCDE
INTO
...variables
DO BEGIN
INSERT INTO
CLAIM_TABLE (...)
VALUES (...variables);
WHEN GDSCODE unique_key_violation DO
TX_ID=0;
WHEN GDSCODE no_cur_rec DO
/* Why does this happen?
-508 335544348 no_cur_rec No current record for fetch operation
*/
EXCEPTION E 'no_cur_rec ' || TX_ID;
END
The procedure P_SELECT_CLAIM_FILE contains another FOR SELECT INTO with lots of trimming and finally a SUSPEND command. This reads from a fixed width text file.
I'm tempted to change this into a single INSERT SELECT where not exists statement. I prefer to make a minimal fix instead however; the holidays already here.