Re: Item cannot be found in the collection corresponding to the requested name or ordinal.



anthonybrough@xxxxxxxxxxxxxx wrote:
I am trying to get a value from a RETURNING statement on an Oracle
database and write the result on the same ASP page, but I am getting
the error:

Error Type:
ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested
name or ordinal.
<<<>

This the code that I am using,

conn.beginTrans
sql = "INSERT INTO tbltest(REGID) Values (tbltest_SEQ.nextval )"
conn.execute SQL


sql = "Insert into tblreg_Account (REGID, Account1) Values
(tbltest_SEQ.currval, '" &strAccount &"')RETURNING REGID into
return_REGID "
set r = conn.execute (sql)
response.write r.fields("return_REGID").value

conn.commitTrans

If I leave out :

set r = conn.execute (sql)
response.write r.fields("return_REGID").value

the code executes no problem.

I would be grateful of any pointers in how to resolve.

I'm a little hesitant to reply, never having used Oracle, but in SQL Server,
RETURN values are returned via parameters, not via resultsets. I suspect
it's the same way with Oracle. In order to get the return parameter value,
you have to use a Command object. Try:

const adInteger=3
const adParamReturnValue=4
set cmd=createobject("adodb.command")
cmd.commandtext=sql
cmd.commandtype=1
set cmd.activeconnection=conn
cmd.parameters.append cmd.createparameter("Return", _
adInteger,adParamReturnValue)
cmd.execute
response.write cmd.parameters(0).value

The ADO documentation can be found here.
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoapireference.asp
You should look up the methods I used above to become familiar with them.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: Limit of 1050 columns for ANSI joins
    ... comprehensive than Oracle SQL. ... I'm trying not to have any auto-generated SQL on my system, ... Index your schema properly and think about the proper design. ...
    (comp.databases.oracle.server)
  • Re: I cant find a SETUP.EXE in the SQL Plus Client ??
    ... someone else's server for testing some SELECT statements I'm ... free client because I don't own the Oracle license. ... SQL statements. ... There is no documentation with that download. ...
    (comp.databases.oracle.tools)
  • Re: How to convince my customer to use SQL2005 instaed of Oracle10g
    ... the old Sql versus Oracle debate. ... If I were you I would focus one SQL Server 2005 clearest advantages ... You mentioned Availability, so I assume your looking into HA (high ...
    (microsoft.public.sqlserver)
  • Re: How to convince my customer to use SQL2005 instaed of Oracle10g
    ... migration to Sql 2005 would be direct & straight forward, quick, and ... If I were you I would focus one SQL Server 2005 clearest advantages ... would need a 4 processor license but for Oracle you would need a 16 ... You mentioned Availability, so I assume your looking into HA (high ...
    (microsoft.public.sqlserver)
  • Re: MS SQL Server - a plethora of limitations...
    ... > Most of your objections are that MS-SQL is not Oracle. ... according to the standards. ... > There is no such syntax or concept in Standard SQL. ... Partitioning shouldn't be done automatically by the DB, ...
    (microsoft.public.sqlserver.programming)