ORA-01461: can bind a LONG value only for insert into a LONG column via Access - oracle

I am trying to run the below query in Access on a Oracle database :-
UPDATE tblQuotesNew SET tblQuotesNew.Quote_Status = 'Expired'
WHERE tblQuotesNew.Quote_Status='In Progress' AND tblQuotesNew.Date_Quote_Sent<DateAdd('m',-1,Date())
The data type of Quote_Status is VARCHAR2 size 255. The data type of Date_Quote_Sent is Date.
I am connecting to the Oracle database using the code below :-
Dim mydb As DAO.Database
Dim myq As DAO.QueryDef
connectstring = "ODBC;DSN=Comsales;UID=Comsales;PWD=******;SERVER=PDBREPT"
sqltext = "UPDATE tblQuotesNew SET tblQuotesNew.Quote_Status = 'Expired' WHERE tblQuotesNew.Quote_Status='In Progress' AND tblQuotesNew.Date_Quote_Sent<DateAdd('m',-1,Date());"
myq.ReturnsRecords = False
myq.Connect = connectstring
myq.SQL = sqltext
myq.Execute
myq.Close
When I run this query I get a ORA-01461: can bind a LONG value only for insert into a LONG column error.

You're running an Access query (using Access SQL functions) as a Pass-Through query (by setting connectstring = "ODBC;...).
This won't work. Either use Oracle syntax in a Pass-Through query, or Access syntax in a "regular" Access query.
For the latter, tblQuotesNew must be a linked table, and the query connect string must be empty.

Related

Oracle not using index, Entity Framework & Devart DotConnect for oracle

The table in question has ~30mio records. Using Entity Framework I write a LINQ Query like this:
dbContext.MyTable.FirstOrDefault(t => t.Col3 == "BQJCRHHNABKAKU-KBQPJGBKSA-N");
Devart DotConnect for Oracle generates this:
SELECT
Extent1.COL1,
Extent1.COL2,
Extent1.COL3
FROM MY_TABLE Extent1
WHERE (Extent1.COL3 = :p__linq__0) OR ((Extent1.COL3 IS NULL) AND (:p__linq__0 IS NULL))
FETCH FIRST 1 ROWS ONLY
The query takes about four minutes, obviously a full table scan.
However, handcrafting this SQL:
SELECT
Extent1.COL1,
Extent1.COL2,
Extent1.COL3
FROM MY_TABLE Extent1
WHERE Extent1.COL3 = :p__linq__0
FETCH FIRST 1 ROWS ONLY
returns the expected match in 200ms.
Question: Why is it so? I would expect the query optimizer to note that the right part is false if the parameter is not null, so why doesn't the first query hit the index?
Please set UseCSharpNullComparisonBehavior=false explicitly:
var config = Devart.Data.Oracle.Entity.Configuration.OracleEntityProviderConfig.Instance;
config.QueryOptions.UseCSharpNullComparisonBehavior = false;
If this doesn't help, send us a small test project with the corresponding DDL script so that we can investigate the issue.

VB6 insert into table from Recordset

There are one view and one table
both has truly the same columns
but they are in diffrent servers
what I want to do is like below
cn1.ConnectionString = "Server1"
cn2.ConnectionString = "Server2"
sql = "SELECT * FROM VIEW"
Set rs.1ActiveConnection = cn1
rs1.Open sql, cn1
sql = "INSERT INTO table SELECT * FROM view"
cn2.Execute (sql)
I can access to view by cn1, but table by cn2
So this cant be done
I want to know how can it be done
table and view are exactly same
I searched a lot, but there was no good examples for me
I think there are two ways of doing it
inserting recordset into table or inserting each of field to another
easy example would be very helpful thank you
This won't work because, even though you are pulling the records from your first server into your recordset, you are trying to insert directly from the view, rather than inserting from the recordset.
You can loop through your recordset, and insert the records one by one into the other database, but that's a lot of round trips and is very slow. A better way is use UpdateBatch to insert from the recordset all in one go. Here's the basic idea:
cn1.ConnectionString = "Server1"
cn2.ConnectionString = "Server2"
sql = "SELECT * FROM VIEW"
Set rs.ActiveConnection = cn1
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient 'you need a client-side recordset
rs1.Open sql, cn1, adLockBatchOptimistic 'you need to set the locktype to this
Set rs.ActiveConnection = cn2 'now you're connecting your recordset to the other server
rs.UpdateBatch 'and updating the database all in one batch
That should get you started.

Query results in Oracle SQL Developer are different to those using .Net ODP

I have this query:
SELECT
case
when
AddressType IN (select code.codeid from code where code.codeset = AddressTypeCodeSet and code.description like 'Postal%')
then 'PostalAddress'
when
AddressType IN (select code.codeid from code where code.codeset = AddressTypeCodeSet and code.description like 'Email%')
then
'EmailAddress'
else
'OtherAddress'
end as AddressType
FROM VW_Address
WHERE AddressId=190000;
When I execute this query using SQL Developer, the result returned is OtherAddress. This is what I'm expecting. However, when I execute the same query via this code:
Dim cmd =
New Oracle.DataAccess.Client.OracleCommand(["SQL HERE]")
cmd.Parameters.Add(":p0", OracleDbType.Int32)
cmd.Parameters(0).Value = 190000
cmd.BindByName = True
Dim r = cmd.ExecuteReader()
I get a different result: EmailAddress
ODP is version 2.111.7.20, Oracle is 11g.

Why a select query is running slower in Oracle than sql server

I am reading data from Oracle database by using ODP.Net with the follwing code
OracleConnection con = new OracleConnection(connectionString);
OracleCommand cmd = new OracleCommand( SELECT ID,RECORD(XMLType) FROM tbl_Name, con);
con.Open();
OracleDataReader _dataReader = cmd.ExecuteReader();
while (_dataReader.Read())
{
string rowId = _dataReader[0].ToString();
string xmlString = _dataReader[1].ToString();
adding this data into Queue for further processing
}
It working fine but in a minute it's reading only 10000 record. If I use SqlServer database it's reading 500000 record in minute having table with same schema.
Please help me if I am missing something to read data faster using ODP.NET
Thank you.
**
ANSWER:
**
I have tried with GetClobVal() and GetString Val() functions, now it is working fine.
select t.RECID, t.XMLRECORD.GetClobVal() from tableName t"
select x.RECID,x.XMLRECORD.getStringVal() from tableName x"
If we use these queries with oracle command it will run fast, but not as fast as sql server query.

Update value from a select statement

I'm using an Access over Oracle database system (Basically using Access for the forms and getting into the tables using ADO code) and am trying to update a field in the product table with the value of the same named field in a load table.
The code I am using is:
.CommandText = "UPDATE " & strSchema & ".TBL_CAPITAL_MGMT_PRODUCT a INNER JOIN " & strSchema & ".TBL_CAPITAL_MGMT_TEMP_LOAD b ON a.AR_ID = b.AR_ID SET a.TOT_RWA_AMT = b.TOT_RWA_AMT;"
Which returns an error about missing SET keyword.. So I changed it to:
.CommandText = "UPDATE (SELECT a.TOT_RWA_AMT, b.TOT_RWA_AMT As New_RWA_AMT FROM " & strSchema & ".TBL_CAPITAL_MGMT_TEMP_LOAD a INNER JOIN " & strSchema & ".TBL_CAPITAL_MGMT_PRODUCT b ON b.AR_ID = a.AR_ID Where a.New_Rec <> '-1' AND a.IP_ID Is Not Null) c SET c.New_RWA_AMT = c.TOT_RWA_AMT;"
Which returns an error about non key-preserved table. the b table has a pk of AR_ID but the a table has no primary key and it probably won't be getting one, I can't update the structure of any of the tables.
I tried using the /*+ BYPASS_UJVC */ which lets the code run, but doesn't actually seem to do anything.
Anyone got any ideas where I should go from here?
Thanks
Alex
Ignoring the irrelevant ADO code, the update you are trying to do is:
UPDATE TBL_CAPITAL_MGMT_PRODUCT a
INNER JOIN
SET a.TOT_RWA_AMT = b.TOT_RWA_AMT;
This isn't supported by Oracle (though maybe this undocumented BYPASS_UJVC hint is supposed to overcome that, but I wasn't aware of it till now).
Given that your inline view version fails due to lack of constraints you may have to fall back on the traditional Oracle approach using correlated subqueries:
UPDATE TBL_CAPITAL_MGMT_PRODUCT a
SET a.TOT_RWA_AMT = (SELECT b.TOT_RWA_AMT
FROM TBL_CAPITAL_MGMT_TEMP_LOAD b
WHERE a.AR_ID = b.AR_ID
)
WHERE EXISTS (SELECT NULL
FROM TBL_CAPITAL_MGMT_TEMP_LOAD b
WHERE a.AR_ID = b.AR_ID
);
The final WHERE clause is to prevent TOT_RWA_AMT being set to NULL on any "a" rows that don't have a matching "b" row. If you know that can never happen you can remove the WHERE clause.
If you're using Oracle 10g or higher, an alternative to Tony's solution would be to use a MERGE statement with only a MATCHED clause.
MERGE INTO TBL_CAPITAL_MGMT_PRODUCT a
USING TBL_CAPITAL_MGMT_TEMP_LOAD b
ON (a.AR_ID = b.AR_ID)
WHEN MATCHED THEN
UPDATE SET a.TOT_RWA_AMT = b.TOT_RWA_AMT;

Resources