I an trying to INSERT multiple rows into an SQL, Oracle table though SQL Developer v3.0.04
the Database was set-up by Uni so I don’t know what version it is.
after looking on-line I have come up with the code below but it will not INSERT any data. I have tested the insert with just one row and that is OK. What am I missing?
Insert all
Into Patient Values
('101', '1 house', Null, 'Kingston', 'Surrey', 'KT1 1XX', '10/jan/1980', 'm', 01452987456)
Into Patient Values
('102', '2 egg rd', 'vail', 'guildford', 'Surrey', 'GU1 1LL', '05/dec/1985', 'm', 01452987456)
Into Patient Values
('103', '6 station rd', Null, 'guildford', 'Surrey', 'GU1 2XX', '15/may/1990', 'f', 01452987456)
Select * from Patient;
INSERT ALL has two different uses. One is to insert different sub-sets of selected columns into a table. The other is to direct rows into different according to certain criteria. In both cases the data comes from a SELECT clause rather than from VALUES. See the examples in the documentation.
Normally, you would simply write multiple
INSERTstatements potentially in a single PL/SQL block. Something likeIf you really want to do this in a single SQL statement, you can do an
INSERT ... SELECTbut that’s generally going to be more complex than using three separate statements.I would also caution you to use proper data types and to specify the column names in your
INSERTstatement. I’m guessing, for example, that the first column ofPatienttable is some sort ofPatientIDthat is defined as aNUMBER. If so, you’d really want to insert a number rather than a character string. Similarly, the seventh column with values like ’15/may/1990′ is probably defined as aDATEin the table. If so, yourINSERTshould insert aDATEnot a character string by either explicitly callingTO_DATEwith a particular format mask or by using the ANSI date format, i.e.date '1980-01-10'. And if you want the last column to retain the leading 0, you’ll need to ensure that the column in the database is defined as aVARCHAR2and that you insert a character string rather than a number.