我正在使用oracle 11g并使用sqldeveloper来运行/编辑查询。
我的表是:
ID FIRST_NAME LAST_NAME MAJOR CURRENT_CREDITS
10008 A Dd Computer Science 2
10009 B DD History 3
10010 D dd Computer Science 3
10011 C ad Economics 3
10012 D Da History 3
10013 E df History 3
上表是CSV格式(lect.csv),存储在'D:\ 1Deepak \ Data'..
我创建了以下过程来导入oracle中的csv文件,但它无法正常 :
连接数据库r。
ORA-29280:目录路径无效
ORA-06512:at" SYSTEM.LOADLECTURER",第39行
ORA-06512:第2行
流程退出。
断开与数据库的连接r。
代码:
create user D identified by d
CREATE DIRECTORY log_dir AS 'D:\1Deepak\Data';
Grant all privileges to D;
Grant Read, Write on Directory log_dir to D;
CREATE TABLE lecturer (
id NUMBER(5) PRIMARY KEY,
first_name VARCHAR2(20),
last_name VARCHAR2(20),
major VARCHAR2(30),
current_credits NUMBER(3)
);
CREATE OR REPLACE PROCEDURE Loadlecturer
AS
p_TotalInserted number;
v_FileHandle UTL_FILE.FILE_TYPE;
v_NewLine VARCHAR2(100); -- Input line
myFirstName lecturer.first_name%TYPE;
v_LastName lecturer.last_name%TYPE;
v_Major lecturer.major%TYPE;
v_FirstComma NUMBER;
v_SecondComma NUMBER;
BEGIN
v_FileHandle := UTL_FILE.FOPEN ('Log_dir','Lect.csv', 'r');
p_TotalInserted := 0;
LOOP
BEGIN
UTL_FILE.GET_LINE(v_FileHandle, v_NewLine);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
v_FirstComma := INSTR(v_NewLine, ',', 1, 1);
v_SecondComma := INSTR(v_NewLine, ',', 1, 2);
myFirstName := SUBSTR(v_NewLine, 1, v_FirstComma - 1);
v_LastName := SUBSTR(v_NewLine, v_FirstComma + 1,
v_SecondComma - v_FirstComma - 1);
v_Major := SUBSTR(v_NewLine, v_SecondComma + 1);
INSERT INTO lecturer (ID, first_name, last_name, major) VALUES (1, myFirstName, v_LastName, v_Major);
p_TotalInserted := p_TotalInserted + 1;
dbms_output.put_line(p_totalinserted);
END LOOP;
UTL_FILE.FCLOSE(v_FileHandle);
Exception
WHEN OTHERS THEN
UTL_FILE.FCLOSE(v_FileHandle);
RAISE;
END Loadlecturer;
任何人都可以帮我弄清楚为什么会出现上述错误吗?