I have a table TABLE1 with columns R_ROW_ID, NAME, MARKS, TIME, NUMBER,LAST_UPD_TIME,USER_ID... All column values are not null.
TABLE1 has unique index on column R_ROW_ID.
I have a file which has only NAME, MARKS data and load this data into TABLE1 using SQL Loader.
File1.txt has below data:
JOHN|83
DON|54
LONIS|91
How to populate ROLLNO with unique value , NUMBER with default value 0 and LAST_UPD_TIME with current timestamp
This file loading is one time and I have created a sequencer SEQ as mentioned below:
CREATE SEQUENCE SEQ START WITH 90000 INCREMENT BY 1;
Grant on this sequencer SEQ is:
GRANT SELECT ON SEQ TO LOAD_USER;
This is the control file code I have written:
LOAD DATA APPEND
INTO TABLE TABLE1 FIELDS TERMINATED BY "|"
TRAILING NULLCOLS
(
R_ROW_ID "SEQ.NEXTVAL",
NAME CHAR "NVL(TRIM(:NAME),' ')",
MARKS CHAR "NVL(TRIM(:MARKS),' ')",
TIME CHAR "NVL(TRIM(:TIME),' ')",
NUMBER CONSTANT "0",
LAST_UPD_TIME EXPRESSION "CURRENT_TIMESTAMP(3)",
USER_ID CHAR "NVL(TRIM(:USER_ID),' ')"
)
This is the error it is showing :
SQL*Loader-951: Error calling once/load initialization
ORA-02373: Error parsing insert statement for table TABLE1.
ORA-02289: sequence does not exist
Let me know is there anything wrong in above one.
Is there any other way we can populate R_ROW_ID value (which should be unique) apart from using sequences ?
Well, who knows what's wrong if you aren't telling the truth.
You want to set
ROLLNOto something, but that column doesn't exist in column list you specified in the 1st sentence.Then, you want to set column named
NUMBERto something else; you probably don't, becausenumbercan't be column's name as it is keyword, reserved for datatype (true, there can be exceptions, but I doubt this is the issue here)Why did you create sequence in one schema (we don't know which one) and granted it to another user? Why don't you do everything in the same schema? Or did you just get a wrong idea that you should grant privilege on sequence you created to yourself?
Here's an example; see if it helps. Everything is being done in the same schema.
Control file:
Loading session:
Result:
If you really are loading data using another user, then - in my example - "this" user is
scottand he grantsselectonseqsequence tomike. Mike is doing the rest:Control file; note modification for
r_row_id(uppercase owner name!):Loading session:
Result:
Alternatively, you could create a synonym for owner's sequence (still connected as
mike):Then you don't have to modify the 1st control file I posted at all, and loading does the job: