ORA-00904 while using update

S

sjoshi

I'm trying to use this simple code to update an Oracle table and it
fails with this message:
Oracle.DataAccess.Client.OracleException : ORA-00904: "MINDEX":
invalid identifier

The Select command works fine.

OracleConnection con = new OracleConnection("Data
Source=SP3DSMP2;User Id=sys;Password=xxxx;DBA Privilege=SYSDBA;");
OracleDataAdapter adap = new OracleDataAdapter("Select
MODELINDEX, BSFILEPATH From ZGK037_MDB.COREPdsAttachFile", con);

adap.UpdateCommand = new OracleCommand("Update
ZGK037_MDB.COREPdsAttachFile Set BSFILEPATH=BPATH Where
MODELINDEX=MINDEX", con);

OracleParameter paramFPath =
adap.UpdateCommand.Parameters.Add("BPath", OracleDbType.NVarchar2,
ParameterDirection.Input);
OracleParameter paramMIndex =
adap.UpdateCommand.Parameters.Add("MIndex", OracleDbType.Decimal,
ParameterDirection.Input);

paramMIndex.SourceColumn = "MODELINDEX";
paramMIndex.SourceVersion = DataRowVersion.Original;

DataSet dSet = new DataSet();
adap.Fill(dSet, "RefFiles");
Console.Write(PrintTable(dSet.Tables[0]));
string newDir = @"\\sp3dsmp3\SymbolsShares
\Siemens_ZGK037_V7\DGN";

foreach (DataRow row in dSet.Tables[0].Rows)
{
string curPath = row["BSFILEPATH"].ToString();
try
{
//\\COCANETAPP4\Data\Suncor\CADD\Civil\LDD TO SP3D
\Microstation V7\LDD_108 test_DTM.dgn
int lastSlash = curPath.LastIndexOf(@"\");
string newFilename = Path.Combine(newDir,
curPath.Substring(lastSlash + 1));
row["BSFILEPATH"] = newFilename;
}
catch { }
}
Console.Write("Updated {0} records", adap.Update(dSet,
"RefFiles"));

thanks
Sunit
 
G

Guest

Sunit,

I believe that Oracle parameters in the SQL statement must be preceded by
the colon symbol:

adap.UpdateCommand = new OracleCommand("Update
ZGK037_MDB.COREPdsAttachFile Set BSFILEPATH = :BPATH Where
MODELINDEX = :MINDEX", con);

Kerry Moorman
 
Top