HP Neoview SQL Reference Manual page 147

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

--- 1 row(s) inserted.
Unlike the previous example, the insert source of this statement does not contain a value
for the CREDIT column, which has a default value. As a result, this INSERT must include
the column name list.
This SELECT statement shows the default value 'C1' for CREDIT:
SELECT * FROM sales.customer
WHERE custnum = 1120;
CUSTNUM
CUSTNAME
-------
--------------
1120
EXPERT MAILERS
--- 1 row(s) selected.
Insert multiple rows into the JOB table by using only one INSERT statement:
INSERT INTO persnl.job
VALUES (100,'MANAGER'),
(200,'PRODUCTION SUPV'),
(250,'ASSEMBLER'),
(300,'SALESREP'),
(400,'SYSTEM ANALYST'),
(420,'ENGINEER'),
(450,'PROGRAMMER'),
(500,'ACCOUNTANT'),
(600,'ADMINISTRATOR'),
(900,'SECRETARY');
--- 10 row(s) inserted.
The PROJECT table consists of five columns using the data types numeric, varchar, date,
timestamp, and interval. Insert values by using these types:
INSERT INTO persnl.project
VALUES (1000, 'SALT LAKE CITY', DATE '2007-10-02',
TIMESTAMP '2007-12-21 08:15:00.00', INTERVAL '30' DAY);
--- 1 row(s) inserted.
Suppose that CUSTLIST is a view of all columns of the CUSTOMER table except the credit
rating. Insert information from the SUPPLIER table into the CUSTOMER table through the
CUSTLIST view, and then update the credit rating:
INSERT INTO sales.custlist
(SELECT * FROM invent.supplier
WHERE suppnum = 10);
UPDATE sales.customer
SET credit = 'A4'
WHERE custnum = 10;
You could use this sequence in the following situation. Suppose that one of your suppliers
has become a customer. If you use the same number for both the customer and supplier
numbers, you can select the information from the SUPPLIER table for the new customer
and insert it into the CUSTOMER table through the CUSTLIST view (as shown in the
example).
This operation works because the columns of the SUPPLIER table contain values that
correspond to the columns of the CUSTLIST view. Further, the credit rating column in the
CUSTOMER table is specified with a default value. If you want a credit rating that is different
from the default, you must update this column in the row of new customer data.
STREET
------------------
5769 N. 25TH PL
POSTCODE
CREDIT
--------
------
85016
C1
INSERT Statement
147

Advertisement

Table of Contents
loading

Table of Contents