I am trying to insert the following into my sqlite3 database:
INSERT INTO candlestick_1min (timestamp, close, high, low, open, volume)
VALUES (2016-08-11 15:30:00, 34.258, 34.318, 34.258, 34.302, 45890.0);
For some reason it's giving me the following error:
Error: near "15": syntax error
The schema is the following:
CREATE TABLE candlestick_1min (timestamp TEXT PRIMARY KEY NOT NULL, close REAL, high REAL, low REAL, open REAL, volume REAL);
Can anybody tell me why the error is showing up? The table is completely empty by the way.
Put the date values inside quotes '' like
INSERT INTO candlestick_1min (timestamp, close, high, low, open, volume)
VALUES ('2016-08-11 15:30:00', 34.258, 34.318, 34.258, 34.302, 45890.0);
Related
I have to create an SQR that generates a list of EEIDs, if there were any changes to the Pension data in the past day. The SQR compiles and works perfectly when I hardcode in the table names.
However, when I tried using variables for the table names, I get a compile error
I've pasted the portion of SQR that I'm trying to fix
When I start using $tableName and $auditTableName as table variables, that's when I get the error and I'm not sure what is going wrong
Can anyone help?
Please and Thank You
!***************************
begin-procedure Process-Main
!***************************
let $tableName = 'PS_PENSION_PLAN'
let $auditTableName = 'PS_AUDIT_PENSION_PLN'
let $dummy-dyn-variable = ''
begin-SELECT DISTINCT
L.EMPLID
L.EMPL_RCD
do someProcName(&L.EMPLID, &L.EMPL_RCD)
FROM [$dummy-dyn-variable]
(
SELECT DISTINCT
PP.EMPLID,
PP.EMPL_RCD,
PP.EFFDT,
'1901-01-01 12:00:00' AS AUDIT_STAMP
FROM [$dummy-dyn-variable] [$tableName] PP
UNION
SELECT DISTINCT
A.EMPLID,
A.EMPL_RCD,
A.EFFDT,
A.AUDIT_STAMP
FROM [$dummy-dyn-variable] [$auditTableName] A
)L
WHERE DATEDIFF(DAY,CAST(L.AUDIT_STAMP AS DATE),SYSDATE) = 1
ORDER BY 1,2
end-SELECT
end-procedure
Edit:
does the UNION have anything to do with this?
I keep receiving is this error:
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 102 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'FROM'.
(SQR 5528) ODBC SQL dbdesc: SQLNumResultCols error 8180 in cursor 1:
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
Edit2:
Ok, initial problem solved with [$dummy-dyn-variable], which led to the next problem with the DO command. I've updated the code above with DO someProcName(param_a, param_b)
I am now getting an error saying:
(SQR 2002) DO arguments do not match procedure's
Weird part, if I remove the dynamic table variables and hardcode the table names in the FROM section, then it compiles properly without errors. This makes me believe that the error is not related to my someProcName (maybe?)
am I missing something here?
Below is my code for creating and loading data with fastload onto teradata database.
CREATE TABLE MARK,FALLBACK
(
A INTEGER NOT NULL,
B INTEGER NOT NULL,
C DATE,
D INTEGER NOT NULL,
E DECIMAL(10,2),
PRIMARY KEY (D)
) PRIMARY INDEX(A,B);
While processing the fastload script, it gives an error of
RDBMS error 3621: Cannot load table MARK
unless secondary indexes and join indexes are removed
How should I solve this kind of problem?
I am trying to use a cursor for the following block of code, but it is not compiling and giving error saying the following:
PL/SQL: SQL Statement ignored
PL/SQL: ORA-00947: not enough values
All the trxn table values are being fetched, Does anyone have faced similar error before? Any way this can be fixed or am I missing something?
I am trying to use a cursor for the following block of code, but it is not compiling and giving error saying the following:
PL/SQL: SQL Statement ignored
PL/SQL: ORA-00947: not enough values
All the trxn table values are being fetched, Does anyone have faced similar error before? Any way this can be fixed or am I missing something?
cursor bulk_select is
with trxn as (
select --+ materialize
-- Wire info
wt.id
,wt.fl
,wt.abc
,wt.xyz
from
wt_temp_t wt
where
<condition>
)
select a
,b
,c
from
(
select
w.aa
,w.bb
,w.cc
trxn w
where
<condition>
)included_trxn
-- Left joins in case the acct is null or external
left outer join table
acct a_cp,
cust c_cp
where
<condition>
type tab_bulk_select is table of bulk_select%rowtype;
cur_bulk_select tab_bulk_select;
BEGIN
EXECUTE IMMEDIATE 'truncate table AML_CAMBRS6_HUB_SPOKE_TMP';
commit;
open bulk_select;
LOOP
fetch bulk_select bulk collect into cur_bulk_select limit 50000;
FORALL i IN 1..cur_bulk_select.COUNT
insert /*+ append */ into AML_CAMBRS6_HUB_SPOKE_TMP (a,b,c)
values cur_bulk_select(i);
commit;
EXIT When bulk_select%NOTFOUND;
END LOOP;
CLOSE bulk_select;
Its because in trxn you are fetching only 2 values wt.fo_trxn_seq_id ,wt.pass_thru_fl.
But in select clause select w.aa ,w.bb, w.cc trxn w where <condition> you are using aa, bb, cc and also missing from in statement.
I want to move data from one table to a table.
I wrote one plsql code for this process.
Column sizes sometimes do not fit when I move data from table 'TABLE_1' to table 'TABLE_2'.
oracle is sending an error as follows.
I have identified one exception to get rid of this error.
but this exception is in a static state.
I want to make this exception part dynamic.
that is, if this error occurs in other columns, I want to automatically increase the size of the column in those columns.
the following is the plsql code I wrote.
for example, an oracle insert operation may give the same error in the 'explanation' column.
I want to modify the size of the 'explanation' column.
if this error occurs,
I want to perform these operations automatically for each column.
DECLARE
SAYAC INTEGER;
SAYAC_2 INTEGER;
extension_already_exists EXCEPTION;
PRAGMA EXCEPTION_INIT(extension_already_exists, -12899);
BEGIN
SAYAC:=0;
FOR XX IN (SELECT
FILE_NO,
NAME,
EV_ADRESI,
explanation
FROM TABLE_1
WHERE NOT EXISTS (SELECT *
FROM TABLE_2
WHERE TABLE_2.FILE_NO = TABLE_1.FILE_NO )
)LOOP
BEGIN
SAYAC:=SAYAC+1;
EXECUTE IMMEDIATE 'INSERT INTO
TABLE_2(
FILE_NO,
NAME,
EV_ADRESI,
explanation
)
VALUES
(
:A,
:B,
:C,
:D
) '
using XX.FILE_NO,XX.NAME,XX.EV_ADRESI,xx.explanation
;
IF MOD(SAYAC,1000)=0 THEN
COMMIT;
END IF;
EXCEPTION WHEN extension_already_exists THEN
dbms_output.put_line('seviye cok buyuk = '||sqlcode||' FILE_NO = '||XX.FILE_NO||','||xx.EV_ADRESI);--this error may occur in other columns
EXECUTE IMMEDIATE 'ALTER TABLE TABLE_2 MODIFY EV_ADRESI,explanation VARCHAR2(100)'; --forexample xx.explanation
NULL; --I want to make this place dynamic
end;
END LOOP;
COMMIT;
END;
ORA-12899: value too large for column "HOSPITAL"."table_2"."EV_ADRESI" (actual: 34, maximum: 20)
ORA-06512: at line 20
That won't work anyway. Even if you capture the error and enlarge the column, you'd miss the offending row as you should repeat the previous insert (which failed).
From my point of view, you should first match columns' datatpyes and then move data from here to there in a simple manner.
By the way, why did you use dynamic SQL for insert? There's nothing dynamic there.
I wanted to name this post Make SQLite abort on first error but StackOverflow's AI overlords decided it doesn't fit their conception of intelligent human behavior. For the record, I was googling exactly that, but perhaps even Google AI considered my question unworthy and didn't bother to help me. Mods, feel free to change the title according to what your AI bosses desire (if you can figure it out).
I have this script
create if not exists table entries (
id integer primary key,
start datetime not null,
end datetime not null
);
delete from entries;
insert into entries values (1, '2018-08-01 10:00', '2018-08-01 15:00');
insert into entries values (2, '2018-08-01 17:00', '2018-08-01 20:00');
insert into entries values (1, '2018-08-02 19:00', '2018-08-02 00:00');
insert into entries values (1, '2018-08-03 00:00', '2018-08-03 04:00');
insert into entries values (1, '2018-08-03 14:00', '2018-08-03 18:00');
There is a mistake in create statement. When I run the script I get
% sqlite3 db.sqlite3 <ddl.sql
Error: near line 1: near "if": syntax error
Error: near line 7: no such table: entries
Error: near line 8: no such table: entries
Error: near line 9: no such table: entries
Error: near line 10: no such table: entries
Error: near line 11: no such table: entries
Error: near line 12: no such table: entries
How do I make SQLite exit executing the script on first error it encounters? I'm looking for equivalent of set -e in Bash.
From the documentation, it looks like you can turn on the dot command .bail.
.bail on|off Stop after hitting an error. Default OFF
See also - O'Reilly Using Sqlite
Edit
To exit, you can use the .exit dot command.