Error: Inserting multiple values i get this error ORA-00911: invalid character - oracle-xe

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;

Related

Snowflake stream behavior

I have following fields in table 1-
db,schema,jobnm,status,runtime, ins_tstmp, upd_tstmp.
A stream has been created on table 1.
A stored procedure was written to loop through another table's dataset (4 records) and write all 4 records to table 1 if they don't already exist else update (using merge sql here; ins_tstmp gets populated via insert part of merge while upd_tstmp gets updated via update part ).
As expected, table1 has all 4 records and Stream also has 4 records with metadata$action as INSERT . UPD_TSTMP is null here.
Now on 2nd run, same 4 records were retrieved. Since they were a match, upd_tstmp got populated in both table 1 and stream but why metadata$action is INSERT only? Not seeing 2 entries for an update. Could someone please explain what I am missing here?
Thanks
Since they were a match, upd_tstmp got populated in both table 1 and
stream but why metadata$action is INSERT only?
The METADATA$ACTION column can have 2 possible values: INSERT and DELETE. So you can't see "UPDATE" in this column.
METADATA$ISUPDATE: This is an extra column indicating whether the operation was part of an UPDATE statement. In your case, you should also see it "false" because Streams record the differences between two offsets. If a row is added and then updated in the current offset, the delta change is a new row. The METADATA$ISUPDATE row records a FALSE value.
https://docs.snowflake.com/en/user-guide/streams-intro.html#stream-columns

SQL Server statements imported into Postgres DB now unable to see images - Rails Project

Yesterday I was able to figure out how to use the following query in order to get rid of duplicate results (see SQL Query to delete duplicate values in a 3 tables inner join with two different databases for additional info if necessary):
SELECT
"AM-Martin".dbo.CpCore_Site.Number,"AM-Martin".dbo.CpCore_Site.Latitude,"AM-Martin".dbo.CpCore_Site.Longitude,"AM-Martin".dbo.CpSm_Face.RetiredOn,**CAST("AM-Martin_bin".dbo.CpCore_Image.Bytes as Varbinary)**, "AM-Martin".dbo.CpCore_Site.Name, "AM-Martin".dbo.CpCore_Site.Zipcode
FROM
"AM-Martin".dbo.CpCore_Site
INNER JOIN "AM-Martin".dbo.CpSm_Face on "AM-Martin".dbo.CpSm_Face.SiteId = "AM-Martin".dbo.CpCore_Site.Oid
INNER JOIN "AM-Martin_bin".dbo.CpCore_Image on "AM-Martin".dbo.CpSm_Face.Oid = "AM-Martin_bin".dbo.CpCore_Image.OwnerId
WHERE
"AM-Martin".dbo.CpSm_Face.RetiredOn LIKE '%9999%'
AND "AM-Martin".dbo.CpCore_Site.Number LIKE N'%LA%' OR "AM-Martin".dbo.CpCore_Site.Number LIKE N'%LC%' OR "AM-Martin".dbo.CpCore_Site.Number LIKE N'%BH%'
AND "AM-Martin".dbo.CpCore_Site.Latitude > 0.0
GROUP BY "AM-Martin".dbo.CpCore_Site.Number,"AM-Martin".dbo.CpCore_Site.Latitude,"AM-Martin".dbo.CpCore_Site.Longitude,"AM-Martin".dbo.CpSm_Face.RetiredOn,**CAST("AM-Martin_bin".dbo.CpCore_Image.Bytes as Varbinary)**, "AM-Martin".dbo.CpCore_Site.Name, "AM-Martin".dbo.CpCore_Site.Zipcode;
This query allowed me to use Group By on the images column. Afterwards I took the data and put it into SQL Statements and imported them into my Postgres SQL DB. When I click on an image value I am unable to open it the message I get in my program (RazorSQL) is:
Unable to display image
I also checked in the SQL Database Table directly where I ran the query and I am unable to open the images. I suspect it has to do with this line:
**CAST("AM-Martin_bin".dbo.CpCore_Image.Bytes as Varbinary)**
Now the issue is the image values are encoded and I do not know how to decode them when I transfer them over like the SQL statement below:
CREATE TABLE "map" (
number varchar(32) NOT NULL,
latitude float NOT NULL,
longitude float NOT NULL,
retiredon timestamp NOT NULL,
image bytea NOT NULL,
name varchar(256) NOT NULL,
zipcode varchar(11) NOT NULL
);
INSERT INTO map("number", "latitude", "longitude", "retiredon", "image", "name", "zipcode") VALUES ('BH-0001', 34.059858, -118.376056, '9999-12-31 00:00:00.0', decode('FFD8FFE000104A46494600010100000100010000FFDB0043000604050605','hex'), 'NB La Cienega Blvd FS Olympic Blvd NEC', '90035');
I want to render the images on my website but they appear to be encoded. How do I decode them when I bring them over to postgresql from SQL server in the SQL statement?
Update
I tried to render the images in my rails project without the image column everything works smoothly. As soon as I try to render the image data I get the following error message:
Encoding::UndefinedConversionError
Also see
You may want to consider translating your byte to hex before migrating the images into the database as strings and then translating them back to byte form before displaying. See this blog for help in the translations.
Alternatively, you could always try hosting your images on AWS and saving the image url as a string in your database.

iOS: SQLITE INSERT QUERY ERROR

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.

How to insert the result of this code into a existing table in SQL Server 2008 R2?

I have to insert the output of this code into an already existing table. How can I achieve this? I did it, but the output is getting appended to the previous result of the table.
Code:
DECLARE #KPI_BU TABLE (BU NVARCHAR(MAX))
INSERT #KPI_BU
SELECT #BU
Declare #KTV table(Business_Unit nvarchar(max), KPI nvarchar(max),YTD_Plan money, Actual money, Deviation money, Year_Plan money )
DECLARE BU_cursor CURSOR FAST_FORWARD FOR
SELECT BU FROM #KPI_BU
OPEN BU_cursor
FETCH NEXT FROM BU_cursor INTO #BU
WHILE ##FETCH_STATUS = 0
BEGIN
INSERT #KTV(Business_Unit, KPI, YTD_Plan, Actual, Deviation, Year_Plan)
EXEC dbo.SP_KPI_History #FiscalYear, #BU
FETCH NEXT FROM BU_cursor INTO #BU
END
CLOSE BU_cursor
DEALLOCATE BU_cursor
--SELECT * FROM #KTV
And if I provide
SELECT *
into KPI_History
FROM #KTV
in place of the commented line it creates a new table and inserts the result into it. I want to insert the RESULT into already existing table.
Update
#Mikael;
I don't know whether i was able to make u understand my question or not. Sorry for that.
What i want is, Now i have two table with this columns:
KPI_History with(Businessunit,KPI_Name,YTD,Actual,Deviation,..)
KPI_codes with (KPI_Name, KPI_code)
In KPI_history table i want to use the KPI_Code of KPI_Codes table instead of KPI_name of KPI_History table. As KPI_Names are too long strings and i have created short codes for the KPI_Names and valued them into KPI_Code. i.e. KPI_code table consist of the KPI names and the codes for the KPI_Names.
So output should be:
KPI_Table with (Businessunit,KPI_Name[It sholud contain codes from KPI_History table],YTD,etc.)
Hope i was able to make you guys understand what i am asking for. :|
I want to insert the RESULT into already existing table.
Here is how you insert into an existing table:
insert into KPI_History (Business_Unit, KPI, YTD_Plan, Actual, Deviation, Year_Plan)
select Business_Unit, KPI, YTD_Plan, Actual, Deviation, Year_Plan
from #KTV;
but the output is getting appended to the previous result of the
table.
So you don't want the result to be added to KPI_History? Then I guess you just have to delete the rows in KPI_History before inserting.
delete from KPI_History;
insert into KPI_History (Business_Unit, KPI, YTD_Plan, Actual, Deviation, Year_Plan)
select Business_Unit, KPI, YTD_Plan, Actual, Deviation, Year_Plan
from #KTV;
Update:
If you need information from another table in the insert you can just join to that table.
Something like this might work for you.
insert into KPI_History
(Business_Unit,
KPI,
YTD_Plan,
Actual,
Deviation,
Year_Plan,
Code)
select K.Business_Unit,
K.KPI,
K.YTD_Plan,
K.Actual,
K.Deviation,
K.Year_Plan,
C.Code
from #KTV as K
inner join KPI_Code as C
on K.KPI = C.KPI;

Firebird Insert Distinct Data Using ZeosLib and Delphi

I'm using Zeos 7, and Delphi 2009 and want to check to see if a value is already in the database under a specific field before I post the data to the database.
Example: Field Keyword
Values of Cheese, Mouse, Trap
tblkeywordKEYWORD.Value = Cheese
What is wrong with the following? And is there a better way?
zQueryKeyword.SQL.Add('IF NOT EXISTS(Select KEYWORD from KEYWORDLIST ='''+
tblkeywordKEYWORD.Value+''')INSERT into KEYWORDLIST(KEYWORD) VALUES ('''+
tblkeywordKEYWORD.Value+'''))');
zQueryKeyword.ExecSql;
I tried using the unique constraint in IBExpert, but it gives the following error:
Invalid insert or update value(s): object columns are
constrained - no 2 table rows can have duplicate column values.
attempt to store duplicate value (visible to active transactions) in unique index "UNQ1_KEYWORDLIST".
Consider to use UPDATE OR INSERT or MERGE statements:
update or insert into KEYWORDLIST (KEYWORD) values(:KEYWORD) matching(KEYWORD)
For details check the following documents in your Firebird installation folder:
doc\sql.extensions\README.update_or_insert.txt
doc\sql.extensions\README.merge.txt

Resources