iOS: SQLITE INSERT QUERY ERROR - ios
I am constantly receiving DB error NO Column found inspite i have recreated column and verified it too many times.
Below is the table structure:
CREATE TABLE "ContractorTester" ("ContrTestID" VARCHAR NOT NULL ,"Ack" VARCHAR NOT NULL ,"TesterLName" VARCHAR,"TesterFName" VARCHAR,"GaugeName1" VARCHAR,"GaugeMake1" VARCHAR,"TestCrossConLic" VARCHAR,"CCLicExpDate" VARCHAR,"GaugeSerialNum1" VARCHAR,"GaugeCalibrDate1" VARCHAR,"ContrCompanyName1" VARCHAR,"ContrAddr1" VARCHAR,"ContrCity1" VARCHAR,"ContrState1" VARCHAR,"ContrZip1" VARCHAR,"ContrPhone1" VARCHAR,"Lat" DOUBLE,"Log" DOUBLE,"MCreatedDate" VARCHAR,"MUpdatedDate" VARCHAR,"ActLocalCT
" VARCHAR,"ContrTestTranID" VARCHAR PRIMARY KEY )
Below is Insert Query:
INSERT OR REPLACE INTO ContractorTester ('GaugeName1','GaugeMake1','ContrPhone1','ContrTestTranID','TesterFName','ContrAddr1','ContrCity1','ContrZip1','CCLicExpDate','TestCrossConLic','GaugeCalibrDate1','Ack','TesterLName','ContrTestID','ContrState1','ContrCompanyName1','GaugeSerialNum1','ActLocalCT','Log','Lat') VALUES ('TK-99F','MIDWEST','(847) 111-3314','0','Jack','819 Main1','Lake Zurich','60051','2016-04-17T00:00:00.003','XC3673','2015-04-17T00:00:00.003','0','Skirm','5','IL','American Backflow Prevention Inc.','TG0605','1','0','0')
Below is the error:
SQLiteManager: Likely SQL syntax error: INSERT OR REPLACE INTO ContractorTester ('GaugeName1','GaugeMake1','ContrPhone1','ContrTestTranID','TesterFName','ContrAddr1','ContrCity1','ContrZip1','CCLicExpDate','TestCrossConLic','GaugeCalibrDate1','Ack','TesterLName','ContrTestID','ContrState1','ContrCompanyName1','GaugeSerialNum1','ActLocalCT','Log','Lat') VALUES ('TK-99F','MIDWEST','(847) 111-3314','0','Jack','819 Main1','Lake Zurich','60051','2016-04-17T00:00:00.003','XC3673','2015-04-17T00:00:00.003','0','Skirm','5','IL','American Backflow Prevention Inc.','TG0605','1','0','0') [ table ContractorTester has no column named ActLocalCT ]
Exception Name: NS_ERROR_FAILURE
Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]
Please any one review and let me know what is the wrong in above Queries.
Thanks in advance.
Replace
INSERT OR REPLACE INTO ContractorTester
with
INSERT OR REPLACE INTO ContractorTester VALUES
Without the VALUES the list in parens is the list of columns to insert into, not the list of values to insert.
Related
SQLite alter table with result from select statement
I am trying to execute this statement in mozilla sqlite add-on alter table (select tbl_name from sqlite_master where rowid=1) add GUID varchar But this runs into error : SQLiteManager: Likely SQL syntax error: alter table (select tbl_name from sqlite_master where rowid=1) add GUID varchar [ near "(": syntax error ] Exception Name: NS_ERROR_FAILURE Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement] the statement :select tbl_name from sqlite_master where rowid=1 works fine
You cannot do that: in SQL, table names and column names must be identifiers embedded in the SQL string itself. They cannot come from values that you query, or even in a query parameter. You need to select the table name, make the alter table statement, and then execute it separately.
Error: Inserting multiple values i get this error ORA-00911: invalid character
Im a first year student distance learning student who is experiencing problems with me building my database. The error i get is ORA-00911: invalid character when i do the following: INSERT INTO ORDER_LINE VALUES ('21608','AT94',11,21.95); INSERT INTO ORDER_LINE VALUES ('21610','DR93',1,495.00); INSERT INTO ORDER_LINE VALUES ('21610','DW11',1,399.99); INSERT INTO ORDER_LINE VALUES ('21613','KL62',4,329.95); INSERT INTO ORDER_LINE VALUES ('21614','KT03',2,595.00); INSERT INTO ORDER_LINE VALUES ('21617','BV06',2,794.95); INSERT INTO ORDER_LINE VALUES ('21617','CD52',4,150.00); INSERT INTO ORDER_LINE VALUES ('21619','DR93',1,495.00); INSERT INTO ORDER_LINE VALUES ('21623','KV29',2,1290.00); I have noticed that when I insert the values one by one all seems to be fine. The problem somehow occurs when i want to insert more than one value at a time. The forums have tons of similar problems but because im a NOOB i cant see where i have gone wrong. I have retyped everything because i though i may have made a mistake somewhere but still experience this problem.
I had the same issue using Toad to Oracle 10g. You have to put your insert queries between BEGIN and END: BEGIN INSERT INTO ORDER_LINE VALUES ('21608','AT94',11,21.95); INSERT INTO ORDER_LINE VALUES ('21610','DR93',1,495.00); END;
why the result of Module.sum(:field) is integer?
create table test_tables ( id number(38) primary key, name varchar2(50), age number(5), gender varchar2(10), point number(5,2) ); insert into test_tables values (1,'name1',20,'male',80.5); insert into test_tables values (2,'name2',21,'female',60.5); insert into test_tables values (3,'name3',23,'male',90.5); insert into test_tables values (4,'name4',19,'male',79.5); insert into test_tables values (5,'name5',18,'female',80.5); The result of TestTable.sum(:point) is 391, why not 391.5? I check rdoc,there are some description: The value is returned with the same data type of the column But in my case,the type of 'point' is number(5,2). It's not a float?
I'm not especially familiar with SQLite but I think you should be using a DECIMAL type in your create table statement. More details: Active Record SQLite Type Mapping SQLite Types Be careful of this issue though. It seems that the sqlite3 ruby driver insists on creating Float ruby objects rather than BigDecimal for DECIMAL query results.
SQLite3/Ruby statement question
I am trying to import a file as a table in SQLite 3 using a Ruby script. I need to assign a tab separator, and I used the following code: db = SQLite3::Database.new("meshdb2.db") db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL) db.prepare(".separator '\t'") I am coming back with a "/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3/errors.rb:62:in `check': near ".": syntax error (SQLite3::SQLException)" error, and I think it is because of the db.prepare() command. What is the proper command when I want to pass settings through Ruby to SQLite 3? -Bobby
You're missing the ending quotation mark on the second line after your query. db.execute("CREATE TABLE IF NOT EXISTS pubmed(id integer primary key,prideID INT NOT NULL,pubmedID VARCHAR(10) NOT NULL") # >------------------->------------------->------------------->------------------->------------------->----------------^
How to convert a table column to another data type
I have a column with the type of Varchar in my Postgres database which I meant to be integers... and now I want to change them, unfortunately this doesn't seem to work using my rails migration. change_column :table1, :columnB, :integer Which seems to output this SQL: ALTER TABLE table1 ALTER COLUMN columnB TYPE integer So I tried doing this: execute 'ALTER TABLE table1 ALTER COLUMN columnB TYPE integer USING CAST(columnB AS INTEGER)' but cast doesn't work in this instance because some of the column are null... any ideas? Error: PGError: ERROR: invalid input syntax for integer: "" : ALTER TABLE table1 ALTER COLUMN columnB TYPE integer USING CAST(columnB AS INTEGER) Postgres v8.3
It sounds like the problem is that you have empty strings in your table. You'll need to handle those, probably with a case statement, such as: execute %{ALTER TABLE "table1" ALTER COLUMN columnB TYPE integer USING CAST(CASE columnB WHEN '' THEN NULL ELSE columnB END AS INTEGER)} Update: completely rewritten based on updated question.
NULLs shouldnt be a problem here. Tell us your postgresql version and your error message. Besides, why are you quoting identifiers ? Be aware that unquoted identifiers are converted to lowercase (default behaviour), so there might be a problem with your "columnB" in your query - it appears quoted first, unquoted in the cast. Update: Before converting a column to integer, you must be sure that all you values are convertible. In this case, it means that columnB should contains only digits (or null). You can check this by something like select columnB from table where not columnB ~ E'^[0-9]+$'; If you want your empty strings to be converted to NULL integers, then run first UPDATE table set columnB = NULL WHERE columnB = '';