I have a table in Oracle that has 6 columns and a comma-delimited text file that has 5 "columns"
I need to put the year in the first column of each row. The year is not in the text file. It will be the same for each row that is appended to the table. This process will run one a year.
An example text file:
2541-1,36,00000,Some Words Here,00000000
1425-4,25,15245,Some Other Words,45786524
6548-8,12,30210,Different Words,885411246
How do I set the first column to the year using SQL*Loader?
The result I want:
| Column A | Column B | Column C | Column D | Column E | Column F |
|---|---|---|---|---|---|
| 2023 | 2541-1 | 36 | 00000 | Some Words Here | 00000000 |
| 2023 | 1425-4 | 25 | 15245 | Some Other Words | 45786524 |
| 2023 | 6548-8 | 12 | 30210 | Different Words | 885411246 |
One option is to "load" a constant.
Table is - initially - empty:
Control file:
Loading session:
Result:
Another option is to set default value for
colaat time of creating that table:Control file: the same as previously, just remove
colaline entirely:Loading session and result:
Yet another option is to insert "calculated" value.
In that case, that calculated column has to be last in control file.
Control file:
Loading session and result: