In my SQLite I want to insert 2 rows.
INSERT INTO notification_invoice (amount,currencyISOCode) VALUES
(1.1,'498'),
(34.2,'980');
But I get error:
30-Nov-18 12:21:21: SQL Error: near ",": syntax error INSERT INTO
notification_invoice (amount,currencyISOCode) VALUES (1.1,'498'),
(34.2,'980');
>
Related
I'm new at SQLite and i'm trying to add a column into a table which is exist or not exist with the statement below.
ALTER TABLE
table1
ADD
columnx TEXT NULL
WHERE
type = "table"
i've got the SQLiteException: near "WHERE": syntax error (code 1) error. What is wrong with that statement? What is the correct way of adding new column into a table with checking the existance of the table?
I cannot insert NULL (NA) values into an SQL Server Date column field using dbWriteTable.
dbWriteTable(con, "BIOutput", data[Cdate == date,], append = TRUE);
I get the error:
Error in result_insert_dataframe(rs#ptr, values) :
nanodbc/nanodbc.cpp:1587: 22007: [Microsoft][ODBC SQL Server Driver]
[SQL Server]Conversion failed when converting date and/or time from
character string.
I understand this works for numeric fields, but why doesn't it work for Dates? What workaround can I use?
I have a mixed case column in my_table that can only be queried using double quotes in psql. For example:
select "mixedCase" from my_table limit 5; would be the correct way to write the query in psql, and this returns records successfully
However, I am unable to replicate this query in R:
I have tried the following:
dbGetQuery(con, "SELECT '\"mixedCase\"' from my_table limit 5;")
which throws: RS-DBI driver warning: (unrecognized PostgreSQL field type unknown (id:705) in column 0)
dbGetQuery(con, "SELECT 'mixedCase' from my_table limit 5;")
which throws: RS-DBI driver warning: (unrecognized PostgreSQL field type unknown (id:705) in column 0)
dbGetQuery(con, "SELECT "mixedCase" from my_table limit 5;")
which throws Error: unexpected symbol in "dbGetQuery(con, "SELECT "mixedCase"
What is the solution for mixed case columns with the RPostgreSQL package?
You seem to understand the problem, yet you never actually tried just using the literal correct query in R. Just escape the double quotes in the query string and it should work:
dbGetQuery(con, "SELECT \"mixedCase\" from my_table limit 5;")
Your first two attempts would have failed because you are passing in mixedCase as a string literal, not as a column name. And the third attempt would fail on the R side because you are passing in a broken string/code.
I am trying to parse XML in PL SQL. But getting following error
Error report:
ORA-06550: line 21, column 43:
PL/SQL: ORA-00902: invalid datatype
ORA-06550: line 17, column 1:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
I am trying to run below query
DECLARE
l_xml xmltype:= xmltype('<Table>
<Data>
<DataKey>Test</DataKey>
<DataTypeID>8</DataTypeID>
<DataValue>test1</DataValue>
<Id>eb96c9c1-6236-403d-9afa-6d45ec623dbc</Id>
</Data>
</Table>');
begin
select * FROM
xmltable ('/Table/Data' passing l_xml
columns
DataKey nvarchar2(50) path '/Data/DataKey'
,DataTypeID int, path '/Data/DataTypeID'
, DataValue nvarchar2(1024) path '/Data/DataValue');
end;
/
I am new to PL/SQL, so not able to figure out the error. Can anybody help me here?
Thanks
You have an extra comma between int and path:
,DataTypeID int, path '/Data/DataTypeID'
should be
,DataTypeID int path '/Data/DataTypeID'
Or you could use number instead of int.
Your select also has to be selecting into something, since this is in a PL/SQL context. So now you'll get a PLS-00428 error. Without knowing what you plan to do with the results it isn't entirely obvious how you should correct that - whether you don't actually need PL/SQL, or you want to loop over the results to do something with them, or insert into another table, or...
I have a table SyncTokenLock that has column lockName that is of CLOB type. When I run following query from SQLDeveloper -
select * from SyncTokenLock where
lockName='com.vmware.horizon.datastore.impl.ProvisioningStateDataServiceImpl';
I get following exception -
ORA-00932: inconsistent datatypes: expected - got CLOB
00932. 00000 - "inconsistent datatypes: expected %s got %s"
I get similar error when this query is executed through Hibernate (3.6.10) against Oracle 11g. Hibernate throws following exception -
ORA-00932: inconsistent datatypes: expected - got CLOB
Any idea what could the reason be.
Correct, you can't use equality with a CLOB in the WHERE clause. But you can do this:
SELECT * FROM SyncTokenLock
WHERE dbms_lob.substr(lockName, 100) =
'com.vmware.horizon.datastore.impl.ProvisioningStateDataServiceImpl';
Does your column really need to be a CLOB? Are you expecting values over 4000 characters? If not, use a VARCHAR2.
Instead of using the equal sign, you may use like:
select * from SyncTokenLock where lockName like 'com.vmware.horizon.datastore.impl.ProvisioningStateDataServiceImpl';