Oracle ODBC BLOB examples.

We are currently writing a VB application to harvest data from an Access 2000 database, which is to large to convert to 97 and use migration workbench, and stuff it into an Oracle 8 database, which already has the table structures from the Access dataabase created in it. We are running into a problem in transfering OLE objects in Access to BLOBs in Oracle. Can anyone give some insight / code examples?
Thanks,
Matt Shoultz

When you get a chance, can you post the ADO version, or a link to it?
thanks.
Chris
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
Unfortunately, I've never dealt with OLE objects in Access. I'm more than happy to help with BLOB's, though.
I'm posting a document below that covers reading & writing BLOB's with RDO under VB. Unfortunately, it's a little long, so I hope it doesn't get mangled too badly. If there's interest in an ADO version, let me know that as well and I'll post it on another thread.
If folks would like me to e-mail them a copy of this document, drop me a line. Expect it to take me at least a few days to reply to these requests, though.
PURPOSE
The code below should demonstrate how to read from and write to Oracle
8 BLOB datatypes.
SCOPE & APPLICATION
Experienced Visual Basic Developers.
RELATED DOCUMENTS
None.
The code below this demonstrates how to create a Visual Basic project
to read from and write to BLOB datatypes. It was written and tested using Visual
Basic 5 and RDO 2. The Oracle 8.0.5.2 ODBC driver was also used and an
Oracle 8.0.5 database.
Disclaimer:
This sample is provided for educational purposes only. It is NOT supported by
Oracle World Wide Technical Support. The sample has been tested and appears to
work as intended. However, you should always test in YOUR environment before
relying on it.
'Form Image Description
'~~~~~~~~~~~~~~~~~~~~~~
'The form needs 1 OLE control (OLE1) and 1 small text box (text 1) default value '1'
'it also needs 4 command buttons (AddNew,LoadFrom,LoadFromFile,SaveToDB)
'ODBC Datasource
'~~~~~~~~~~~~~~~
'Configure an 8.0.5.2 Oracle ODBC Driver Datasource named 'V805'
'Code required to generate database objects.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'drop table tblTestBlob;
'CREATE TABLE tblTestBlob
' DATA_ID NUMBER(5,0),
' DATA_BlobData BLOB,
' DATA_MemoData CLOB
'INSERT INTO TBLTESTBLOB VALUES (1,EMPTY_BLOB(), EMPTY_CLOB());
Option Explicit
Dim en As rdoEnvironment
Dim Qd As rdoQuery
Dim Cn As rdoConnection
Dim Rs As rdoResultset
Dim SQL As String
Dim DataFile As Integer, Fl As Long, Chunks As Integer
Dim Fragment As Integer, Chunk() As Byte, I As Integer
Const ChunkSize As Integer = 16384
Dim fileName As String
Private Sub PipeToFile(sFileName)
Dim iFile As Integer
iFile = FreeFile
Open sFileName For Binary As iFile
Me.OLE1.SaveToFile iFile
DoEvents
Close iFile
End Sub
Private Sub AddNew_Click()
Dim sSQL As String
sSQL = "Select * from TBLTESTBLOB"
On Error GoTo errorhandler
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
Rs.AddNew
Rs("DATA_ID") = Val(Me.Text1)
Rs("DATA_BLOBDATA").AppendChunk Null
Rs("DATA_MEMODATA").AppendChunk Null
Rs.Update
Rs.Close
Set Rs = Nothing
Exit Sub
errorhandler:
MsgBox "Add new click"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub Form_Load()
On Error GoTo errorhandler
Set Cn = New rdoConnection
Cn.CursorDriver = rdUseOdbc
Cn.Connect = ";dsn=" & "V805" & ";uid=" & "scott" & ";pwd=" & "tiger"
Cn.EstablishConnection
Exit Sub
errorhandler:
MsgBox "Form Load"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Function GetBLOBLength() As Long
Dim sSQL As String
Dim oResult As RDO.rdoResultset
On Error GoTo errorhandler
sSQL = "SELECT DBMS_LOB.GETLENGTH(DATA_BLOBDATA) FROM TBLTESTBLOB WHERE DATA_ID=" & Text1
Set oResult = Cn.OpenResultset(sSQL, rdOpenStatic)
GetBLOBLength = Val("" & oResult.rdoColumns(0).Value)
oResult.Close
Set oResult = Nothing
Exit Function
errorhandler:
MsgBox "Get BLOB Length"
MsgBox Err.Number
MsgBox Err.Description
End Function
Private Sub LoadFrom_Click()
Dim iNumBlocks As Integer
Dim lColSize As Long
Dim lBlockSize As Long
Dim byteData() As Byte
Dim lOffSet As Long
Dim iDestFileNum As Integer
Dim lLeftOver As Long
Dim iCount As Integer
Dim sSQL As String
On Error GoTo errorhandler
sSQL = "Select * from TBLTESTBLOB WHERE DATA_ID=" & Val(Text1)
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
If Not Rs.EOF Then
lColSize = GetBLOBLength()
If lColSize <> 0 Then
iDestFileNum = FreeFile
Open "c:\TEST.DAT" For Binary As iDestFileNum
lBlockSize = 10000
iNumBlocks = lColSize \ lBlockSize
lLeftOver = lColSize Mod lBlockSize
For iCount = 1 To iNumBlocks
ReDim byteData(lBlockSize)
byteData() = Rs("DATA_BLOBDATA").GetChunk(lBlockSize) 'note offset not used by RDO (?)
Put iDestFileNum, , byteData()
lOffSet = lOffSet + lBlockSize 'note offset not used by RDO (?)
Next iCount
ReDim byteData(lLeftOver)
byteData() = Rs("DATA_BLOBDATA").GetChunk(lLeftOver) 'note offset not used by RDO (?)
Put iDestFileNum, , byteData()
Close iDestFileNum
iDestFileNum = FreeFile
Open "c:\TEST.DAT" For Binary As iDestFileNum
Me.OLE1.ReadFromFile iDestFileNum
Close iDestFileNum
End If
End If
Rs.Close
Set Rs = Nothing
Exit Sub
errorhandler:
MsgBox "Load From click"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub LoadFromFile_Click()
' Locates a file and sets the Filename to this file.
On Error GoTo errorhandler
With CommonDialog1
.Filter = "*.*"
.ShowOpen
fileName = .fileName
End With
FileName_Change
Exit Sub
errorhandler:
MsgBox "Load from file"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub SaveToDB_Click()
Dim sSQL As String
Dim sTempName As String
On Error GoTo errorhandler
sTempName = "c:\TEST.DAT"
Kill sTempName
PipeToFile sTempName
sSQL = "Select DATA_ID, DATA_BLOBDATA from TBLTESTBLOB WHERE DATA_ID=" & Val(Text1)
'sSQL = "Select DATA_Field1, DATA_IMAGE from TBLBIGDATA WHERE DATA_FIELD1=" & Val(Text1)
Set Rs = Cn.OpenResultset(sSQL, rdOpenKeyset, rdConcurValues)
If Rs Is Nothing Or Rs.Updatable = False Then
MsgBox "Cant open or write to result set"
Exit Sub
End If
If Not Rs.EOF Then
Rs.Edit
End If
DataFile = 1
Open sTempName For Binary Access Read As DataFile
Fl = LOF(DataFile) ' Length of data in file
If Fl = 0 Then
Close DataFile
Exit Sub
End If
Chunks = Fl \ ChunkSize
Fragment = Fl Mod ChunkSize
Rs("DATA_BLOBDATA").AppendChunk Null
ReDim Chunk(Fragment)
Get DataFile, , Chunk()
Rs("DATA_BLOBDATA").AppendChunk Chunk()
ReDim Chunk(ChunkSize)
For I = 1 To Chunks
Get DataFile, , Chunk()
Rs("DATA_BLOBDATA").AppendChunk Chunk()
Next I
Close DataFile
Rs.Update
Rs.Close
Set Rs = Nothing
MsgBox "Finish"
Exit Sub
errorhandler:
MsgBox "Save to DB"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Private Sub FileName_Change()
On Error GoTo errorhandler
Me.OLE1.CreateEmbed fileName
Exit Sub
errorhandler:
MsgBox "File Name Change"
MsgBox Err.Number
MsgBox Err.Description
End Sub
Justin Cave
ODBC Development<HR></BLOCKQUOTE>
null

Similar Messages

  • Oracle ODBC and BLOB in html

    Hi,
    I would like to ask you if cad I use Oracle-ODBC driver (whuch version) for reading BLOB (LRAW) column in html(asp) - JavaScript.
    create table JPG
    CLZM NUMBER(6) not null,
    JPG_FILE LONG RAW null ,
    <% @ LANGUAGE=JavaScript%>
    <%
    Response.Buffer = true;
    Response.ContentType = "image/jpeg";
    Response.AddHeader("Content-Disposition","attachment; filename=test.jpg");
    Response.CacheControl = "public";
    Response.Expires = 0;
    oConn = Server.CreateObject("ADODB.Connection");
    oConn.Open("DSN=ORACLE;UID=scott;PWD=tiger;");
    // Query SQL to obtain recordset containing gif BLOB
    oRs = oConn.Execute("SELECT JPG_FILE FROM JPG WHERE CLZM='3156'");
    // Obtain local variable of /*
    PicSize = oRs("JPG_FILE").ActualSize;
    Pic = oRs("JPG_FILE").GetChunk(PicSize);
    // ??? Obtain only 4 bytey - why ???
    Response.BinaryWrite(Pic);
    Response.End();
    %>
    Thank's
    Ondrej

    I had the same problem using VBScript.
    What you have to do isread in blocks of let's say 1k in a loop and check wether the return value is exactly 1k, if not you may end your loop.
    Here's my code in VBScript.
    Dim varBlob
    Dim varChunk
    Const chuckSize = 1024
    Do
    varChunk = objRs.Fields("blobField").getChunk(chuckSize)
    varBlob = varBlob & varChunk
    Loop While (len(varChunk) = chuckSize)
    the contents of varBlob is your Picture
    null

  • Insert into CLOB fails with Oracle ODBC driver version 9.02.00.65

    I tried to insert into CLOB using the latest Oracle ODBC driver 9.02.00.65 and it fails. But the same works with earlier versions of ODBC driver earlier to 9.02.00.65 ie., 9.02.00.63.
    Here is the code snippet I tried. Any help now is highly appreciated as I am in the crunch time.
    I tried the same code snippet with VARCHAR2 column with the same driver and it works.
    ** CONVDSN.C - This is the ODBC sample code for
    ** creating File DSN pointers to machine DSNs.
    **This code is furnished on an as-is basis as part of the ODBC SDK and is
    **intended for example purposes only.
    #include <windows.h>
    #include <stdio.h>
    #include <tchar.h>
    #include <sql.h>
    #include <sqlext.h>
    #include <odbcinst.h>
    #include <sqltypes.h>
    #define MAXDATALEN 25 //maximum data length per column
    #define MAX_COL 15 //maximum column in result set
    #define MAX_ROW 100 //maximum number of rows
    #define MAXBUFLEN 256
    #define SQLERR_FORMAT "SQL Error State:%s, Native Error Code: %lX, ODBC Error: %s"
    #define MAXDISPLAYSIZE MAX_COL*(MAXDATALEN+1)
    #define SQLWRNMSGTITLE "SQL_SUCCESS_WITH_INFO results"
    #define SQLERRCNTDTITLE "SQL_ERROR results continued"
    #define SQLWRNMSGTITLE "SQL_SUCCESS_WITH_INFO results"
    #define SQLWRNCNTDTITLE "SQL_SUCCESS_WITH_INFO results continued"
    #define NULLDATASTRING "SQL_NULL_DATA"
    #define SQLERRMSGTITLE "SQL_ERROR results"
    // prototypes
    void ExpandFileName(LPSTR szFileDSNName, LPCSTR szDSNName);
    void MakeLegalName(LPSTR szLegalDSNName, LPCSTR szDSNName);
    // main routine: Iterate through the user and system DSNs, creating a pointer
    // to each.
    void FAR PASCAL DisplayError(SQLRETURN nResult, HWND hWnd, SWORD fHandleType, SQLHANDLE handle);
    void insertSelectClob();
    void checkRcCode(RETCODE rc);
    int main (int argc, char* argv[])
         insertSelectClob();
    return 0;
    void FAR PASCAL DisplayError(SQLRETURN nResult, HWND hWnd, SWORD fHandleType, SQLHANDLE handle)
         UCHAR szErrState[SQL_SQLSTATE_SIZE+1]; // SQL Error State string
         UCHAR szErrText[SQL_MAX_MESSAGE_LENGTH+1]; // SQL Error Text string
         char szBuffer[SQL_SQLSTATE_SIZE+SQL_MAX_MESSAGE_LENGTH+MAXBUFLEN+1];
         // formatted Error text Buffer
         SWORD wErrMsgLen; // Error message length
         UDWORD dwErrCode; // Native Error code
         int iSize; // Display Error Text size
         SQLRETURN nErrResult; // Return Code from SQLGetDiagRec
         SWORD sMsgNum = 1;
         SWORD fFirstRun = TRUE;
         char szDispBuffer[MAXDISPLAYSIZE+1]; // Display Buffer
         szBuffer[0] = '\0';
         do
              // continue to bring messageboxes till all errors are displayed.
              // more than one message box may be reqd. as err text has fixed
              // string size.
              // initialize display buffer with the string in error text buffer
              strcpy(szDispBuffer, szBuffer);
              // call SQLGetDiagRec function with proper ODBC handles, repeatedly until
              // function returns SQL_NO_DATA. Concatenate all error strings
              // in the display buffer and display all results.
              while ((nErrResult = SQLGetDiagRec(fHandleType, handle, sMsgNum++,
                   szErrState, &dwErrCode, szErrText,
                   SQL_MAX_MESSAGE_LENGTH-1, &wErrMsgLen)) != SQL_NO_DATA)
                   if(nErrResult == SQL_ERROR || nErrResult == SQL_INVALID_HANDLE)
                   break;
                   wsprintf(szBuffer, SQLERR_FORMAT, (LPSTR)szErrState, dwErrCode, (LPSTR)szErrText);
                   iSize = strlen(szDispBuffer);
                   if (iSize && (iSize+strlen(szBuffer)+1) >= MAXDISPLAYSIZE)
                   break;
                   if (iSize)
                   strcat(szDispBuffer, "\n");
                   strcat(szDispBuffer, szBuffer);
              // display proper ERROR or WARNING message with proper title
              if (nResult == SQL_SUCCESS_WITH_INFO)
                   MessageBox(hWnd, szDispBuffer, (fFirstRun? SQLWRNMSGTITLE : SQLWRNCNTDTITLE),
                   MB_OK | MB_ICONINFORMATION);
              else
                   MessageBox(hWnd, szDispBuffer, (fFirstRun? SQLERRMSGTITLE : SQLERRCNTDTITLE),
                   MB_OK | MB_ICONEXCLAMATION);
              if (fFirstRun)
                   fFirstRun = FALSE;
         while (!(nErrResult == SQL_NO_DATA || nErrResult == SQL_ERROR || nErrResult == SQL_INVALID_HANDLE));
    void insertSelectClob()
    SQLCHAR clobdata[1001];
    SQLCHAR resultdata[1001];
    SQLINTEGER ind = SQL_DATA_AT_EXEC;
    SQLCHAR *bufp;
         SQLINTEGER cbOrderID = sizeof(SQLSMALLINT);
         SQLSMALLINT sTmp=13;
         SQLCHAR *sqlStmt1  = _T("INSERT INTO clobtbl(id, clob1) VALUES(?, ?)");
         SQLCHAR *sqlStmt2  = _T("SELECT id, clob1 FROM clobtbl");
    //     SQLCHAR *sqlStmt1  = _T("INSERT INTO testInsert(id, clob1) VALUES(?, ?)");
    // SQLCHAR *sqlStmt2  = _T("SELECT id, clob1 FROM testInsert");
    int clobdatalen, chunksize, dtsize, retchklen;
         HENV envHnd;
    HDBC conHnd;
    HSTMT stmtHnd;
    RETCODE rc;
         int nRowcnt=0;
         SQLPOINTER pToken = NULL;
    rc = SQL_SUCCESS;
    // ENV is allocated
    rc = SQLAllocEnv(&envHnd);
    // Connection Handle is allocated
    rc = SQLAllocConnect(envHnd, &conHnd);
    rc = SQLConnect(conHnd, T("testd734"), SQLNTS, T("ipathdba"), SQLNTS, T("ipathdba"), SQLNTS);
    printf(_T("Insert CLOB1 using SQLPutData...\n[%s]\n"), sqlStmt1);
    // Set CLOB Data
    int i;
    SQLCHAR ch;
    for (i=0, ch=_T('A'); i< sizeof(clobdata)/sizeof(SQLCHAR); ++i, ++ch)
    if (ch > _T('Z'))
    ch = _T('A');
    clobdata[i] = ch;
    clobdata[sizeof(clobdata)/sizeof(SQLCHAR)-1] = _T('\0');
    clobdatalen = lstrlen(clobdata); // length of characters
    chunksize = clobdatalen / 7; // 7 times to put
         rc = SQLAllocHandle(SQL_HANDLE_STMT, conHnd, &stmtHnd);
    // Step 1: Prepare
    rc = SQLPrepare(stmtHnd, sqlStmt1, SQL_NTS);
    // checkSQLErr(envHnd, conHnd, stmtHnd, rc);
    // Step 2: Bind Parameter with SQL_DATA_AT_EXEC
    rc = SQLBindParameter(stmtHnd,
    1,
    SQL_PARAM_INPUT,
    SQL_C_SSHORT,
    SQL_INTEGER,
    0,
    0,
    &sTmp,
    0,
    &cbOrderID);
    rc = SQLBindParameter(stmtHnd,
    2,
    SQL_PARAM_INPUT,
    SQL_C_CHAR,
    SQL_LONGVARCHAR,
    clobdatalen*sizeof(CHAR),
    0,
    (SQLPOINTER)clobdata,
    clobdatalen*sizeof(CHAR),
    &ind);
    // checkSQLErr(envHnd, conHnd, stmtHnd, rc);
    // Step 3: Execute
    rc = SQLExecute(stmtHnd);
         while (rc == SQL_NEED_DATA) {
              rc = SQLParamData(stmtHnd, &pToken);
              if (rc == SQL_NEED_DATA) {
                   for (dtsize=0, bufp = clobdata;
                        dtsize < clobdatalen;
                        dtsize += chunksize, bufp += chunksize)
                   int len;
                   if (dtsize+chunksize < clobdatalen)
                        len = chunksize;
                        rc = SQLPutData(stmtHnd, bufp, len*sizeof(SQLCHAR));
                   else
                        len = clobdatalen-dtsize;
                        rc = SQLPutData(stmtHnd, bufp, SQL_NTS);
              rc = SQLParamData(stmtHnd, &pToken);
    // Fails as row count retrieved is zero.
         rc = SQLRowCount(stmtHnd, &nRowcnt);
         if(rc != SQL_SUCCESS)
              DisplayError(rc, NULL, SQL_HANDLE_ENV, conHnd);
    rc = SQLFreeStmt(stmtHnd, SQL_CLOSE);
    printf(_T("Finished Update\n\n"));
    rc = SQLAllocStmt(conHnd, &stmtHnd);
    if (rc != SQL_SUCCESS)
    printf(_T("Failed to allocate STMT\n"));
    exit(-1);
    // Clear Result Data
    memset(resultdata, 0, sizeof(resultdata));
    chunksize = clobdatalen / 15; // 15 times to gut
    rc = SQLExecDirect(stmtHnd, sqlStmt2, SQL_NTS); // select
         if(rc != SQL_SUCCESS)
              DisplayError(rc, NULL, SQL_HANDLE_ENV, conHnd);
    // Step 2: Fetch
    rc = SQLFetch(stmtHnd);
    for(dtsize=0, bufp = resultdata;
    dtsize > sizeof(resultdata)/sizeof(CHAR) && rc != SQL_NO_DATA;
    dtsize += chunksize-1, bufp += chunksize-1)
    int len; // len should contain the space for NULL termination
    if (dtsize+chunksize<sizeof(resultdata)/sizeof(CHAR))
    len = chunksize;
    else
    len = sizeof(resultdata)/sizeof(CHAR)-dtsize;
    // Step 3: GetData
    rc = SQLGetData(stmtHnd,
    2,
    SQL_C_CHAR,
    (SQLPOINTER)bufp,
    len*sizeof(CHAR),
    &retchklen);
    if (!_tcscmp(resultdata, clobdata))
    printf(_T("Succeeded!!\n\n"));
    else
    printf(_T("Failed!!\n\n"));
         if (conHnd)
              SQLFreeConnect(conHnd);
         if (envHnd)
              SQLFreeEnv(envHnd);
    }

    Hi,
    Since 9.2 has been desupported for error correction you will not be able to download that version from OTN. You should ask whoever is providing the training if their is an alternate version you can use. The only versions that you will be able to download from oracle.com is 10.2 11.1, and 11.2.

  • Insert Blob column in the client errors ClassCastException: oracle.sql.BLOB

    Hi,
    When I try to insert and commit a Blob column(picture) I am getting the following exception.
    Is there any jar I need to add or any other setup I need to do to accept the BLOB column in the olite client database.
    500 Internal Server Error
    javax.faces.FacesException: #{backing_XXPBWorkOrderResultsCreatePGBean.saveButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.sql.BLOB
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
         at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
    Caused by: java.lang.ClassCastException: oracle.sql.BLOB
         at oracle.lite.poljdbc.LiteEmbPreparedStmt.setVal(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.web.JupPreparedStatement.setObject(Unknown Source)
         at oracle.jbo.server.BaseSQLBuilderImpl.bindUpdateStatement(BaseSQLBuilderImpl.java:1765)
         at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:7345)
    With regareds,
    Kali.
    OSSI.

    Here are examples if inserting into a Blob from text, file, and retrieving a blob.
    Insert into a Blob (Text)
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class InsertBlob {
        public static void main(String[] args) throws FileNotFoundException {
            Connection con = null;
            PreparedStatement stmt = null;
            ResultSet rs = null;
            String letterText = "some letter text";
            long id = 100;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, EMPTY_BLOB())");
                stmt.setLong(1, id);
                stmt.executeUpdate();
                stmt = con.prepareStatement("SELECT BLOB_DATA FROM BLOB_TABLE WHERE BLOB_ID = ? FOR UPDATE");
                stmt.setLong(1, id);
                rs = stmt.executeQuery();
                if (rs.next()) {
                    try {
                        oracle.lite.poljdbc.BLOB oliteBlob = null;
                        oliteBlob = ((oracle.lite.poljdbc.OracleResultSet) rs).getBLOB(1);
                        byte[] byteLetterText = letterText.getBytes();
                        oliteBlob.putBytes(1, byteLetterText);
                        con.commit();
                    } catch (ClassCastException e) {
                        e.printStackTrace();
                    } finally {
                        rs = null;
                        stmt = null;
                        con.rollback();
                        con = null;
            } catch (SQLException e) {
                e.printStackTrace();
    }Insert Into a Blob (File)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class InsertBlobFile {
        public static void main(String[] args) throws FileNotFoundException {
            Connection con = null;
            PreparedStatement stmt = null;
            long id = 200;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, ?)");
                stmt.setLong(1, id);
                File fBlob = new File ( "C:\\BLOB_TEST_FILE.TXT" );
                FileInputStream is = new FileInputStream ( fBlob );
                stmt.setBinaryStream (2, is, (int) fBlob.length() );
                stmt.executeUpdate();
                con.commit();
            } catch (SQLException e) {
                e.printStackTrace();
    }Retrieve from Blob (Write to file)
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class RetrieveBlob {
        final static int bBufLen = 32 * 1024;
        final static String outFile = "C:\\BLOB_OUTPUT_FILE.TXT";
        public static void main(String[] args) throws IOException {
            Connection con = null;
            PreparedStatement stmt = null;
            ResultSet rs = null;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("SELECT * FROM BLOB_TABLE");
                rs = stmt.executeQuery();
                while(rs.next()) {
                    int id = rs.getInt(1);
                    Blob value = rs.getBlob(2);
                    System.out.println(id + " | " + value);
                    writeBlobToFile(value);
            } catch (SQLException e) {
                e.printStackTrace();
        public static long readFromBlob(Blob blob, OutputStream out)
          throws SQLException, IOException {
            InputStream in = blob.getBinaryStream();
            int length = -1;
            long read = 0;
            byte[] buf = new byte[bBufLen];
            while ((length = in.read(buf)) > 0) {
                out.write(buf, 0, length);
                read += length;
            in.close();
            return read;
        public static long writeBlobToFile(Blob blob)
          throws IOException, SQLException {
            long wrote = 0;
            OutputStream fwriter = new FileOutputStream(outFile);
            wrote = readFromBlob(blob, fwriter);
            fwriter.close();
            return wrote;
    }

  • Oracle ODBC Driver 10.02.00.04 sqora32.dll with /*+ RULE */ base hints

    Hi Everybody,
    I have a problem with SQL queries with /*+ RULE */ base hints being posted to an Oracle database. I have reason to believe that these queries are generated by the Oracle ODBC Driver itself. Although I don't have a performance problem per se, I need to reduce these hints to a minimum so we can fine-tune the database as a whole.
    * The views that are hit are always the same: All_Objects, All_Arguments, All_Synonyms,
    * We are using Oracle ODBC driver 10.02.00.04 for Windows, the database server is a RS6000 with AIX and Oracle 10g,
    * Aside Oracle Development tools, there are no applications, reports or similar gadgets that query the tables described above.
    I would really appreciate any help about this issue.
    Here is an example of the type of queries that I'm writing about:
    SELECT /*+ RULE */ '', b.owner, decode (b.object_type, 'PACKAGE', CONCAT( CONCAT (b.object_name, '.'), a.object_name), b.object_name), NULL, NULL, NULL, NULL, decode (b.object_type, 'PACKAGE', decode(a.position, 0, 2, 1, 1, 0), decode(b.object_type, 'PROCEDURE', 1, 'FUNCTION', 2, 0))
    FROM ALL_ARGUMENTS a, ALL_OBJECTS b
    WHERE ( b.object_type = 'PROCEDURE' OR b.object_type = 'FUNCTION' ) AND b.object_id = a.object_id AND (a.sequence=1 OR a.sequence=0) AND b.OBJECT_NAME = 'MYTABLE' AND b.OWNER = 'MYSCHEMA' UNION
    SELECT /*+ RULE */ '', b.owner,b.object_name,NULL, NULL, NULL, NULL,decode(b.object_type, 'PROCEDURE', 1, 'FUNCTION', 2, 0)
    FROM ALL_OBJECTS b
    WHERE (b.object_type = 'PROCEDURE' OR b.object_type = 'FUNCTION') AND b.OBJECT_NAME = 'MYTABLE' AND b.OWNER = 'MYSCHEMA' UNION
    SELECT /*+ RULE */ distinct '', a.owner,CONCAT(CONCAT (a.package_name, '.'), a.object_name),NULL, NULL, NULL, NULL,decode(a.position, 0, 2, 1, 1, 0)
    FROM ALL_ARGUMENTS a
    WHERE (a.sequence=1 OR a.sequence=0) AND a.OBJECT_NAME = 'MYTABLE' AND a.OWNER = 'MYSCHEMA' ORDER BY 2,3
    Best Regards,
    Manuel
    Edited by: user10165637 on Jul 28, 2009 1:29 PM

    Hi Greg,
    Thank you for your answer. One of the things that we did when we migrated to Oracle 10g was to ensure that the "Disable Rule Base Hints" flag, located in the "Work-arounds" tab in the ODBC DSN window is checked. We previously refreshed all Microsoft's Access databases to use this new DSN connection. Still, the hints are there.
    However... we may have been able to link these calls to these Oracle System Catalog views, with a custom application that launces Crystal Reports.
    Although we all know that Crystal Reports also caches ODBC DSN configuration settings, I must say that these same Crystal Reports do not generate hints when called from their InfoView server.
    We will proceed to modify the custom application, overridding the dissable rule-base hint work-around with the string "DRH=T" on the connection string. Next week we will know if this works.
    Best Regards,
    Manuel

  • Java source / oracle.sql.BLOB.createTemporary

    Hi!
    I want to write some java-code (CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED...)
    where I want to return an image as blob.
    For doing that I have to initialize the blob in the java-code -correct?
    I see many examples like
    oracle.sql.BLOB.createTemporary(conn, false,oracle.sql.BLOB.DURATION_CALL)
    In PL/SQL there is some similar:
    dbms_lob.createtemporary(lob_loc => xmlclob, cache => TRUE, dur => dbms_lob.SESSION);
    If I have to initialize the blob in the java source, how to do that?
    I don't want an connection to an remote database, the java-code will be in the database, so can I call createTemporary without >conn<?
    (Oracle 10gR2, Windows, Linux, AIX)
    The picture will be generated calling other java-code loaded with loadjava.
    The java-source I want to write will be wrapped with PL/SQL.
    Greetings
    Bjørn

    Hi!
    It seems you can do this:
              try {
                   conn = new OracleDriver().defaultConnection();                graphblob = oracle.sql.BLOB.createTemporary(conn, false,oracle.sql.BLOB.DURATION_CALL); // must init
                   System.out.println("Blob is init");
              } catch ( java.sql.SQLException sEx ) {
                   throw new RuntimeException ("No connection", sEx);
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1285601748584
    http://www.unix.org.ua/orelly/oracle/guide8i/ch09_08.htm
    /Bjoern

  • Oracle.sql.BLOB ClassCastException

    Hi everyone,
    I'm trying to put a serialized Java object into Oracle. I am following the example here: http://www.oracle.com/oramag/oracle/01-may/o31asktom.html
    Here is my code:
    String sql = "begin " +
          "insert into rdm_logs (datetime, id, machine, ip_addr, action_code, tablename, comments, " +
         "row_before, row_after)" +
          "values (sysdate, ?, ?, ?, ?, ?, ?, empty_blob(), empty_blob()) " +
          "return row_before into ?; " +
      "end;";
    CallableStatement stmt = connection.prepareCall(sql);
    stmt.setString(1, username);
    stmt.setString(2, machine);
    stmt.setString(3, ip);
    stmt.setString(4, action_code);
    stmt.setString(5, table);
    stmt.setString(6, comment);
    stmt.registerOutParameter(7, java.sql.Types.BLOB);               
    stmt.executeUpdate();               
    Object o = stmt.getBlob(7);
    // output class name here
    System.out.println(o.getClass().toString());
    // cast to oracle.sql.BLOB
    oracle.sql.BLOB blob = (BLOB) o;The system output is:
    class oracle.sql.BLOB
    java.lang.ClassCastException: oracle.sql.BLOB
    As you can see, the System.out gives oracle.sql.BLOB as the object class type, so why does it throw an exception when I cast it to be the same?
    Any help would be appreciated.

    As you can see, the System.out gives oracle.sql.BLOB as the object
    class type, so why does it throw an exception when I cast it to be the same?This can happen if the two BLOB classes have been loaded with two different unrelated class loaders. Even though the names of the classes are the same there are two separate classes.
    How to fix this depends... Somehow arrange the JDBC driver to be loaded by the system class loader before any other class loader has a chance to load it?

  • Oracle.sql.BLOB.freeTemporary() is not freeing TEMP space in the database

    Hi Folks,
    We are using oracle.sql.BLOB to store some file information into the database.
    Allocation of the temp space is done as below
    BLOB blob=BLOB.createTemporary(conn, false, BLOB.DURATION_SESSION); // this results in the usage of TEMP space from database
    And subsequent release is done as below
    blob.freeTemporary(); // this should have release the space from the database.
    This is on Oracle 10g, Java 1.6, ojdbc6.jar There are no exceptions. Even a simple program results in the same.
    Anybody faced something similar? Any pointers would be really appreciated.
    Thanks,
    Deva
    Edited by: user10728663 on Oct 11, 2011 5:33 AM

    Thanks a lot for the information.
    Memory is fine. And I am able to reproduce this within the scope of a simple example as well.
    Would you have any reference to the thread which had earlier reported this as a bug. I tried a reasonable amount of search in the forum, but no success.
    Thanks very much for any pointers.

  • Oracle.sql.BLOB.setBytes() Error

    Hi,
    I'm trying to use Java to put a large array of bytes into a BLOB table column. I'm first inserting the new row with an empty_blob() and then calling select <blob_column> ... for update and getting the oracle.sql.BLOB out of the resultset. I then try to call setBytes() on this BLOB and I get the following exception:
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
    at oracle.jdbc.driver.T4CConnection.putBytes(T4CConnection.java:2440)
    at oracle.sql.BLOB.setBytes(BLOB.java:916)
    I'm using Oracle XE (oracle-xe-11.2.0-1.0.x86_64.rpm), the latest ojdbc6.jar, and jboss 4.2.2 on CentOS.
    A code snippet of what I'm doing:
    ... stmt = con.prepareStatement("select blob_column from blob_table where id=? for update"); stmt.setLong(1, Id); ResultSet rs = stmt.executeQuery(); try {     if (rs.next()) {         WrappedResultSet wrappedRs = (WrappedResultSet)rs;         BLOB oracleBlob = ((OracleResultSet)wrappedRs.getUnderlyingResultSet()).getBLOB(1);         if(oracleBlob != null) {             byte[] bytes = getData();             int pos = 0;             long bytesLeft = bytes.length;             log.debug("Attempting to write " + bytes.length + " bytes to BLOB");             while(bytesLeft > 0) {                 int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);                 log.debug("Wrote " + bytesWritten + " bytes to BLOB");                 bytesLeft -= bytesWritten;                 pos += bytesWritten;             }         }     } } finally {     rs.close(); } ...
    Any help would be greatly appreciated!

    Welcome to the forum!
    Thanks for posting the code and the DB, JDBC and app server versions. Those are what is needed to help.
    >
    java.sql.SQLException: Invalid argument(s) in call: putBytes()
                while(bytesLeft > 0) {
                    int bytesWritten = oracleBlob.setBytes(pos, bytes, pos, MAXBUFSIZE);
                    log.debug("Wrote " + bytesWritten + " bytes to BLOB");
                    bytesLeft -= bytesWritten;
                    pos += bytesWritten;That 'Invalid argument . . .' was your clue to look at the ARGUMENT values you are passing to the method call. You could have easily done that by displaying the values to the console each time in the loop BEFORE the method call.
    This is the signature of that method in the Javadocs (edited to highlight the relevant parts):
    http://docs.oracle.com/javase/6/docs/api/java/sql/Blob.html#setBytes(long, byte[])
    >
    int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException
    Writing starts at position pos in the BLOB value; len bytes from the given byte array are written.
    Parameters:
    pos - the position in the BLOB object at which to start writing; the first position is 1
    bytes - the array of bytes to be written to this BLOB object
    offset - the offset into the array bytes at which to start reading the bytes to be set
    len - the number of bytes to be written to the BLOB value from the array of bytes bytes
    >
    This is what you are passing for 'len': MAXBUFSIZE
    Most likely that value is LARGER than the 'byte array' that you are using; perhaps it is even the MAX int size.
    That value is invalid.
    In addition each time thru the loop you increment 'pos' and use 'pos' as the 'offset' into your array. Then you once again use MAXBUFSIZE as the number of bytes to write from your array. Even if MAXBUFSIZE is less than the length of your array at some point it will likely be greater than what is left of the array.
    For example, if MAXBUFSIZE is 2 and your array length is 3 the first 'put' will put the first two bytes. Then the second put will use a 'pos' of 2 and try to put 2 more bytes; except there is only one byte left.
    Your code updates the entire BLOB value. Best practices are to use the stream methods for reading and writing BLOB/CLOB rather than the 'setBytes' method you are using. The main reason for this is performance: the stream methods write DIRECTLY to the database.
    >
    Notes:
    The stream write methods described in this section write directly to the database when you write to the output stream. You do not need to run an UPDATE to write the data. However, you need to call close or flush to ensure all changes are written. CLOBs and BLOBs are transaction controlled. After writing to either, you must commit the transaction for the changes to be permanent.
    >
    See 'Reading and Writing BLOB and CLOB Data' in the JDBC Dev Guide
    http://docs.oracle.com/cd/B19306_01/java.102/b14355/oralob.htm#i1058044
    >
    Example: Writing BLOB Data
    Use the setBinaryOutputStream method of an oracle.sql.BLOB object to write BLOB data.
    The following example reads a vector of data into a byte array, then uses the setBinaryOutputStream method to write an array of character data to a BLOB.
    java.io.OutputStream outstream;
    // read data into a byte array
    byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    // write the array of binary data to a BLOB
    outstream = ((BLOB)my_blob).setBinaryOutputStream(1L);
    outstream.write(data);

  • Af:inputFile componet - want to use class oracle.sql.BLOB instead

    Hi,
    I want to use the class oracle.sql.BLOB to get a blob from an input field. Can I use another ADF component instead of the af:inputFile component?
    According to this site: http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/apidocs/oracle/adf/view/faces/component/core/input/CoreInputFile.html - The "value" property of an inputFile component will be set to an instance of the oracle.adf.view.faces.model.UploadedFile class.
    From the Oracle JDeveloper 10g (10.1.3) Documentationdocumentation:
    UploadedFile file = (UploadedFile) event.getNewValue();
    //Here's where we could call file.getInputStream()
    I don't want to use getInputStream().
    I am working with JDev, oracle ADF, and Toplink.
    Any help is appreciated.
    Lin

    Hi,
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    Example 85
    http://otn.oracle.com/products/jdev/tips/muench/uploadedfiletoblob/UploadedFileToBlob.zip
    Frank

  • Oracle ODBC Driver is very slow?

    Hi,
    I installed Oracle8.1.7 on my machine and setted up an odbc connection using
    VC to the database. I created a statement adding records in the database using
    the SQLPrepare and SQLExecute by setting some parameters.
    It takes about 5 seconds to create 100 records! During this the PC is not so buisy.
    Oracle has some of 1% CPU time and my application has lesser than 1% CPU.
    If I look in the oracle trace file, it shows for this statement
    parsing 1 times, executed 100 times, cpu 0,01
    If I try a similar example using PL/SQL it adds 1000 records in one second.
    What I'm doing wrong here and what is the key to get the odbc driver work
    faster?
    I already read the Oracle ODBC documentation and have done all the steps there,
    like disabling the thread safe mode, but without any improvment.
    thanks
    khamis
    [email protected]

    My guess, since I'm not sure exactly what the structure of your program is, is that the slowness of ODBC comes from the fact that ODBC statements are, by default, automatically committed. This means that each time you execute a statement successfully, the database must take additional time to commit the changes, which can be expensive. In PL/SQL, however, the commit operation only occurs when you explicitly commit a statement.
    You can turn off autocommit mode and choose to manage your transactions manually. In straight ODBC, this is an option in the SQLSetConnectAttr function. I'm not sure whether your application is using straight ODBC or some higher-level API, though.
    Justin

  • Encountered ODBC error 1: 01004, 0, [Oracle][ODBC]String data, right trun

    I am getting the following error like "07/01 17:33:33 (3380 0EC4): Encountered ODBC error 1: 01004, 0, [Oracle][ODBC]String data, right truncated."
    What does this error means.The set of query I am running for insertion is same for 32bit(Windows 2003 Server) and 64bit (Windows 2008 Server R2).
    In case of the former this works perfectly without any error but in case of 64bit I am getting the above issue.Any suggestion would be of great help and what is the workaround for this.
    Thanks in advance.
    -R

    Sorry for incomplete information. Basically there is a insertion and then there is retrieval of information from the same data table.
    When I am inserting data of blob type I am getting data and grabage value also.
    From the backend when I am using plsql and querying on that paritcular table from the 2nd row onwards I am getting garbage value apended with the string.How I see the garbage is when I click on the blob data under the plsql respective table it takes me to string by default for all the columns containing blob and from 2nd column onwards I get the garbage appended with the string.
    This garbage value is not present in the 1st row at all but it from the 2nd row it comes.
    desc of the particular table I am talking about is
    SQL> desc Table_1084;
    Name Null? Type
    BBID NOT NULL NUMBER
    KEYORDER NOT NULL NUMBER
    KEYLENGTH NOT NULL NUMBER
    DTTM_DOM NOT NULL NUMBER(2)
    KEYVALUE BLOB
    2ndly I tried to remove the garbage using memset.This time there is no garbage but from the 2nd row onwards when I click on the blob from the plsql backend
    I did memset for deleting the garbage.But then after 2nd column onwards when I click on the blob it takes me hex by default not to text.When I come to text I don't see any garbage.
    In both the cases I get the above error when I try to retrieve the above information from the DB.
    The same set of query runs well when I use Windows 32bit but I am getting issue when I am using Windows 2008 Server 64bit.
    Below I have given the code snipet any thoughts or inputs would be very much appreciated.
    SQLLEN lsqlkeyElementIDLengths = *(this->keyElementIDLengths);
    SQLBindParameter(this->statement,1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementBlackBoxIDs, 0, &lsqlkeyElementIDLengths);
    SQLLEN lsqlkeyElementOrderLengths = *(this->keyElementOrderLengths);
    SQLBindParameter(this->statement,2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementOrders, 0, &lsqlkeyElementOrderLengths);
    SQLLEN lsqlkeyElementLengthLengths = *(this->keyElementLengthLengths);
    SQLBindParameter(this->statement,3, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementLengths, 0, &lsqlkeyElementLengthLengths);
    SQLLEN lsqlkeyElementValueLengths = *(this->keyElementValueLengths);
    SQLBindParameter(this->statement,4, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY,
    elementSize, 0, this->keyElementValues,
    elementSize, &lsqlkeyElementValueLengths);
    SQLExecDirect(this->statement, (unsigned char*) insertcommand, SQL_NTS);
    Here the this->keyElementValues is of void pointer.
    When I query on the back ground I get the below garbage value
    ntdll.dll!KiFastSystemCallRet 0x7c8285ec
    kernel32.dll + 0x24ed (0x77e424ed)
    termite.exe!CTermiteDlg::TestRegisterMemoryProc 0x004050ed c:\cm\build\public\tkbkwincln.10-01-06\talkback\src\client\termite\win32\termdlg.cpp, line 460Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾
    Let me know if I can provide more information.
    Thanks,
    -R

  • Encountered ODBC error 1: 01004, 0, [Oracle][ODBC]String data, right trunca

    Dear All,
    I am getting the following error like "07/01 17:33:33 (3380 0EC4): Encountered ODBC error 1: 01004, 0, [Oracle][ODBC]String data, right truncated."
    What does this error means.The set of query I am running for insertion is same for 32bit(Windows 2003 Server) and 64bit (Windows 2008 Server R2).
    In case of the former this works perfectly without any error but in case of 64bit I am getting the above issue.Any suggestion would be of great help and what is the workaround for this.
    When I am inserting data of blob type I am getting data and grabage value also.
    From the backend when I am using plsql and querying on that paritcular table from the 2nd row onwards I am getting garbage value apended with the string.How I see the garbage is when I click on the blob data under the plsql respective table it takes me to string by default for all the columns containing blob and from 2nd column onwards I get the garbage appended with the string.
    This garbage value is not present in the 1st row at all but it from the 2nd row it comes.
    desc of the particular table I am talking about is
    SQL> desc Table_1084;
    Name Null? Type
    BBID NOT NULL NUMBER
    KEYORDER NOT NULL NUMBER
    KEYLENGTH NOT NULL NUMBER
    DTTM_DOM NOT NULL NUMBER(2)
    KEYVALUE BLOB
    2ndly I tried to remove the garbage using memset.This time there is no garbage but from the 2nd row onwards when I click on the blob from the plsql backend
    I did memset for deleting the garbage.But then after 2nd column onwards when I click on the blob it takes me hex by default not to text.When I come to text I don't see any garbage.
    In both the cases I get the above error when I try to retrieve the above information from the DB.
    The same set of query runs well when I use Windows 32bit but I am getting issue when I am using Windows 2008 Server 64bit.
    Below I have given the code snipet any thoughts or inputs would be very much appreciated.
    SQLLEN lsqlkeyElementIDLengths = *(this->keyElementIDLengths);
    SQLBindParameter(this->statement,1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementBlackBoxIDs, 0, &lsqlkeyElementIDLengths);
    SQLLEN lsqlkeyElementOrderLengths = *(this->keyElementOrderLengths);
    SQLBindParameter(this->statement,2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementOrders, 0, &lsqlkeyElementOrderLengths);
    SQLLEN lsqlkeyElementLengthLengths = *(this->keyElementLengthLengths);
    SQLBindParameter(this->statement,3, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementLengths, 0, &lsqlkeyElementLengthLengths);
    SQLLEN lsqlkeyElementValueLengths = *(this->keyElementValueLengths);
    SQLBindParameter(this->statement,4, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY,
    elementSize, 0, this->keyElementValues,
    elementSize, &lsqlkeyElementValueLengths);
    SQLExecDirect(this->statement, (unsigned char*) insertcommand, SQL_NTS);
    Here the this->keyElementValues is of void pointer.
    When I query on the back ground I get the below garbage value
    ntdll.dll!KiFastSystemCallRet 0x7c8285ec
    kernel32.dll + 0x24ed (0x77e424ed)
    termite.exe!CTermiteDlg::TestRegisterMemoryProc 0x004050ed c:\cm\build\public\tkbkwincln.10-01-06\talkback\src\client\termite\win32\termdlg.cpp, line 460Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾
    Let me know if I can provide more information.
    Thanks,
    -R

    Dear All,
    I am getting the following error like "07/01 17:33:33 (3380 0EC4): Encountered ODBC error 1: 01004, 0, [Oracle][ODBC]String data, right truncated."
    What does this error means.The set of query I am running for insertion is same for 32bit(Windows 2003 Server) and 64bit (Windows 2008 Server R2).
    In case of the former this works perfectly without any error but in case of 64bit I am getting the above issue.Any suggestion would be of great help and what is the workaround for this.
    When I am inserting data of blob type I am getting data and grabage value also.
    From the backend when I am using plsql and querying on that paritcular table from the 2nd row onwards I am getting garbage value apended with the string.How I see the garbage is when I click on the blob data under the plsql respective table it takes me to string by default for all the columns containing blob and from 2nd column onwards I get the garbage appended with the string.
    This garbage value is not present in the 1st row at all but it from the 2nd row it comes.
    desc of the particular table I am talking about is
    SQL> desc Table_1084;
    Name Null? Type
    BBID NOT NULL NUMBER
    KEYORDER NOT NULL NUMBER
    KEYLENGTH NOT NULL NUMBER
    DTTM_DOM NOT NULL NUMBER(2)
    KEYVALUE BLOB
    2ndly I tried to remove the garbage using memset.This time there is no garbage but from the 2nd row onwards when I click on the blob from the plsql backend
    I did memset for deleting the garbage.But then after 2nd column onwards when I click on the blob it takes me hex by default not to text.When I come to text I don't see any garbage.
    In both the cases I get the above error when I try to retrieve the above information from the DB.
    The same set of query runs well when I use Windows 32bit but I am getting issue when I am using Windows 2008 Server 64bit.
    Below I have given the code snipet any thoughts or inputs would be very much appreciated.
    SQLLEN lsqlkeyElementIDLengths = *(this->keyElementIDLengths);
    SQLBindParameter(this->statement,1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementBlackBoxIDs, 0, &lsqlkeyElementIDLengths);
    SQLLEN lsqlkeyElementOrderLengths = *(this->keyElementOrderLengths);
    SQLBindParameter(this->statement,2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementOrders, 0, &lsqlkeyElementOrderLengths);
    SQLLEN lsqlkeyElementLengthLengths = *(this->keyElementLengthLengths);
    SQLBindParameter(this->statement,3, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
    0, 0, this->keyElementLengths, 0, &lsqlkeyElementLengthLengths);
    SQLLEN lsqlkeyElementValueLengths = *(this->keyElementValueLengths);
    SQLBindParameter(this->statement,4, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY,
    elementSize, 0, this->keyElementValues,
    elementSize, &lsqlkeyElementValueLengths);
    SQLExecDirect(this->statement, (unsigned char*) insertcommand, SQL_NTS);
    Here the this->keyElementValues is of void pointer.
    When I query on the back ground I get the below garbage value
    ntdll.dll!KiFastSystemCallRet 0x7c8285ec
    kernel32.dll + 0x24ed (0x77e424ed)
    termite.exe!CTermiteDlg::TestRegisterMemoryProc 0x004050ed c:\cm\build\public\tkbkwincln.10-01-06\talkback\src\client\termite\win32\termdlg.cpp, line 460Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾Þï¾
    Let me know if I can provide more information.
    Thanks,
    -R

  • "[Oracle][ODBC]Restricted data type attribute violation

    Hi,
    I have a program that use the database object,TQuery in Borland C++ Builder 5 to access information on an Oracle8i table. The program was working fine until I updated the Oracle8i ODBC driver from 8.1.5 to 8.1.6.
    I am getting the error :
    "[Oracle][ODBC]Restricted data type attribute violation."
    I can't see what I have done wrong with the SQL statement in the query as it is only a select * from table statement. Can anyone help me with this ? Thank in advance.
    C.M.

    I think I had found what is causing the problem. It looks like the latest Oracle ODBC driver doesn't like any table that
    consists of any 2 fields of type NUMBER but with 1 of them having
    NOT NULL. >example : >Name Null? Type>-------- --------
    ----------------- NO1 NUMBER>NO2 NOT NULL NUMBER>I think this is
    a bug. >null
    I am not sure what you mean by the statement
    "the latest Oracle ODBC driver doesn't like any table that
    consists of any 2 fields of type NUMBER but with 1 of them having
    NOT NULL"
    Do you mean there cannot be two not null number columns in a
    table witht he latest Oracle ODBC driver.
    I am running into the same problem as you did. I am getting a
    restricted type violation, and have isolated the column and it is
    a number(x,y). I have the the Oracle Client 8.01.06.00 driver
    and I have PowerBuilder8.0 as the GUI.
    Any help would be much appreciated,
    Thanks in advance,
    Khanh

  • Oracle ODBC Connection: TNS Problem?

    Hello!
    I'm trying to connect to a Oracle Database from a 64bit Linux machine.
    I'm using instantclient 10.2.0.4 64bit and oracle odbc driver.
    Here are all files and env variables, i created:
    ODBCINST.INI
    [Oracle]
    Description = Oracle Driver
    Driver = /usr/lib/libsqora.so.10.1
    UsageCount = 2
    ODBC.INI
    [DS1]
    Description = DS1
    Driver = Oracle
    Trace = Yes
    TraceFile = sql.log
    Database = //111.11.11.111:1111/db1
    User = user
    Password = pass
    LD_LIBRARY_PATH = :/usr/lib/oracle/10.2.0.4/client64/lib
    SQLPATH = /usr/lib/oracle/10.2.0.4/client64/bin
    I also had edited the SQLConnect.c and isql.c: http://sourceforge.net/tracker/?func=detail&aid=2260937&group_id=1544&atid=351544
    If i'm tring to connect to the database ( isql -v DS1 user pass ), i'm getting this error message:
    [S1000][unixODBC][Oracle][ODBC][Ora]ORA-12162: TNS:net service name is incorrectly specified
    I found a nice work-around for this problem:
    export TWO_TASK=//111.11.11.111:1111/db1
    After this change, i can connect to the database...
    But this means, all oracle connections are trying to connect to THIS server, right? But i need more then one server possibility...
    Any ideas?
    Thanks, mdo.

    Hello
    I have found the resolution to the problem , and below is the details if required by any one .
    Thanks
    Harshad
    1. Using MS Access, follow the process to link tables from the Oracle
    database using the user account you wish to restrict, until the list of
    attachable objects is shown.
    2. Note the tables that appear in the list. You should see a long list of
    tables owned by multiple schema owners.
    3. Without linking any tables, close the Link Tables dialog box.
    4. Create an ALL_OBJECTS view and ALL_SYNONYMS view in the user's schema in
    which you used to log into the database.
    For example:
    CREATE OR REPLACE VIEW SCOTT.ALL_OBJECTS AS
    SELECT * FROM SYS.ALL_OBJECTS
    WHERE OWNER IN ('SCOTT');
    CREATE OR REPLACE VIEW SCOTT.ALL_SYNONYMS AS
    SELECT * FROM SYS.ALL_SYNONYMS
    WHERE OWNER IN ('SCOTT');
    5. Using MS Access, again follow the process to link tables from the Oracle
    database using the user account from above to log in.
    6. Note the tables that show up in the list. The only tables listed should
    be those owned by the schema owner specified by the views, if the example
    statement above is used.
    --NOTE that this technique has the limitation that only objects actually
    owned by the view user will be viewable. For example, if the user has
    a synonym that points to an object in another user's schema, it will not
    be visible

Maybe you are looking for

  • How do i change default printer settings

    Hi I have an Epson Photo PX720WD. When I print photos directly from Finder they always print on the A4 plain paper I have in the tray rather than the 6 x 4 photo paper I want them to. The print option in Finder doesn't give me any opportuntiy to sele

  • Quick time will not install/unistall windows vista fatal error

    I am unable to install, unistall, or repair quicktime on my computer with vista. Before fatal error I see install has insufficient privileges to modify this file: C:\Program Files\Quick Time\Quick Time Read Me.htm Any suggestions for removing this so

  • Clearing all songs/data from Ipod

    Hello Is there an easy way to clear an Ipod Nano so that is has nothing on it - I bought one off of Craigs list that I want to give to someone but it still has some songs on there from the previous person. Is there a way to just 'clear' everything of

  • Mac App Store Stuck - Cannot Sign In

    Hello, I've recently upgraded my Mac OS X from 10.6.2 to 10.6.6 . Now the App Store is installed and shown in my dock , but I can't use it because it cannot connect to iTunes Store . When I open the Mac App Store , "Connecting to iTunes Store ..." ap

  • Ibot unable to open in OBIEE 10g

        Hi All, I have encountered an strange issue with iBots, in which when i click on any saved ibot to view or to modify, iBot did not open in webpage. Its keep on waiting to open but did not open even after 2 hrs. This happens also when i try to cre