Oracle ODBC can't update
Hello
I can connect to a Oracle 10g release 2 server using instant client. I can execute a select query without any problems, but when I try to update a table, my program crashes.
For example,
SELECT * FROM table WHERE col1 = 'value'; works fine.
UPDATE table SET col2 = 'value' WHERE col1 = 'val'; does not work
Is this a known limitation with instant client, or is there a problem with my installation?
Thanks in advance for your help.
What sort of program are you using to establish the connection?
I assume the user you're connecting with has been granted the UPDATE privileges on the table?
Similar Messages
-
Useing a Idoc an Oracle database Can be update useing JDBC Adapter
Hi Guys,
Can you help me on the above topic..
Regd's
RajHi Raj,
You can use the Idoc Adapter on the sender side and JDBC on the reciever side. After you have configured your scenario, you should be able to write data into the oracle database.
For the strucutre of your Datatype for insertion , just check this link,
http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
To access any Database from XI, you will have to install the corresponding Driver on your XI server.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10
Or on the JDBC end you can write a stored procedure to make your data update more efficient.
Go through this blog for stored procedures.
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
I hope this helps.
Regards,
Abhy -
How to detect which Oracle ODBC Driver is installed using VBA Excel
Hi,
I have an excel workbook containing database queries that uses an oracle ODBC driver to update data. However different machines have different versions of the ODBC drivers installed and so although the code works on my machine, it doesn't on others because the ODBC connection reference is different.
So as a first step, I would like Excel to automatically find what ODBC drivers are installed when the macro is run so that I could dynamically change the ODBC connection reference depending on what drivers are installed.
The connection strings relating to ODBC drivers are in following formats:
Machine A: "ODBC;DRIVER={Oracle OraDb11g_home1}
Machine B: "ODBC;DRIVER={Oracle in instantclient11_1}
ETC
All machine run windows XP.
Alternatively would there be an easier way to connect to a shared orcale database without the need of installing any additional drivers?
Thanks,
LucasProblem with Excel & ODBC drivers really has NOTHING to do with Oracle RDBMS.
I suggest you tag your post as "Off Topic" & post it in some Excel forum instead. -
UPDATE problem - [Oracle][ODBC][Ora]ORA-01456
I try to UPDATE a table using following driver, url and syntax :
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // load driver
Connection conn = DriverManager.getConnection("jdbc:odbc:JDEV", "salgsinfo", "si"); // get connection
but receives this answer :
java.sql.SQLException: [Oracle][ODBC][Ora]ORA-01456: INSERT-, DELETE- or UPDATE-statements cannot be done in READ ONLY-transaction
the user is granted dba priviliges, what can i do ?
NielsORA-01456:may not perform insert/delete/update operation inside a READONLY transaction
Cause:A non-DDL INSERT/DELETE/UPDATE or SELECT FOR UPDATE operation was attempted.
Action:Commit or roll back the current transaction, then retry the operation. -
How can I do to get Oracle ODBC driver in Windows?
Hello,
Please, I need help to use Oracle ODBC driver in Windows 7. I installed Oracle Client 10g with the ODBC driver, but I can't use it. OracleODBC driver don't appear in the driver list when I want to create a new datasource. How I can do to get Oracle ODBC driver for create a new datasource?
Thank
Edited by: user4528703 on 13 mars 2010 02:01Hello,
To get the ODBC driver you should run a custom Oracle Client installation and Select
Oracle Windows Interfaces 10.2.0.1.0.
Then, you'll get the Oracle ODBC Driver 10.2.0.1.
But, be aware that Oracle didn't certify Windows 7.
So, if afterwards, you experience some trouble, think to install Oracle with Xp compatibilty mode, or
wait to Oracle 11.2.0.1 which will be certified on Windows 7.
Hope this help.
Best regards,
Jean-Valentin -
Can we update oracle standard table Attributes column by custom trigger?
Can we update the oracle Standard table's Attributes column using custom trigger? Is it allowed by oracle? Is this supported?
ThanksATTRIBUTE columns store DFF information and therefore custom code can be used to update their contents. Care must be taken that such updates do not cause "logical" corruption (an ATTRIBUTE column may be designed to store the color of a product, for example, but an incorrect SQL statement can update the value to a numeric one, thus causing corruption - Oracle does not have a means to check the validity of these update statements). Also, some localizations, such as Brazil and India, reserve some ATTRIBUTE columns for their use - updating such columns is not supported. More information may be found in the Flexfields Guide for your release at http://www.oracle.com/technology/documentation/applications.html
HTH
Srini -
Can not see Oracle ODBC driver in Ms SQL Server 2007
Hi
I am trying to export an ms sql server table to Oracle using the Ms SQL Server 2007 export wizard and the only driver I found in the list is Microsoft OLEDB Provider for Oracle.
I already installed Oracle client and I addedd an ODBC conenction of the datasources Why can I not see the Oracle ODBC driver?Which version of Oracle and what kind of Client Install
Are you sure you did the full Client Install which will have ODBC ?
Execute odbcad32 and look under Drivers Tab for Oracle ODBC Driver -
In Oracle Service - Version: 11.5.9 How can I Update the owner of a SR to N
Hi,
I´m using cs_servicerequest_pub.update_servicerequest and it works ok, but when I set the owner_id to NULL I get an API error.
Anyone knows how to set the owner of a SR to NULL thru this API?
ThanksHi,
Yes in 11.5.9 is mandatory too, but from Oracle Support Application it´s possible to set the OWNER_ID of a incident to NULL so we got incidents with this field set to NULL.
The problem is that we can´t update this incidents without setting the owner_id to a 'valid' owner. (In this case it works)
I have searched about this in metalink but I got no solution to this isssue...
It´s another method to achieve this than using this procedure?
Regards -
I have installed Oracle XE database v10.2.0.1.0 As far as I know there is a version
v10.2.0.4.0 out there.
How can I update an existing Oracle XE installation?
I found no patch for this.
Peteruser559463 wrote:
I have installed Oracle XE database v10.2.0.1.0 As far as I know there is a version
v10.2.0.4.0 out there.
How can I update an existing Oracle XE installation?You might want to go back and read the license agreement that you accepted when you got Express Edition. That spells it out.
In a nutshell - you can now purchase one of the 'full' editions (SE1 is least expensive), migrate to that, purchase support, get and apply the patch.
Also see the "Oracle Database Express Edition Upgrade Guide 10g Release 2" document in the sidebar at http://www.oracle.com/technology/products/database/xe/index.html -
Hi,
I have installed Oracle 11g database.
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
I want to update the patch.
Oracle 11g database can we update patch directly from 11.2.0.3.0 to 11.2.0.4.0?
Is any impact on the database?
Kindly suggest,
Regards,
Sachin11.2.0.4 is nothing but a patchset of 11.2.0.3, in-place upgrade is allowed :
http://docs.oracle.com/cd/E11882_01/server.112/e23633/preup.htm#UPGRD12370
"You cannot install the new software into the same location for Oracle home as your current release, unless you are installing an Oracle Database 11g patchset release. For a patchset release, you can use the same Oracle Database 11g Oracle home."
And since it's a patchset, a direct upgrade is ok.
Lastly, yes, every upgrade has an impact (e.g. perf.), it has to be tested.
Nicolas. -
Oracle ODBC - Internal Error - unable to initialize NLS during driver load
I'm having some trouble with my ODBC connections which I hope someone can please help me with!
About 6 weeks ago all was working as normal.
As far as I know there have been no updates to the ORacle DB, the Windows XP operating system or the ODBC Drivers.
Today when I opened access and visual case 2 to connect to Oracle I was at first greeted with a:
unable to connect SQLState=IM004 SQL_HANDLE_ENV
error. ODBC also kept crashing.
I restarted the computer and was confronted with a different error:
odbc SQLSTate 08004 ORA 12154 TNS could not resolve the connect identifier specified
I was able to fix this error by setting the environment variable TNS_ADMIN in windows xp environment variables. I'm extremely confused about how this happened though as it was working and I don't think anything has changed.
I was then able to connect to the database via Microsoft Access but when I opened Visual Case 2 and tried to make an update, I was confronted with the following error:
Oracle ODBC Driver - internal error - unable to initialize NLS during driver load
I looked in the registry at:
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient10g_home1
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient10g_home2
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraDb10g_home1
and NLS_LANG was set to "AMERICAN_AMERICA.WE8MSWIN1252" in all 3 places.
(Though KEY_OraClient10g_home2 only had 4 entries as opposed to KEY_OraClient10g_home1's 13 entries)...
Since I made those changes I can no longer connect through Access.
I just receive a ODBC - connection to 'xxx' failed
Advice greatly appreciated!!!!
Edited by: user11150264 on Aug 25, 2009 10:21 PMActually it sort of does...
I switched the ODBC connection to use instant client and now it's all working again.
The biggest mystery is what changed to make it suddenly stop working the old way... -
MS ODBC or Oracle ODBC driver?
Can anyone tell me which is the correct driver to use when developing front end MS Access 2003 to retrieve and update data on a Open VMS platform with Oracle 8.1.7.3 database?
I have serval Access 2000 databases that run on most WinNT or W2K clients with a couple of W2K Dell exceptions. These Access 2000 db's connect to the Oracle database using linked tables and SQL pass-through queries that work with ODBC Manager-DNS system setup using the Microsoft for Oracle ODBC driver.
Now we are upgrading to Office Pro 2003 so new W2K images have been setup with Oracle 8.1.7 Client. SQL*Plus works on these clients but when I create the System DNS the Access databases return an error "ODBC connection failed". I can however connect with a pass-through query using Oracle's ODBC driver. Not enough time in roll-out plan to change the ODBC connection string in hundreds of Access SPT queries.
Please help!
Bonnieif you still need assistance reagarding this...email me directly..
shah
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. -
Oracle ODBC error when inserting "end" or "begin"
I think I may have found a bug in the Oracle ODBC driver....
I am using version 8.01.73.00 of the Oracle ODBC driver, and my VB application is trying to insert a record into a table using ADO. All works fine, until the user tries to enter the word "end", or "begin" into any of the text (CLOB) fields. The following code shows how I am doing an insert:
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = "DSN=Envoy;uid=Envoy;pwd=significance;"
cmd.CommandText = "Insert into Mon_Reading (Creation_User, Creation_Date, Reading_Date, Param_ID, Mon_ID, Value, ApplicableYN, Site_ID, Prev_MEter_Value, MeterResetYN, UOM_ID, LimitsApplicableYN, Lower, Upper, Limit_UOM_ID, ApprovedYN, Comments ) Values ('Matttt', '01-jan-2002', '01-jan-2003', 1, 1, 1., 'Y', 1, 0, 'N', 1, 'N', 0, 0, 0, 'Y', ' end ');"
cmd.CommandType = adCmdText
cmd.Execute , , adExecuteNoRecords
As you can see, the text " end " is being added to the comments field, a CLOB data field. When executed, this causes an Oracle ORA-0911 error (invalid character), and the insert fails.
Heres the weird thing - if you change the word "end" to anything else apart from "begin" - it will work!!! Also, it only fails if you wrap the "end" in spaces?!!?!! Users that reported this were entering comments like "this is the end of June" - this would have caused the error. If you copy teh failed SQL and paste it into SQLPlus, it executes OK.
I can only presume this is an Oracle bug. Anyone else have an ideas? What can I do as a workaround?First thought would be to grab the updated 8.1.7.x ODBC driver (8.1.7.7 IIRC). Perhaps this problem has already been solved.
Justin -
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 ShoultzWhen 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
Maybe you are looking for
-
Performance - composite index with 'OR' in 'WHERE' clause
I have a problem with the performance of the following query: select /*+ index_asc(omschact oma_index1) */ knr, projnr, actnr from omschact where ((knr = 100 and actnr > 30) or knr > 100) and rownum = 1; (rownum used only for test purpose) index: cre
-
I am running Windows 8, Itunes, and an Iphone 4 - all up to date software. When I connect my iphone to the computer, Windows makes the sound that says you've connected a device. After that, neither Windows nor Itunes recognizes the phone. When I go t
-
Stock transfer in quality certificate
Hi all, I have one question i have activated indicator stock transfer indicator " transfer posting and stock transfer order " I am transferinfg one batch from one plant A ( company codex) to another plant B ( company code Y) Now the ques
-
Today, i notice my aluminum ring on the headphone jack is missing. The question is, does this effect the phone waterproof capability?
-
Once i changed my adobe flash player website storage settings,and it's been resetting to none ALL the time..if i refreshed/opened it again,it gets reset instantly to none.,,I really can't seem to find a solution,How can i change my website storage se