Question

Using coldfusion 8, blob values selected from a table are appearing as "[empty string]".

Is there a mistake in my cfml or is there another issue?

I appreciate the help!

ColdFusion Server - 8,0,1,195765

Oracle Database 11g - 11.2.0.3.0 - 64bit

BLOB test -

<cfset idval="1">
<cfset val="hello world">
<cfset encoding="utf-8">

<!---STRING CONVERSION TO BINARY DATA--->
<cfset form.binVal = CharsetDecode(val,encoding)>
<cfdump var="#form.binVal#">

<!---CLEAR TABLE--->
<cfquery name="delete" datasource="DATA1">
DELETE FROM DATA1.TEST_BLOB
</cfquery>

<!---INSERT--->
<cfquery name="insert" datasource="DATA1">
INSERT INTO DATA1.TEST_BLOB 
VALUES(<cfqueryparam value="#idval#">,
       <cfqueryparam cfsqltype="CF_SQL_BLOB" value="#form.binVal#">
      )
</cfquery>

<!---SELECT AND DISPLAY DATA--->
<cfquery name="select" datasource="DATA1">
SELECT *
FROM DATA1.TEST_BLOB
</cfquery>

<cfdump var="#select#">
Was it helpful?

Solution

A utl_raw.cast_to_Varchar2() is needed to get results:

<cfquery name="select" datasource="DATA1">
  SELECT UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(*name_of_field*)) 
  FROM   DATA1.TEST_BLOB
</cfquery>

OR

To return the data without casting

Go to the CF admin setting for the DSN, there are advanced setting that enable BLOB data

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top