Weblogic and cmp with blob fields
I have an entity bean with cmp. This bean has a blob field. When ejbCreate and
ejbPostCreate methods are executed in this bean, exception saying "row containing
the LOB value is not locked" is thrown.
The transaction attribute for the method is set to RequiresNew in the deployment
descriptor.
Can someone suggest what may be going wrong here.
Thanks
I have an entity bean with cmp. This bean has a blob field. When ejbCreate and
ejbPostCreate methods are executed in this bean, exception saying "row containing
the LOB value is not locked" is thrown.
The transaction attribute for the method is set to RequiresNew in the deployment
descriptor.
Can someone suggest what may be going wrong here.
Thanks
Similar Messages
-
Error displaying a jpg file loaded into a table with blob field
This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
The database is 10g
-- Create table
create table PHOTOS
IMAGEID NUMBER(10),
IMAGE BLOB,
IMAGE_NAME VARCHAR2(50)
load image
CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
src_file BFILE;
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
src_file := bfilename('SNAPUNCH', p_photo_name);
-- insert a NULL record to lock
INSERT INTO photos (imageid, image_name, image)
VALUES (p_id , p_photo_name, EMPTY_BLOB())
RETURNING image INTO dst_file;
-- lock record
SELECT image
INTO dst_file
FROM photos
WHERE imageid = p_id AND image_name = p_photo_name
FOR UPDATE;
-- open the file
dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
-- determine length
lgh_file := dbms_lob.getlength(src_file);
-- read the file
dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
-- update the blob field
UPDATE photos
SET image = dst_file
WHERE imageid = p_id
AND image_name = p_photo_name;
-- close file
dbms_lob.fileclose(src_file);
END load_file;
display image
PROCEDURE display_image(p_id NUMBER) IS
Photo BLOB;
v_amt NUMBER DEFAULT 4096;
v_off NUMBER DEFAULT 1;
v_raw RAW(4096);
BEGIN
-- Get the blob image
SELECT image
INTO Photo
FROM PHOTOS
WHERE IMAGEID = p_id;
owa_util.mime_header('images/jpg');
BEGIN
LOOP
-- Read the BLOB
dbms_lob.READ(Photo, v_amt, v_off, v_raw);
-- Display image
htp.prn(utl_raw.cast_to_varchar2(v_raw));
v_off := v_off + v_amt;
v_amt := 4096;
END LOOP;
dbms_lob.CLOSE(Photo);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
END;
The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks. -
Export table rows to Excel and save to BLOB field
Hi all,
I try to find out how export data from table to Excel file format and save the result to BLOB field in some other table.
I know how to download report from Page by submit, but I need to process data and instead of returning result to user as Excel file - save it in BLOB.
Also I found implementation on JAVA for the issue but actually I wanna study out - Is it possible to resolve this issue by PL/SQL and APEX API methods?
So, any ideas :) ??
Thanks,It is not very difficult.
Here is the function I use to get a CSV file from a query :
PROCEDURE get_query_result_as_csv_file(
in_query IN VARCHAR2,
in_filename IN VARCHAR2)
IS
l_blob BLOB;
l_raw RAW(32767);
l_cursor INTEGER;
l_cursor_status INTEGER;
l_col_count NUMBER;
l_col_val VARCHAR2(32767);
l_desc_tbl sys.dbms_sql.desc_tab2;
BEGIN
-- create temporary BLOB
dbms_lob.createtemporary(l_blob, FALSE);
-- open BLOB
dbms_lob.open(l_blob, dbms_lob.lob_readwrite);
-- open cursor (and get cursor id)
l_cursor := dbms_sql.open_cursor;
-- parse query
dbms_sql.parse(l_cursor, in_query, dbms_sql.native);
-- get number of columns and description
dbms_sql.describe_columns2(l_cursor, l_col_count, l_desc_tbl);
-- define report columns
FOR i IN 1 .. l_col_count LOOP
dbms_sql.define_column(l_cursor, i, l_col_val, 32767);
END LOOP;
-- write column headings to CSV file
FOR i IN 1 .. l_col_count LOOP
l_col_val := l_desc_tbl(i).col_name;
IF i = l_col_count THEN
l_col_val := '"' || l_col_val || '"' || chr(10);
ELSE
l_col_val := '"' || l_col_val || '",';
END IF;
l_raw := utl_raw.cast_to_raw(l_col_val);
dbms_lob.writeappend(l_blob, utl_raw.length(l_raw), l_raw);
END LOOP;
-- execute the query
l_cursor_status := dbms_sql.execute(l_cursor);
-- write result set to CSV file
LOOP
EXIT WHEN dbms_sql.fetch_rows(l_cursor) <= 0 OR dbms_sql.last_row_count > 1000;
FOR i IN 1 .. l_col_count LOOP
dbms_sql.column_value(l_cursor, i, l_col_val);
IF i = l_col_count THEN
l_col_val := '"' || l_col_val || '"' || chr(10);
ELSE
l_col_val := '"' || l_col_val || '",';
END IF;
l_raw := utl_raw.cast_to_raw(l_col_val);
dbms_lob.writeappend(l_blob, utl_raw.length(l_raw), l_raw);
END LOOP;
END LOOP;
-- close cursor and BLOB
dbms_sql.close_cursor(l_cursor);
dbms_lob.close(l_blob);
-- set http headers
owa_util.mime_header('application/octet', FALSE);
htp.p('content-length: ' || dbms_lob.getlength(l_blob));
htp.p('content-disposition: attachment;filename="' || in_filename || '.csv"');
owa_util.http_header_close;
-- download the file
wpg_docload.download_file(l_blob);
END;If you need to get the query dynamically from your report, you can try to get the source from the apex_application_page_regions table :
SELECT region_source
FROM apex_application_page_regions
WHERE application_id = 111 -- replace with your application id
AND static_id = 'static_id_of_your_report'Then instead of using wpg_docload.download_file, simply insert the BLOB into your table.
Good luck.
Yann. -
Problem with BLOB fields (DBMS_LOB)
I want to read a word document from hard disc and save it into a BLOB field with using DBMS_LOB package. but when using it I always receive error "Invalid LOB locator specified" even I use oracle examples.
I use FormBuilder 6.0.
How can I do this. plz give me a code.
Thanks so much>
help plzzz
>
If you want help in the forum you need to use English when you post.
You also need to actually ask a question or present the issue that you need help with. Just saying you nave a problem and then posting code isn't sufficient.
Please edit your post and provide the English version of your code, comments, error messages and your action question or issue. -
Inserting and updating a BLOB field
Friends I want my application (Oracle is the backend) to look for a character in a BLOB field and then replace it with the desired character.
Can some one give me some example of retrieving and updating a BLOB fieldExamples are in Oracle Technet: http://otn.oracle.com/
In this forum I saw also some examples and in your local Oracle Client Installation you find under $ORACLE_HOME$/jdbc/demo/ examples.
reagrds Dietmar -
Serialization Object and storasge in blob field Oracle 8.1.6
Hi,
this is problem with serializing and deserializing when i am storing object serialized in a Blob field Oracle:
MyObject myObject = new MyObject();
ByteArrayOutputStream bayos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream (bayos);
oos.writeObject(myObject);
oos.flush();
byte[] buffer = bayos.toByteArray();
int size = buffer.length;
oos.close();
ByteArrayInputStream bayis = new ByteArrayInputStream(buffer,0,size);
// if the number bytes of serialized myObject > 4kbytes then the insert in Blob field fails down.
// if the number bytes of serialized myObject < 4kbytes then the insert in Blob field successes.
// So I only can put in Blob field serialized object with size minus 4k.
// The code for insert:
PreparedStatement pstmt = connection.prepareStatement(sqlInsert);
pstmt.setBinaryStream(1,bayis,size);
int retCode = pstmt.executeUpdate();
// The code for read from table Oracle
rset = stmt.rxecuteQuery(sqlSelect);
rset.next();
oracle.sql.BLOB fldBlob = (BLOB)rset.getObject(1);
InputStream ins = fldBlob.getBinaryStream();
byte[] buf = new byte[size]
ByteArrayInputStream bayis = new ByteArrayInputStream(buf,0,size);
ObjectInputStream ois = new ObjectInputStream(bayis);
MyObject myObject = (MyObject)ois.readObject();
Someone knows the reason of the limit of 4Kbyte ?
Thanks....Insert LOBs into Oracle is a 3 step process. You must insert a place holder, and the do a select for update to put the contents into the row. Lets say you have a table called MY_LOB:
create table MY_LOB (
MYID NUMERIC(10) NOT NULL,
MYLOB BLOB DEFAULT EMPTY_BLOB()
);The 'empty_blob' keyword tells Oracle to put a dummy value in the blob column when a row is initially created. To insert (assuming you have a db connection already):
conn.setAutoCommit(false);
PreparedStatement pstmt = null;
ResultSet rs = null;
oracle.sql.BLOB myLob = null;
try
//Insert the initial row.
pstmt = conn.prepareStatement("INSERT INTO MY_LOB (MYID) VALUES (?)");
//Set the PK value
pstmt.setInt(1,100);
pstmt.executeUpdate();
pstmt.close();
//Lock the row for insertion. This is needed for large inserts.
pstmt = conn.prepareStatement("SELECT MYLOB from MY_LOB where MYID = ? FOR UPDATE");
pstmt.setInt(1,100);
rs = pstmt.executeQuery();
if (rs.next())
myLob = (oracle.sql.BLOB)rs.getBlob(1);
rs.close();
pstmt.close();
//Finally...update the row with the blob data....
myLob.putBytes(1, buffer);
pstmt = conn.prepareStatement("UPDATE MY_LOB SET MYLOB = ? WHERE MYID = ?");
pstmt.setBlob(1, myLob);
pstmt.setInt(2,100);
pstmt.executeUpdate();
pstmt.close();
conn.commit();
catch(SQLException sqlE)
conn.rollback();
finally
//make sure and close all statements....
}Hope this helps, I didn't compile it so it may have some bugs. It should lead in the right direction at least. -
Generic UDF to handle empty contexts and contexts with missing fields
Hi,
I have been trying to get my head around a UDF for this for a while, but cannot find the solution. I''l start by showing input structure, and expected target structure (subset of an invoice IDoc with 4 line items):
SOURCE:
E1EDK01 (0..1)
E1EDP01
---POSEX = 1
---E1EDP05
KOTXT (qualifier) = Z1
BETRG (amount) = 200,00
---E1EDP05
KOTXT = Z2
BETRG = 300,00
---E1EDP19...
E1EDP01
---POSEX = 2
---E1EDP05
KOTXT = Z1
---E1EDP05
KOTXT = Z2
BETRG = 400,00
---E1EDP19...
E1EDP01
---POSEX = 3
---E1EDP05
KOTXT = Z2
BETRG = 500,00
---E1EDP19...
E1EDP01
---POSEX = 4
---E1EDP19...
TARGET:
Line
---PosId = 1
---Price = 200.00
Line
---PosId = 2
---Price = N/A
Line
---PosId = 3
---Price = N/A
Line
---PosId = 4
---Price = N/A
I want the price from E1EDP05/BETRG where KOTXT = Z1to be set for each line. As you can see the source structure can be split in 4 cases:
1. for some line items there exist multiple E1EDP05-segments with one of them qualifier Z1 and one corresponding amount field. This is the "perfect" structure and easy to handle.
2. some line items contains E1EDP05 with qualifier Z1 with no BETRG. Problem-case
3. some line items contains no E1EDP05-segments with qualifier Z1, but contains other E1EDP05-segments. Can be solved.
4. some line items contains no E1EDP05-segments at all. Can be solved.
I need to (I believe) set the context of the KOTXT and BETRG to E1EDP01 since I want one value per line item, irrespective of how many E1EDP05-segments exist per line item. In cases where no value can be found for relevant qualifier (Z1) or no E1EDP05-segments exist for a line item I want a default value to be set (N/A).
My problem is that all these different cases might occur in the same file, and they mess up the values in each context, leading to wrong BETRG to be picked in some cases (where case 2 exist) since mapWithDefault cannot be used (context contains value for other qualifier).
Do you know how to handle all these cases?
Any pseudo-code for an UDF?
Many thanks for your help!
Br,
KennethHi Shweta!
Thanks a lot, your idea didn't completely solve my problem, but pointed me in the right direction and gave me some valuable ideas:)
For anyone wondering how it is done, I solved it by using your suggested two inputs, along with a third input (constant) which functions as default value for contexts where value-field is missing for a specific qualifier, or in case no segments with desired qualifier exists for a context.
My mapping now looks like the following (where KOTXT is qualifier and KRATE is value field) for the 3 inputs:
KOTXT(Context = E1EDP01) \
equalsS -->
Constant(qualifier value) /
KOTXT(Context = E1EDP05) \
equalsS \
Constant(qualifier value) / ifWithoutElse --> removeContexts -->
KRATE (Context = E1EDP05) /
Constant(default value) -->
Then these 3 inputs goes into the following UDF (queue function):
int j=0;
boolean contextDone = false;
for(int i=0;i<a.length;i++)
if(a<i>.equals("true"))
if(b[j].equals(ResultList.SUPPRESS))
result.addValue(c[0]);
else
result.addValue(b[j]);
contextDone = true;
j=j+1;
if(a<i>.equals(ResultList.CC))
if (contextDone)
contextDone = false;
result.addValue(ResultList.CC);
else
result.addValue(c[0]);
result.addValue(ResultList.CC);
This results in a target node created for each context, where context relates to each line item in this case, where each value is either a default value or the value corresponding to the qualifier. This works in all cases where:
1. there are no segments containing relevant qualifier
2. there are segments with relevant qualifier, but missing value field
3. there are segments with relevant qualifier and value field
Thanks a lot again, Shweta, for guiding me!
Br,
Kenneth -
Connection MESG and INOB with additional field
Hi friends,
i'm beginner in ABAP and for this reason i create reports in ABAP query.
So i create query between tables MSEG and INOB (then INOB with AUSP).
In INOB-OBJEK - value is matnr and charg,
but value in this field is: for example
matnr charg
EK759064BK (8 free spaces) 0000000066
EK759064BK (8 free spaces) 0000000067
EK759064BK (8 free spaces) 0000000068
EK759064BK (8 free spaces) 0000000069
EK759064BK (8 free spaces) 0000000070
My idea is to create additional field with MSEG-MATNR and MSEG-CHARG and relate with INOB-OBJEK
(concatenate mseg-matnr mseg-charg into refkey.)
result is:
EK759064BK0000000066
EK759064BK0000000067
EK759064BK0000000068
EK759064BK0000000069
EK759064BK0000000070
Now my question is how to change code and create additional field like INOB-OBJEK, how to change my code so i have 8 free spaces between MATNR and CHARG?
Edited by: Marin Lyubomirov on Dec 13, 2009 9:39 AMthe ABAP keyword CONCATENATE has a parameter RESPECTING BLANKS
So if you use this this parameter, then you would get the missing 8 spaces, because the material number field is 18 long and your material only 10 long.
Alternative, just use an own field that is 8 long and do the concatenation like this :
concatenate mseg-matnr myfield mseg-charg into refkey -
Migrating a table with BLOB field from SQL-Server to Oracle.
Hi All,
I'm trying to create a Class to migrate data from SQL-Server to Oracle, this table has a BLOB field.
The Code:
package br.com.infox;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class Migrador {
public static void main(String[] args){
try {
// Conex�o com o SQL Server
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conSQL = DriverManager.getConnection ("jdbc:jtds:sqlserver://10.10.2.9/protocolo","prot","suinf2002");
// Conex�o com o Oracle
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conORA = DriverManager.getConnection ("jdbc:oracle:thin:@10.10.2.2:1521:des","protocolo","protocolo");
Statement stSQL = conSQL.createStatement();
String querySQL = "SELECT * FROM DOC_INCORPORADO";
ResultSet rsSQL = stSQL.executeQuery(querySQL);
String queryORA = "INSERT INTO PROT_VITALICIAMENTO (NU_PROCESSO, ANO_PROCESSO, CD_USUARIO, DT_ENVIO," +
"DE_COMPLEMENTO, NM_ARQUIVO, ARQUIVO, NU_SEQ, CD_TIPO_ARQUIVO, MES, ANO) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement psORA = conORA.prepareStatement(queryORA);
while (rsSQL.next()){
System.out.println("Linha: " + rsSQL.getRow());
psORA.setInt(1, rsSQL.getInt("nu_processo"));
psORA.setInt(2, rsSQL.getInt("ano_processo"));
psORA.setInt(3, rsSQL.getInt("cd_usuario"));
psORA.setDate(4, rsSQL.getDate("dt_incorporacao"));
psORA.setString(5, rsSQL.getString("complemento"));
psORA.setString(6, rsSQL.getString("nm_arquivo"));
psORA.setBinaryStream(7, rsSQL.getBinaryStream("arquivo"), (int)rsSQL.getBlob("arquivo").length());
psORA.setInt(8, rsSQL.getInt("num_seq"));
psORA.setInt(9, rsSQL.getInt("cd_tipo_arquivo"));
psORA.setInt(10, rsSQL.getInt("mes"));
psORA.setInt(11, rsSQL.getInt("ano"));
psORA.executeUpdate();
stSQL.close();
psORA.close();
conORA.close();
conSQL.close();
} catch (Exception e){
e.printStackTrace();
The ERROR:
java.sql.SQLException: Exce��o de E/S: Connection reset
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3668)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1119)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2191)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2064)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2989)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:658)
at br.com.infox.Migrador.main(Migrador.java:41)
What's the problem of these Class?
Thank's.Depending on the version of the database you have, you could use transportable tablespaces.
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96524/c04space.htm#9370 -
ReadObject and problems with Vector field
hello.
i'm trying to send an object(data Packet for a chat application) and receive it via sockets.
every thing is right but there is a Vector field(online users list)that has some problems.
my clients receive every updated class that contains new user list.but they just see the first received list?
it's so strange to me because every thing else (such as color,font,size,..) works fine.
can you help me?Every time you resend an object you have already sent, ObjectOutputStream will just send a 'handle', not the actual object. If it's changed value this is a problem. Use ObjectOutputStream.reset() to cause it to forget everything previously sent.
-
Add GoodsIssue and StockTransfers with specific field
I have a little problem to add a documents via DI like:
1. GoodsIssue with field in database called IGE1.OcrCode
My code in C#
private void add_GoodIssue()
SAPbobsCOM.Documents vRw;
vRw = (SAPbobsCOM.Documents)vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
vRw.DocObjectCodeEx = "60";
vRw.Lines. ?? (OcrCode)
2. StockTransfers with field in database called OWTR.Filler
My code in C#
private void add_StockTransfers()
SAPbobsCOM.Documents vMM;
vMM = (SAPbobsCOM.Documents)vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
vMM.DocObjectCodeEx = "67";
vMM. ?? (Filler)
I use SAP BO 2007A (8.00.235) PL11 HotFix1
I try check it at SAP BO 2007A (8.00.242) PL15
It is possible to add it via DI?
Edited by: kkostek on Jun 28, 2011 9:31 AMHello,
I see you would like to issue draft docuemnts. Arentyou?
use CostingCode to enter OcrCode this supports the distribution rules (profit centers).
private void add_GoodIssue()
SAPbobsCOM.Documents vRw;
vRw = (SAPbobsCOM.Documents)vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
vRw.DocObjectCodeEx = "60";
vRw.Lines.CostingCode = "profitcenter"
Draft stock transfers can be issued as stocktransferdraft document
use oStockTransferDraft instead of oDrafts
private void add_StockTransfers()
SAPbobsCOM.StockTransfer vMM;
vMM = (SAPbobsCOM.Documents)vcmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransferDraft);
vMM. FromWarehouse = "filler"
Regards
János -
BLOB field in Entity CMP EJB (DB = Oracle)
I use Borland App Server 4.5.1 .
I have table, which has BLOB column.
My first question is:
What datatype should corresponding field in Entity CMP EJB have?
I set it to byte [].
When I deal with BLOB data of small size, everything is OK.
But when the size of BLOB data is few larger,
when I insert new record
an Oracle error happens: a sort of
"TNS adapter error: end of communication chanel"
I use thin jdbc-driver.
So does anybody have an experience in working with BLOB field in Entity CMP EJB (DB = Oracle) ?
may be, the solution is to write BMP fields in Entity EJB,
i.e. to write own methods
set[BLOB_COLUMN](...),
get[BLOB_COLUMN]() ?
Thank you for answers.I have tried with db2 7.1/ IAS 4.0 and it works fine
I use Borland App Server 4.5.1 .
I have table, which has BLOB column.
My first question is:
What datatype should corresponding field in Entity CMP
EJB have?
I set it to byte [].this is perfect
When I deal with BLOB data of small size, everything
is OK.
But when the size of BLOB data is few larger,
when I insert new record
an Oracle error happens: a sort of
"TNS adapter error: end of communication chanel"In db2 there is a max size limit on the blob column. please check if such limit for oracle database.
>
I use thin jdbc-driver.
So does anybody have an experience in working with
BLOB field in Entity CMP EJB (DB = Oracle) ?
may be, the solution is to write BMP fields in Entity
EJB,
i.e. to write own methods
set[BLOB_COLUMN](...),
get[BLOB_COLUMN]() ?this is a good approach
>
Thank you for answers.Regards,
-- Ashish -
MD form with a blob field on the detail
Hi,
I created a master detail form, my detail form is based on a table with a blob field.
I got the following error message when I hit 'OK' on the form to finish creation.
"Exception from wwv_generate_component.build_procedure (WWV-01821)
Error creating module: ORA-01403: no data found (WWV-16042)".
Why?
BTW, I can create a form based on a table with blob field without any problem, but not a master detail form.
Thanks;
Kelly.Kelly,
Please provide more details and/or send the URL/login info directly to me.
Thanks,
Dmitry -
How to display image in blob field in ResultSet in SiteStudio?
I am running Site Studio 10gR4. For a custom page, I created a component that basically runs a query. The structure of the underlying data is a combination of Varchar2, Date and a single BLOB field. The blob field either contains a simple jpeg image, or nothing.
In my Page where I am looping through the data, how do I display the blob as an image?
Currently the code looks like this:
<!--$loop SQLRoutes-->
<tr>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 0))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 1))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 2))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 3))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 4))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 5))--></td>
<td><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))--></td>
</tr>
<!--$endloop-->Field 1 is a blob and fields 5 and 6 are dates.
So really two questions:
1. How do I display field1 as an image?
Example:
<!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 1))-->doesn't do it. Is there a different function then getValue() that I should be using to get the blob contents?
2. I want to compare the date fields to todays date, and either change the color or conditionally display the fields. I could do this with basic taglibs from jsp. How do I do this with IDocScript?
Example:
<!--$if getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6)) > dateCurrent-->
<span class="red"><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))--></span>
<!--$endif-->Thanks, KenI actually don't know the answer to #1. If I were to guess, there's nothing out-of-the-box to handle blobs, so your best option is to write your own idoc function. Take a look at the How To component if you don't know how.
For #2, you almost have it right. Insert bold:
<!--$if <b>parseDate(formatDate(</b>getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))<b>)) gt</b> dateCurrent<b>()</b>-->
<span class="red"><!--$getValue("SQLRoutes",rsFieldByIndex("SQLRoutes", 6))--></span>
<!--$endif--> -
BLOB fields again...
Hello,
I'm developing an application which has a database table with blob fields. I've had many problems recently with this type of field, the most undesired being that LOV fields doesn't work in pages with BLOB fields.
As a workaround, I've done a second page just to upload the files to the two blob fields. It worked, but now I needed to handle errors with different kind of files and their mime-types. I was happy to see that JHeadstart provided three auxiliary fields to store the filename, size and mime-type. It worked too, it saved all that information correctly, but:
1. When "downloading" the file, apparently the mime-type is not set.
2. Just after the file is uploaded, I can see in the main table that the attributes were saved correctly, but as soon as I close the browser and open a new session, I have errors. I have two blob columns; in the first, it doesn't shows the filename, but the file size, in the second blob column, it doesn't shows the file name, but the blob mime-type!
Does anybody has any similiar problem?
Thanks,
EduardoHello Peter,
Thanks for the confirmation that the BLOB / LOV issue is a bug.
About my another problem with HTTP headers while downloading files from blob fields, you are right, I need to be more specific. In my first try, this "second page" just to upload the files was a simple UIX page, not generated by JHeadstart. I saw this could be a little difficult to handle, so I discarded it.
Now, I created a second VO with the two blob fields and all other attributes read-only, and put it as a group in JHeadstart configuration file to generate the page automatically. I __disabled all multi-row operations__ so the blob fields are rendered in the main table as hyperlinks to be downloaded with their respective filenames set, as it was saved in the database field in the upload.
But in my tests, if I save other files than images, the browser doesn't open it correctly. So I opened the UIX JHeadstart generated page, where I see something like this:
<link destination="DownloadFile.do?pageTimeStamp=ignore&model=TsacContratoUIModel&binding=TsacContratoDocumentoContrato&rowKeyStr=${uix.current.rowKeyStr}&attachment=${TsacContratoDocumentoContratoTamarq}" text="${ui:cond(uix.current.TsacContratoDocumentoContratoTamarq!=null,uix.current.TsacContratoDocumentoContratoTamarq,'DocumentoContrato')}" rendered="${uix.current.TsacContratoDocumentoContrato!=null}"/>
Clearly I can see two things:
1. attachment=${TsacContratoDocumentoContratoTamarq}. I put uix.current inside, as we are in a table, and it worked fine after that.
2. The hyperlink doesn't have the mimeType parameter set, but the respective DownloadFile.do class uses it to set the correct mimeType header. I put it by hand: &mimeType=${uix.current.TsacContratoImagensViewDocumentoContratoMimetype}"
I verified that all the three attributes used to save file information are correct and exists in the VO, in the entity object and in the table, and I've also tested it in the Application Module and also, they save all the information correctly, so I don't think the problem is here, but in the page generation.
Thanks for your help. JHeadstart is a great and very interesting project despite some minor bugs that still exists.
Eduardo
Maybe you are looking for
-
Photos will Not Sync - Not Recognized in iTunes v12
My old laptop crashed and I replaced it with a Dell Inspiron 3000 running Window 8.1. I have managed to get everything loaded and synced over to my iPhone 5s but photos. I have a folder on my hard drive that has multiple folders in it. When I sele
-
Dynamic SQL in Form Builder 6.0
Hai, I would like to know how to create Dynamic SQL in Form Builder 6.0. I'am using oracle 9i database...Please help me.....
-
Step-by-Step procedure to create an InfoPackage Group & a Scenario!!
Hello BW Experts, IF we have 10 InfoPackages and if we need to create an InfoPackage Group for 7 of them, How do we do it?? Plz provide a detailed Step-by-Step procedure for the same/ create an InfoPackage group!! Ur help is really appreciated!! Than
-
Arranging a tight grid of floating divs with varying heights
When creating a grid using floating divs of varying height, the divs that carry over into the next row often find themselves in the second or third column rather than going immediately below the first div in the first column. I'm curious how I could
-
This is on a Dell Inspiron 1520 Laptop running Windows XP.