Importing Data from Oracle for CLOB data Type

bhanupraveen

New Member
Joined
May 2, 2012
Messages
5
Hi,

I have a scenario where in i need to connect to Oracle and get data from a table which contains CLOB datatype value. Below is my code:

Dim ConnectionString As String
Dim SQL_String As String
Set con = New ADODB.Connection
Set recset = New ADODB.Recordset
Oracle_Data_Source = "perf01"
Oracle_User = "PERF_OWNER"
Oracle_Password = "PERF_OWNER"
ConnectionString = "Provider=msdaora;Data Source=" + Oracle_Data_Source + "; User Id=" + Oracle_User + "; Password=" + Oracle_Password

con.ConnectionString = ConnectionString
con.Open con.ConnectionString

SQL_String = "select ID,dbms_lob.substr(bus_key,25,10) from MDI_WORK"

recset.Open SQL_String, con, adOpenStatic, adLockReadOnly

Do While Not recset.EOF
Debug.Print recset.Fields(0).Value
Debug.Print recset.Fields(1).Value
Loop

When i try to execute this code, getting "Application Defined or Object Defined error '1004'", Pls help me.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Which line causes the error?

(I suspect your problem is in the dbms_lob.substr(bus_key,25,10) part)
 
Upvote 0
Till below statement it executes fine, once i execute below it gives error. might be with dbms_lob only.

Debug.Print recset.Fields(0).Value
 
Upvote 0
I suspect the value is Null then.
 
Upvote 0
Ya, record count is -1 when i execute with Debug.Print recset.RecordCount, But when i execute the same query in Oracle, i get 19 records.
 
Upvote 0
No, I mean I expect the field is actually Null, not that there are no records. (whether or not recordcount is accurate depends on various factors such as cursors)
 
Upvote 0
Are you checking in the recordset or in the table?
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top