File UPLOAD PLSQL procedure
Hello,
I'd like to write a PLSQL stored procedure to upload file. Where I can find documentation or a sample code ?
Thanks in advance.
Alessandro
I'd like to understand where is the "program" that reads the file coming from the client and put it in the blob field in the document table. I wrote this kind of program using PERL and CGI.pm and I want understand if it's possibile using PLSQL. I'd like to write a procedure that put the file upload directly on the file system on the server without passing trough a blob in a DB table.
thanks in advance
Alessandro
null
Similar Messages
-
Calling Batch files in PLSQL Procedure
Hi all,
I am working on a PLSQL procedure and having issues when I am trying to call a batch file.
Issue:-
I have a procedure which have to kick off a batch file. And that batch file needs to run in Windows not in Unix box.
Can someone please help me out in providing some samples or anything?
Thanks a lot in advance.Thank you rp0428 and sb92075,
I have tried to create a sample of what I am trying to get and so I have created the following code in a batch file and named as Check.bat:-
@set a=3
@set b=4
@set /a c=%a%+%b%
echo %c%
So based on those links you guys provided I have created an
Scheduler Job:-
BEGIN
DBMS_SCHEDULER.create_job (job_name => 'MYJOB1',
job_type => 'EXECUTABLE', JOB_ACTION => 'c:\Check.bat', enabled => TRUE,comments => 'runs Check.bat' );
END;
And the following Procedure :-
CREATE OR REPLACE PROCEDURE execute_bat_file
IS
BEGIN
DBMS_SCHEDULER.RUN_JOB ('MYJOB1', TRUE);
END execute_bat_file;
And used the following exec command:-
exec execute_bat_file;
I am getting the following error:-
Error starting at line 1 in command:
exec execute_bat_file
Error report:
ORA-27475: "ACTUATE.MYJOB1" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at "ACTUATE.EXECUTE_BAT_FILE", line 4
ORA-06512: at line 1
27475. 00000 - "\"%s.%s\" must be a %s"
*Cause: An object of the wrong type was specified. For example, a table
could have been passed to the drop_job() procedure.
*Action: Reissue a different command applicable to this object type or
reissue the same command using an object of the valid type.
Can you guys please help with this?
Thank you once again -
Email text files through plsql procedures
Hi,
I have written a procedure that selects table data and writes a .txt file in delimitted format. After the file is created on the C drive of the server I want to attach the file in a email and send it to the recepients.
I have used the built in package and can send emails...but it goes with out the attachment...
Can anyone tell me how can i attach the .txt file in the plsql procedure that sends the email.??user8958533 wrote:
Hi,
I have written a procedure that selects table data and writes a .txt file in delimitted format. After the file is created on the C drive of the server I want to attach the file in a email and send it to the recepients. Don't - why write data externally and then have to read that data again to use it internally?
An attachment in an e-mail is not a separate file - the file contents is part and parcel of the e-mail message body. It is a single block of data. There is no requirement for the so-call attachment to be a physical file at all. All that is needed is correctly formatting the main body (as per MIME specs).
So rather write data to a CLOB and when done, create the e-mail body and append the CLOB contents to the e-mail.
This topic has been discussed numerous times. See {message:id=3963129} and {message:id=3913513} for starters.. and consider using the search function before asking a question. -
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]I also Tried to Use This
But How can i Use SQLLDR Command In Stored Procedure.
Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure. -
File Uploads using stored procedures
Hello, I'm quite new here, but I have a question that I've been butting my head against for the past day. Here goes.
We need to upload a file using a stored procedure (PL/SQL procedure.)
The two things I have found that work are
1) Having oracle do the file handling (using bfiles) in the procedure
2) using an insert statement directly to upload the file contents into a blob.
The platform is php (Oracle instant client) and I will show some code examples.
1) is unworkable because Oracle will not have direct access to any files.
2) is fine, but we would prefer to use a procedure so as to abstract what exactly goes on and possibly other operations away from the php and the framework.
What worked:
1)
CREATE OR REPLACE PROCEDURE php_upload_file (file_name in varchar2, canonical_name in varchar2, owner in number, file_id IN OUT number)
AS
src_loc bfile:= bfilename('DOC_LOC',php_upload_file.file_name);
dest_loc BLOB;
begin
insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
into dest_loc, file_id;
dbms_lob.open(src_loc,DBMS_LOB.LOB_READONLY);
DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.LOADFROMFILE(
dest_lob => dest_loc
,src_lob => src_loc
,amount => DBMS_LOB.getLength(src_loc));
DBMS_LOB.CLOSE(dest_loc);
DBMS_LOB.CLOSE(src_loc);
COMMIT;
end;
'DOC_LOC' is a directory I've set up that the user has access to.
Interfacing with PHP this just looks like
oci_parse($conn,"BEGIN php_upload_file('{$uploadfilename}','{$propername}',{$ownerid},:file_id); END;");
Dead simple, right?
I also do a bind command to pull out 'file_id' so I know the id that was just inserted.
The other solution is
$contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
$lob = oci_new_descriptor($conn, OCI_D_LOB);
$stmt = oci_parse($conn,
"INSERT INTO files (employee_id, filename, data, file_id) VALUES(175,'"
.$_FILES["uploadedfile"]["name"].
"', empty_blob(), files_seq.nextval) RETURNING file_id, files.data INTO :file_id, :src_contents");
where :src_contents is binded to a lob and :file_id as before is binded to an INT:
oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
oci_execute($stmt,OCI_DEFAULT);
In this case the last thing I do before the commit is
$lob->save($contents);
Both work fine, but what I need is this
$contents = file_get_contents($_FILES["uploadedfile"]["tmp_name"]);
$lob = oci_new_descriptor($conn, OCI_D_LOB);
$stmt = oci_parse($conn,"BEGIN do_upload_file(:src_contents,'{$propername}',{$ownerid},:file_id); END;");
oci_bind_by_name($stmt, ':src_contents', $lob, -1, OCI_B_BLOB);
oci_bind_by_name($stmt, ':file_id', $insert_id, -1, SQLT_INT);
oci_execute($stmt,OCI_DEFAULT);
$lob->save($contents);
oci_commit($conn);
this omits error conditions (such as on $lob->save ... etc.) it is simplified.
The content of the procedure I changed as follows, but it seems untestable.
CREATE OR REPLACE PROCEDURE do_upload_file (src_contents IN OUT blob, canonical_name in varchar2, owner in number, file_id IN OUT number)
AS
dest_loc BLOB;
begin
insert into files values(owner,canonical_name,empty_blob(),files_seq.nextval) returning files.data, files.file_id
into dest_loc, file_id;
dbms_lob.open(src_contents,DBMS_LOB.LOB_READONLY);
DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.COPY(dest_lob => dest_loc,
src_lob => src_contents
,amount => DBMS_LOB.getLength(src_contents));
DBMS_LOB.CLOSE(dest_loc);
DBMS_LOB.CLOSE(src_contents);
COMMIT;
end;
I don't get errors because I cannot figure out a way to run this procedure in my PL/SQL environment with valid data. (I can run it with a blank blob.)
But when I work out the order of what's going on, it doesn't make sense; the commit in the procedure is before the $lob->save(...) and thus it would never save the data... nonetheless it should at least create a record with an empty blob but it does not. What is wrong is beyond the error level that seems to be supported by PHP's oci_error function (unless I have not discovered how to turn all errors on?)
In any case I think the logic is wrong here, but I'm not experienced enough to figure out how.
To test it I would need to create a driver that loads an external file into a blob, and passes that blob into the procedure. Trouble is, even if I make a blob and initialize it with empty_blob() it treats it as an invalid blob for the purposes of the dbms_lob.copy procedure.
If someone has solved this problem, please let me know. I would love to be able to do the file upload with just a single procedure.Thanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
The actual file size: 945,991 bytes
If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree? -
Would like to create a file upload facility in a form based on stored procedure
Hello,
I would like to create a 'File Upload' in a 'form based on stored procedure'. The version of portal that I am running is 3.0.7.6.2. In this version, only 'form based on table' has the ability to upload files. Or is it that I am missing something?
Please let me know if this is possible in higher versions of portal.
Thank you for your help.
JayasreeI have kin od fdone this by using the additem fucntion, if you look at the HTML of the add file page, you can see the parameter that are required for the form.
-
How to upload and download any file from plsql through weblogic server
hi all,
how to upload and download any file from plsql through weblogic server? i am using oracle 10g express edition and jboss.
Thanks and Regards,
MSORAhi bala ,
for a windown server u can use VNC (virtual network connection) which opens a session on u r desktop later u can drag and drop form there vice versa and for a linux box you can use Win SCP which helps to open a session with interface to u r desktop in both cases you can upload and down load files very easiy just as we drag and drop items in a simple pc .. we use the same technique...
bye
vamshi -
File upload use pl/sql with OAS 4082 and 8i/EE
is there any way to upload/download files (any format) from web browser use FORM and above env. Don't mention samples in OAS document, it simply doesn't work. thanks.
806675 wrote:
I probably wrong but I interpret this as POST is not supported, http://download.oracle.com/docs/cd/E11882_01/appdev.112/e16659/xdb22pro.htm#ADXDB5550, "Supported HTTP(S) Client Methods"
It says:
"+The semantics of these HTTP(S) methods is in accordance with WebDAV. Servlets and *Web services may support additional HTTP(S) methods*, such as POST.+" (my emphasis - so yes, it is supported).
Today we are using an Appserver with HTTP mod_plsql, the code for the form looks like:
htp.formopen (
curl => 'FileUpload',
cmethod => 'POST',
cenctype => 'multipart/form-data');
the "FileUpload" takes care of the file and inserts it in the dbThe question is how does it do it? A file upload via mod_plsql/EPG is done via the PLSQL document table. It, mod_plsql/EPG, takes cares of the actual upload part - reading the Mime stream of the upload from the browser and inserting it into the document table.
Unfortunately, seems that the 11g documentation lacks details in this regard. Please consult the Oracle® HTTP Server mod_plsql User's Guide (10g).
<li>section 1.7.1 describes the format of the upload table you need to define
<li>section 1.7.4 shows a sample HTML form doing a HTTP post, and the post-process upload PL/SQL procedure that needs to be written to process the contents of the row just created for the uploaded file in the document table -
How Can i get PLSQL Procedure out values in Shell Script?
Hi,
I need to use PLSQL Procedure out values in shell script by using that parameter i need to check and call the other procedure. Please can you guide me how can i?
#!/bin/ksh
# Function to call validation program
SQL_PKG_CALL()
echo "Inside SQL_PKG_CALL for $file"
sqlplus -s /nolog << EOF
whenever sqlerror exit failure
connect ${APPS_LOGIN}
variable exit_value NUMBER
set serveroutput on size 100000
DECLARE
l_errbuf VARCHAR2(10000) := NULL; l_retcode NUMBER := NULL;lv_test VARCHAR2(4000) := NULL;
BEGIN
fnd_global.apps_initialize ( USER_ID => ${USER_ID}, RESP_ID => ${RESP_ID}, RESP_APPL_ID => ${RESP_APPL_ID}
, SECURITY_GROUP_ID => ${SECURITY_GROUP_ID}
#Calling PLSQL procedure for create and attache document
XXAFPEEP_SO_DOC_ATTACH_INT.DOCUMENT_ATTACH (p_errbuf => l_errbuf, p_retcode => :RETMSG, p_fileName => $file
, p_debug => 'Y', p_rettest => lv_test);
# to print the procedure return values
DBMS_OUT.PUT_LINE('Return Message: '|| lv_test);
#${RETCODE}=l_retcode;
print :RETMSG;
END;
EXIT 0
EOF
# Program starts here
echo "+---------------------------------------------------------------------------+"
echo "Program Start"
APPS_LOGIN=${1} # Apps Login
USER_ID=${2} # User ID
RESP_ID=${5} # Responsiblity ID
RESP_APPL_ID=${6} # Responsiblity Application ID
SECURITY_GROUP_ID=${7} # Security Group ID
DIRECTORY_PATH=${8} # Directory --Attached file locations
DIRECTORY_NAME=${9} # Directory Name for plsql
echo "User ID : $USER_ID"
echo "Responsibility ID : $RESP_ID"
echo "Responsibilith Application ID : $RESP_APPL_ID"
echo "Security Goup ID : $SECURITY_GROUP_ID"
echo "Directory Path : $DIRECTORY_PATH"
echo "Direcotry Name : $DIRECTORY_NAME"
echo
#files direcotry
cd $DIRECTORY_PATH
echo Present Working Directory: `pwd`
echo
#for all file names
ALL_FILES=`ls *.pdf`
for file in $ALL_FILES
do
if [ -f $file ]
then
#log "Processing $file" # future
echo Processing: $file
# Calling the PL/SQL Program
SQL_PKG_CALL;
#echo "Retcode : $RETCODE"
echo "RetMessage : $RETMSG"
else
log "Skipped $file: invalid file"
echo "Skipping current file $file: not a valid file."
fi
done
Thanks
SudheerSaubhik's provided the solution, but just for fun:
Test procedure:
create or replace procedure get_ename
( p_empno in emp.empno%type
, p_ename_out out emp.ename%type )
is
begin
select ename into p_ename_out
from emp
where empno = p_empno;
end get_ename;Test data:
SQL> select empno, ename from emp order by 1;
EMPNO ENAME
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
14 rows selectedTest call from SQL*Plus to show it working:
SQL> declare
2 v_ename emp.ename%type;
3 begin
4 get_ename(7844,v_ename);
5 dbms_output.put_line(v_ename);
6 end;
7 /
TURNER
PL/SQL procedure successfully completed.Demo shellscript (borrowing the function idea from Saubhik):
#!/bin/ksh
empno=${1:-NULL}
exec_sql() {
sqlplus -s william/w@//vm.starbase.local:1521/eleven <<END_SQL
spool get_out_value.sh.log
set serverout on size 2000 feedback off
declare
v_name emp.ename%type;
begin
get_ename(${empno},v_name);
dbms_output.put_line('# ' || v_name);
end;
spool off
exit
END_SQL
ename=$(exec_sql ${empno} | awk '/^# / {print $2}')
print Employee ${empno} = ${ename}Demo:
/Users/williamr: get_out_value.sh 7844
Employee 7844 = TURNER
/Users/williamr: get_out_value.sh
Employee NULL =Note this substitutes the word NULL if no empno is passed, and it ignores error output or anything else by only looking for lines beginning '# ' and then taking the following word. Error messages will appear in the logfile. (In this example it probably doesn't need the NULL substitution because a missing parameter would cause a syntax error which the script will handle anyway, but it could be useful in more complex examples.)
For a production script you should probably use an OS authenticated account so you don't have to deal with password strings. -
File Upload / Download - Advice Required
Hi all,
This is really just a general question, looking for advice.
I have downloaded and successfully used the File Upload PJC for Forms 6i - thanks Oracle.
We are looking to use this to download and upload files from or to the client machine, and I am (relatively) confident of reversing the Java components to allow this to happen.
However, we are actually looking to transfer the files from the client machine, to the 9iAS Tier and then to the UNIX (AIX) tier where the database (8.1.7.4) resides - and vice versa.
I have considered a couple of different approaches :
1. Run the Java Server component in the Database JVM to enable the writing/reading of files on the UNIX filesystem.
2. Use TEXT_IO on the 9iAS tier, and UTL_FILE on the Database Tier, to move files between the two tiers.
3. Write the files to / from the Database, and then from/to there into the UNIX filesystem.
Does anyone have any expereince of attempting to implement a similar solution, or information on Oracle documentation explaining any of the above.
Plus, I'm sure I must be missing a trick !
Any other ideas ??
Regards
Marc LudwigWe have build a similar solution,
for the download:
we use the pl/sql gateway to send the file to the client with the following function:
wpg_docload.download_File(lob_loc);
you could build a pl/sql procedure that accepts an id and selects the blob locater and
triggers this function. the procedure can be called by setting the configuration in your DAD correctly.
that way its easier then rebuilding the whole fileupload utility.
in the webforms you can have a code that opens a new window with an url you give.
the url will point to the pl/sql function and you can pass the id of the record you want to get the blob from.
for the upload to your database:
well, we chose to loose the zip functionality and modify the pl/sql library that comes with it.
instead of using the uploadserver class, you could build a pl/sql function in the database that
accepts the varchar32 strings (which are base64encoded chunks of your file) and appends them to a blob.
the function that could do that would look like:
PROCEDURE APPEND_DATA(P_ID IN NUMBER, P_DATA IN VARCHAR2) IS
bin_data blob;
append_data blob;
raw_data raw(16384);
BEGIN
dbms_lob.CREATETEMPORARY(append_data,true);
dbms_lob.OPEN(append_data,DBMS_LOB.LOB_READWRITE);
select binary_data into bin_data from ibs_physical_doc where id=P_ID for update;
raw_data:= utl_encode.BASE64_DECODE(utl_raw.CAST_TO_RAW(p_data));
dbms_lob.write(append_data, utl_raw.LENGTH(raw_data),1,raw_data);
dbms_lob.APPEND(bin_data,append_data);
dbms_lob.CLOSE(append_data);
COMMIT;
END;
you can increase the chunksize a bit more.
you still have a problem btw that you probably cant upload more then 4-8 mb before you get an out of memory error on the client.
you could solve that by rewriting the client java file to send the file piece by piece on request by the server instead of all the pieces after eachother, and first read a piece of the file and then encode that piece and then send it instead of reading the whole file, encoding it and sending the chunks.
Another option is to use the standard upload possibilties with web pl/sql, and open a new browser window to that window from forms. A drawback of that is that it is not integrated in the web forms program and that you cant see when the upload is finished (no callback). and that you are bound to the default table layout.
one final thing, if you are going to use this, you might want to take a look at using JInitiator 1.3.1.9 if you arent using it already this automaticly sets the signature in the clients database if he accepts it. there is a bug in it, look for it somewhere in this forum. if you are using the sample that comes with forms 6i you will have to replace the fileuploadprogressbar with the one that comes with the forms 9i sample and recompile everything and i think you will have to use JDK1.3.1_03 for that. that means that you will have to modify the make batch file. the command for compiling is different, the classpath is an option when you call javac, also you will have to sign it with jarsigner.exe (in the jdk) instead of the one in the example.
Hope this info is helpfull, if you like to have more specific code, mail me at [email protected] -
Calling sql script in plsql procedure
Hello,
I have a sql script named mytest.sql and i want to execute this from a stored procedure.
following is the contents of this script
spool d:\mytestsql.txt
select * from tab;
spool off
Actually i want my sql script to run daily to export some tables data.
I can execute this script from a sql prompt but i want to run it from enterprise manager.
I am using oracle 10gR2 on windows2000 system.
Any idea about scheduling the sql script to run automatically??
How to execute this sql script from a plsql procedure??
ThanksHi all,
Thanks for all the replies. I have found the solution with external procedures.
Following is the complete step by step guide.
1. Create the OSCommand Java Class using the following statement:
connect as any user:
create or replace and compile java source named oscommand as
import java.io.*;
public class OSCommand{
public static String Run(String Command){
try{
Runtime.getRuntime().exec(Command);
return("0");
catch (Exception e){
System.out.println("Error running command: " + Command +
"\n" + e.getMessage());
return(e.getMessage());
2. Create the following Wrapper Function using the following statement:
CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'OSCommand.Run(java.lang.String) return int';
3. connect as sys
Execute dbms_java.grant_permission( 'FKHALID','SYS:java.io.FilePermission', '<<ALL FILES>>','execute');
execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '*' );
execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'readFileDescriptor', '*' );
commit;
note: here fkhalid is the oracle user.
connect as fkhalid user:
Declare
expdp_cmd Varchar2(2000);
Begin
expdp_cmd := OSCommand_Run('cmd /c sqlplus fkhalid@mtcedwt/pwd @d:\ORA_DUMPS\mydbexp.sql');
DBMS_OUTPUT.Put_Line(expdp_cmd);
End;
In Unix
Set Serverout On
Declare
x Varchar2(2000);
Begin
x := OSCommand_Run('/home/test/myoscommand.sh')
DBMS_OUTPUT.Put_Line(x);
End;
I will check the dbms_scheduler also and will let you know the results.
Thanks -
HI Masters , I need information for file upload program in web dynpro java
Hi masters,
i need some inforamtion and documentation on file upload program in web dynpro javaHi surya,
You can follow this procedure to upload the file
i) Take One Context Attribute named as "D1" of Type "binary".
ii) Take one FileUpload UI Element in the Layout Tab.
iii) Bind FileUpload UI Element's data Property to the taken Context Attribute. Here it is "D1".
iv) Take one Button UI Element in the Layout Tab named "Upload" and in the Action of that Button write the following Code.
v) The following code Generates one Folder in the Server & inside that Folder given file is Uploaded.
File ff=new File("FolderXYZ"); // Creates One Folder with the given Name ( Here Folder name is "FolderXYZ")
ff.mkdir();
try
byte b[]=null;
IWDAttributeInfo objAttinfo=null;
IWDModifiableBinaryType binType=null;
File f=null;
FileOutputStream fos=null;
if(wdContext.currentContextElement().getD1()!=null)
b=wdContext.currentContextElement().getD1();
objAttinfo=wdContext.getNodeInfo().getAttribute(IPrivateAttachView.IContextElement.D1);
binType=(IWDModifiableBinaryType)objAttinfo.getModifiableSimpleType();
f=new File(ff.getName()+"
"+binType.getFileName());
fos=new FileOutputStream(f);
fos.write(b);
fos.flush();
fos.close();
objMessageManager.reportSuccess("File uploaded to server");
} catch (Exception e)
objMessageManager.reportException("Unable to upload file to server, error is:"+e,false);
return;
The Uploaded file is stored in the folder & that folder is stored in the Server's following Path.
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0
You can access your Uploaded file from the following Path
<Your Server>\c$\usr\sap\J2E\JC00\j2ee\cluster\server0\FolderXYZ
Regards
Sagar Ingalwar -
HTML File Upload - using DAD - Error
I have set up my document table, the document upload package is in there, but my HTML for the file upload is not working correctly:
DAD info
DAD Name: /pls/portal
Document Table: dw_target.documents
Document Access Procedure: document_api.download
here is the upload HTML:
<html>
<head>
<title>test upload</title>
</head>
<body>
<form enctype="multipart/form-data" action="http://MYURL:7777/portal/pls/portal/dw_target.document_api.download" method="post">
File to upload: <input type="file" name="file"><br>
<input type="submit" value="Upload">
</form>
</body>
</html>
But i get this error when i try to upload a doc:
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
anyone have any insight on how to get the file upload to work (specifically how to configure the HTML to correctly use the upload process?
using Oracle App Server 10g
jasonPschar,
What is "dw_target.documents"?
Joel -
Hi
When using the file upload/download functionality, APEX stores the uploaded object in a table by default. See: http://download-uk.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm#CJAHDJDA
Is there a way to specify that the file should NOT be stored in a table, but rather, be stored on the file system?. Example in a directory object location.
I intend to use the upload/download functionality to load csv files that will then be parsed as external tables.
Thanks
KezieHi,
I modified the above procedure to point to my tables and trying to create the procedure in Apex database and am getting the following error:
Procedure:
CREATE OR REPLACE PROCEDURE write_blob_to_file
( p_docid IN NUMBER,
p_directory IN VARCHAR2,
p_filename IN VARCHAR2 DEFAULT NULL )
IS
l_file utl_file.file_type;
l_buffer RAW(32767);
l_amount BINARY_INTEGER := 32767;
l_position INTEGER := 1;
l_blob BLOB;
l_length INTEGER;
l_filename VARCHAR2(400);
BEGIN
SELECT BLOB_CONTENT, MPP_name
INTO l_blob, l_filename
FROM MPP_FILES
WHERE id = p_docid;
IF p_filename IS NOT NULL THEN
l_filename := p_filename;
END IF;
l_length := dbms_lob.getlength( l_blob );
l_file := utl_file.fopen( p_directory, l_filename, 'wb', 32767 );
WHILE l_position < l_length LOOP
dbms_lob.read( l_blob, l_amount, l_position, l_buffer );
utl_file.put_raw( l_file, l_buffer, TRUE );
l_position := l_position + l_amount;
END LOOP;
utl_file.fclose( l_file );
EXCEPTION
WHEN others THEN
IF utl_file.is_open( l_file ) THEN
utl_file.fclose( l_file );
END IF;
raise_application_error( -20001, SQLERRM );
END write_blob_to_file;
Error:
ERROR at line 6: PLS-00201: identifier 'UTL_FILE' must be declared
4. p_filename IN VARCHAR2 DEFAULT NULL )
5. IS
6. l_file utl_file.file_type;
7. l_buffer RAW(32767);
8. l_amount BINARY_INTEGER := 32767;
Please let me know what am i missing. I am pretty new to PL/SQL and Apex.
Also wondering is there a way to download files from tables using Java Stored Procedure. Please give some pointers.
Ramesh K
Maybe you are looking for
-
How to override AD identity template for resource contained in role?
This is yet another variation on the "I need to compute the container for my AD user, so how do I override the identity template?" I have a relatively elegant hack (detailed below)...but it is a hack and I am worried about unintended consequences. De
-
Problem with exposé and showing desktop
It never happened with Leopard, but since the upgrade, sometimes Exposé has some kind of problem. The problem is that sometimes, if I drag four fingers down to show expose, when I drag four fingers up to go back to its previous state, it doesn't want
-
Animation play wrong in Safari on Win and Mac (with link to project)
Hello all, I really need you solution, and maybe Edge team take a look for my problem Here: http://eliteart.pro/RFGC/presentation.html project (WIP) play well in Mozilla (FF) on Win 7 and Chrome on Win 7, but play wrong on Chrome on Linux, and play w
-
Export meet ora-3113 error!
In my database there are two scheama t1 ,t2. When I use the command 'export' to export the data in 'USER' mode,one of the scheama t1 meet the oracle error ORA-3113,but the other t2 is ok! the error occured when t1's tables are exported and would be e
-
Bug in DLight process selection dialog
When running DLight on a host with a large number of processes, the child "/usr/bin/pargs" process spawned (presumably to collect a set of processes to present for selection) blocks writing to stderr. DLight needs to drain the stderr output stream of