In: Computer Science
7. Use the substitution & method of INSERT command to populate EMP_PROJ table. INSERT INTO EMP_PROJ VALUES (‘&empNo’, ‘&projNo’, &hoursWorked); NOTE: enclose &empNo in ‘ ‘ if the datatype is a string – VARCHAR2 or CHAR If empNo is NUMBER datatype then do not enclose &empNo in ‘ ‘!
empNo |
projNo |
hoursWorked |
1000 |
30 |
32.5 |
1000 |
50 |
7.5 |
2002 |
10 |
40.0 |
1444 |
20 |
20.0 |
1760 |
10 |
5.0 |
1760 |
20 |
10.0 |
1740 |
50 |
15.0 |
2060 |
40 |
12.0 |
I have created an empty table of emp_proj assuming that the
empNo is number(10)
projNo is number and hoursWorked number.
For creating a table I have used the below command
create table EMP_PROJ (empNo number(10), projNo number(10),
hoursWorked number(10,1));
Command to insert data into EMP_PROJ table using the substitution
method
insert into EMP_PROJ values
(&empNo,&projNo,&hoursWorked);
Execute this command as many times the number of rows to be inserted. Each time it prompts us to enter the three columns, enter the data respectively
To view the data in EMP_PROJ table.
If empNo is taken as varchar then create table command would
be
create table EMP_PROJ (empNo varchar2(10), projNo
number(10), hoursWorked number(10,1));
Command to insert data into EMP_PROJ table using the
substitution method :
insert into EMP_PROJ values
('&empNo',&projNo,&hoursWorked);
Execute this command as many times the number of rows to be inserted. Each time it prompts us to enter the three columns, enter the data respectively.
Note that we have given quotes for the empNo while inserting as the data type is varchar.