Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » How to show text/data in Textarea from File without query. (APEX 3.1.2, Oracle database 10g XE)
How to show text/data in Textarea from File without query. [message #380504] Mon, 12 January 2009 02:06 Go to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear experts,

i just want to show text/data in the form "TextArea" field
when i browse and select file and click submit button (not from datbase query)
how can i do this simple thing, can help me please?


Thank you,

Kamal Hossain.

[Updated on: Mon, 12 January 2009 02:08]

Report message to a moderator

Re: How to show text/data in Textarea from File without query. [message #380522 is a reply to message #380504] Mon, 12 January 2009 03:28 Go to previous messageGo to next message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
hi,
hope you have created page variable ie p1_ p followed with page number and your variable name. you shall give default value in it. if you need to store some derived data into this field you shall write pl/sql or before header process. infact it is the simplest thing on creation of page. or I misconstrued your requirement.
yours
dr.s.raghunathan

ps : if your interest on LOV or select list then the process little bit different.

[Updated on: Mon, 12 January 2009 03:30]

Report message to a moderator

Re: How to show text/data in Textarea from File without query. [message #380540 is a reply to message #380504] Mon, 12 January 2009 04:24 Go to previous messageGo to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear Mr. dr.s.raghunathan,

Thank you for your reply and suggestion.
in my form i have 3 variables:

1. P1_MYFILE ( File Browse...)
2. P1_TEXTAREA ( Textarea where i want to show
data from file)
3. P1_SUBMIT ( Button, after pressing it textarea will be
filled by file data).

Can you pls help me giving an example how to write Process under which of the above variable.


i will be highly grateful to you for this.

Thank you.
Kamal Hossain
Re: How to show text/data in Textarea from File without query. [message #380727 is a reply to message #380540] Tue, 13 January 2009 02:53 Go to previous messageGo to next message
dr.s.raghunathan
Messages: 540
Registered: February 2008
Senior Member
Quote:

P1_MYFILE ( File Browse...)


i am little bit confused. what do you mean by file is it a table with data content or the text file created through notepad / wordpad or any html file... what is the storage space of your file. Is it possible to store your content in any table column. or you want to list the files and your package need to select the file and open it and read it and then is it need to be stored in your textarea column. i may not have ready reconer solution still i can try and provide some solution.
yours
dr.s.raghunathan
Re: How to show text/data in Textarea from File without query. [message #380735 is a reply to message #380504] Tue, 13 January 2009 03:13 Go to previous messageGo to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear Mr. dr.s.raghunathan,

ya,it is just a file (not table with data content) it may be notepad or xls file.

Example:
I have a file named "s_raghunathan.xls" and it contains
following data (as ex.):
-----------------------
william IT 5000
John Sales 2000
Martin Adm 1000
------------------------
objective:i want to show that above data in "TextArea" from that file. i dont want to store in the database table. just want to show the exact file data in a "TextArea" field.

Event: i will press Browse Button (P1_MYFILE) and select "s_raghunathan.xls" file then press Submit button (P1_SUBMIT) finally my file data will show in "TextArea" field (P1_TEXTAREA ).

*** Please find the attachment to understand my problem/objective.

pls, i need this solution urgently.
Thank you for your successive reply.

----------------
Kamal hossain.
  • Attachment: FileData.GIF
    (Size: 39.34KB, Downloaded 1215 times)

[Updated on: Tue, 13 January 2009 03:31]

Report message to a moderator

Re: How to show text/data in Textarea from File without query. [message #380841 is a reply to message #380735] Tue, 13 January 2009 09:39 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
Take a look at this:
How to Upload and Download Files in an Application
All the data you insert can be found in the apex_application_files view. There's a name column in it which will hold the value of your file browse item. The file content will be in the column called blob_content, which is a blob, so it would need to be converted for you to be able to show it as text.
Blob functions:
DBMS_LOB

However, the text area may not allow you to show the file if it's too big, so you could have some problems there (varchar2 max length). Why do you need this?

declare
    v_file_blob    blob;
    v_file_clob    clob;
    v_file_size    integer := dbms_lob.lobmaxsize;
    v_dest_offset  integer := 1;
    v_src_offset   integer := 1;
    v_blob_csid    number := dbms_lob.default_csid;
    v_lang_context number := dbms_lob.default_lang_ctx;
    v_warning      integer;
begin
    dbms_lob.createtemporary(v_file_clob, true);
    
    select blob_content into v_file_blob
    from apex_application_files
    where name = :MY_FILE_BROWSE_ITEM;
    
    dbms_lob.converttoclob(v_file_clob,
                           v_file_blob,
                           v_file_size,
                           v_dest_offset,
                           v_src_offset,
                           v_blob_csid,
                           v_lang_context,
                           v_warning);

    :MY_TEXT_AREA := v_file_clob;

    dbms_lob.freetemporary(v_file_clob);

    delete from apex_application_files
    where name = :MY_FILE_BROWSE_ITEM;
end;
Re: How to show text/data in Textarea from File without query. [message #380901 is a reply to message #380841] Tue, 13 January 2009 21:05 Go to previous messageGo to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear Mr. c_stenersen,

Thank you very much.

I need this bcz i want to Insert data in my database table from file(as per Client/Application requirement).It is not just upload an attachment(image or file...).
User will select his file and the file content (data) will disply in the textarea field. when he will press "Update" or whatever button, data will be inserted into the datbase table . I have done such as copying the file content and pasting it into the textArea field then update database field.
Its working perfectly. But my problem is
need a solution that user will select file using browse.. and content will take place in the textarea without copying and pasting.

Thank you for your reply. let me try with this.


------------
Kamal Hossain.

[Updated on: Tue, 13 January 2009 21:24]

Report message to a moderator

Re: How to show text/data in Textarea from File without query. [message #382977 is a reply to message #380504] Mon, 26 January 2009 21:24 Go to previous messageGo to next message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear mr.c_stenersen,

File uploading now working. but i found few problem. some of the xls file showing in the textarea and some of file showing error "ORA-06502: PL/SQL: numeric or value error"
but file is so small, few lines of file.

will you pls help me how to resove it?



Kind regards,



Kamal hossain

Re: How to show text/data in Textarea from File without query. [message #383326 is a reply to message #382977] Wed, 28 January 2009 05:31 Go to previous messageGo to next message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
Can you please give an example of one of the files which gives you errors? The dbms_lob.converttoclob procedure can give you a value_error. You take these files from excel? (I assume that since you use the xls format.) These can't be directly converted to text, so I don't quite understand why you want to put them in a text area (and what you want it to look like).

From the page about the dbms_lob package I gave you a link to in my previous post:
Quote:
Table 69-17 CONVERTTOCLOB Procedure Exceptions
Exception Description

VALUE_ERROR Any of the input parameters are NULL or INVALID.

INVALID_ARGVAL One or more of the following:
- src_offset or dest_offset < 1.
- src_offset or dest_offset > LOBMAXSIZE.
- amount < 1.
- amount > LOBMAXSIZE.

dbms_lob.converttoclob
Re: How to show text/data in Textarea from File without query. [message #384184 is a reply to message #383326] Mon, 02 February 2009 10:41 Go to previous message
dbhossain
Messages: 155
Registered: August 2007
Location: Dhaka
Senior Member

Dear c_stenersen,

Thank you very much agian. Actually it working only for CSV formatted data from execl. but if Normal excel file .xls formate showing error as "ORA-06502: PL/SQL: numeric or value error". But if the same file i convert to .csv formattated then showing in the text box properly


i think you understand the problem.



Thank you.

-Kamal hossain
Previous Topic: Disappearing Breadcrumbs
Next Topic: Can not show value in the 3D stacked bar chart
Goto Forum:
  


Current Time: Fri Apr 19 17:08:18 CDT 2024