Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Multiple Rows SQL Teradata

I am creating a volatile table and trying to insert rows to the table. I can upload one row like below...


create volatile table Example
(
    ProductID VARCHAR(15),
    Price DECIMAL (15,2)
)
on commit preserve rows;
et;

INSERT INTO Example
Values
('Steve',4);

However, when I try to upload multiple I get the error:

"Syntax error: expected something between ')' and ','."

INSERT INTO Example
Values
('Steve',4),
('James',8);
like image 868
Bocean Avatar asked Sep 23 '16 19:09

Bocean


1 Answers

As Gordon said, Teradata doesn't support VALUES with multiple rows (and the UNION ALL will fail because of the missing FROM.

You can utilize a Multi Statement Request (MSR) instead:

INSERT INTO Example Values('Steve',4)
;INSERT INTO Example Values('James',8)
;

If it's a BTEQ job the Inserts are submitted as one block after the final semicolon (when there's a new command starting on the same line it's part of the MSR). In SQL Assistant or Studio you must submit it using F9 instead of F5.

like image 80
dnoeth Avatar answered Sep 20 '22 13:09

dnoeth