怎样在Oracle中,用PlSql往数据库中插入二进制文件.
或者有什么替代解决方案.
请大虾指教!谢谢!
或者有什么替代解决方案.
请大虾指教!谢谢!
解决方案 »
- 求会oracle和mysql的大虾,把oracle语句转换成mysql语句,急急急
- 多表插入
- 安装Oracle遇到的问题
- 一个解析字符串的问题 找出0100100101中最长的111
- oracle developer 的FORM WHEN-BUTTON-PRESSED TRIGGER 中自动执行的创建VIEW的PL/SQL语句如何写?
- VB中的SELECT语句访问ORACLE数据库会占用回滚段吗?
- 兄弟我骨折修养中,散点分希望快快回复
- 紧急求助
- 求一个触发器!
- 在Oracle中可不可以找到一个表最近修改的相关信息
- 高手请进 存储过程返回结果集问题
- 利用migration workbench 移植sql server 2000 数据库到oracle 数据库时提示出问题(数据大小超出此类型的最大值)
REM Version 1.0, last updated 7/13/97
REM This procedure uses UTL_FILE to print student transcripts, as described in
REM Chapter 18 of _Oracle8 PL/SQL Programming_ by Scott Urman.CREATE OR REPLACE PROCEDURE PrintTranscript (
/* Outputs a transcript for the indicated student. The
transcript will consist of the classes for which the
student is currently registered and the grade received
for each class. At the end of the transcript, the student's
GPA is output. */
p_StudentID IN students.ID%TYPE,
p_FileDir IN VARCHAR2,
p_FileName IN VARCHAR2) AS v_StudentGPA NUMBER;
v_StudentRecord students%ROWTYPE;
v_FileHandle UTL_FILE.FILE_TYPE;
v_NumCredits NUMBER; CURSOR c_CurrentClasses IS
SELECT *
FROM registered_students
WHERE student_id = p_StudentID;BEGIN
-- Open the output file in append mode.
v_FileHandle := UTL_FILE.FOPEN(p_FileDir, p_FileName, 'w'); SELECT *
INTO v_StudentRecord
FROM students
WHERE ID = p_StudentID; -- Output header information. This consists of the current
-- date and time, and information about this student. UTL_FILE.PUTF(v_FileHandle, 'Student ID: %s\n',
v_StudentRecord.ID);
UTL_FILE.PUTF(v_FileHandle, 'Student Name: %s %s\n',
v_StudentRecord.first_name, v_StudentRecord.last_name);
UTL_FILE.PUTF(v_FileHandle, 'Major: %s\n',
v_StudentRecord.major);
UTL_FILE.PUTF(v_FileHandle, 'Transcript Printed on: %s\n\n\n',
TO_CHAR(SYSDATE, 'Mon DD,YYYY HH24:MI:SS')); UTL_FILE.PUT_LINE(v_FileHandle, 'Class Credits Grade');
UTL_FILE.PUT_LINE(v_FileHandle, '------- ------- -----');
FOR v_ClassesRecord in c_CurrentClasses LOOP
-- Determine the number of credits for this class.
SELECT num_credits
INTO v_NumCredits
FROM classes
WHERE course = v_ClassesRecord.course
AND department = v_ClassesRecord.department; -- Output the info for this class.
UTL_FILE.PUTF(v_FileHandle, '%s %s %s\n',
RPAD(v_ClassesRecord.department || ' ' ||
v_ClassesRecord.course, 7),
LPAD(v_NumCredits, 7),
LPAD(v_ClassesRecord.grade, 5));
END LOOP; -- Determine the GPA.
CalculateGPA(p_StudentID, v_StudentGPA); -- Output the GPA.
UTL_FILE.PUTF(v_FileHandle, '\n\nCurrent GPA: %s\n',
TO_CHAR(v_StudentGPA, '9.99')); -- Close the file.
UTL_FILE.FCLOSE(v_FileHandle);EXCEPTION
-- Handle the UTL_FILE exceptions meaningfully, and make sure
-- that the file is properly closed.
WHEN UTL_FILE.INVALID_OPERATION THEN
UTL_FILE.FCLOSE(v_FileHandle);
RAISE_APPLICATION_ERROR(-20061,
'PrintTranscript: Invalid Operation');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
UTL_FILE.FCLOSE(v_FileHandle);
RAISE_APPLICATION_ERROR(-20062,
'PrintTranscript: Invalid File Handle');
WHEN UTL_FILE.WRITE_ERROR THEN
UTL_FILE.FCLOSE(v_FileHandle);
RAISE_APPLICATION_ERROR(-20063,
'PrintTranscript: Write Error');
WHEN OTHERS THEN
UTL_FILE.FCLOSE(v_FileHandle);
RAISE;
END PrintTranscript;
/
Procedure write_info (
who in varchar2,
description in varchar2,
file in varchar2 ) ;
procedure download(file_name in varchar2);
procedure html;
End;
/
show errors;Create Or Replace Package body updown as Procedure write_info (
who in varchar2,
description in varchar2,
file in varchar2 ) as
begin
htp.htmlopen;
htp.headopen;
htp.title('File Uploaded');
htp.headclose;
htp.bodyopen;
htp.header(1,'Upload Status');
htp.print('Uploaded ' || file ||' successfully');
commit; htp.bodyclose;
htp.htmlclose;
commit;
end ;
procedure download(file_name in varchar2) is
content_type varchar2(50) default null;
begin
htp.p('<html>');
htp.p('<head>'); select mime_type into content_type from doccontent where name=file_name; htp.p('</head>');
htp.p('<body>'); wpg_docload.download_file(file_name);
htp.p('</body>');
htp.p('</html>'); end download;
procedure html is
begin
htp.p(' <html>
<head>
<title>test upload</title>
</head>
<body>
<FORM enctype="multipart/form-data" action="updown.write_info" method="POST">
<p>Author’s Name:<INPUT type="text" name="who">
<p>Description:<INPUT type="text" name="description"><br>
<p>File to upload:<INPUT type="file" name="file"><br>
<p><INPUT type="submit">
</FORM>
</body>
</html> ');
end ;
end ;
/
show errors;