473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with update. getting ORA-01036: illegal variable name/number

Howdy,

Can someone tell me how im suppsoed to do this? Im new to this and im sure
im doing something stupid. Im trying to update a table. I have the sql
there, and i was able to update the table if i hardcoded everything, but i
would really like to use parameters. Here is my code.
thank you,
rodrigo
ro*************@dfps.state.tx.us
----------------

public void UpdateReportDetails(ReportDetailInfo reportDetailInfo)
{
OracleConnection dbConnection = null;
OracleCommand dbCommand = null;
OracleDataReader dbReader = null;
string UpdateString = "UPDATE REPORTS SET "
+ "TXT_RPT_FULL_NAME = @fullName "
+ "WHERE NM_RPT_SQR_NAME = 'ccf04o' "
+ " AND NM_RPT_SQR_VER = '00' " ;

dbConnection = new OracleConnection(connectionString);
dbCommand = new OracleCommand(UpdateString, dbConnection);
dbCommand.Parameters.Add(new OracleParameter("@fullName",
OracleType.VarChar,32));
dbCommand.Parameters["@fullName"].Value = reportDetailInfo.fullName;
try
{
dbConnection.Open();
dbCommand.Transaction = dbConnection.BeginTransaction();

OracleString rowid;
int rows = dbCommand.ExecuteOracleNonQuery(out rowid);
if (rows<=0)
{
throw new ApplicationException("Update for Template failed.");
}

dbCommand.Transaction.Commit();
dbCommand.Connection.Close();
dbConnection.Close();
}
catch (OracleException ex)
{
GetTemplateException te = new
GetTemplateException("ARC_DOCS_ERR_METADATA_ACCESS OR_DB_CONNECT", "A
metadata accessor could not establish a connection to the database.",
"UpdateFormTemplate", ex);
if (dbCommand != null)
dbCommand.Transaction.Rollback();
throw te;
}
catch (Exception ex)
{
if (dbCommand != null)
dbCommand.Transaction.Rollback();
throw ex;
}
finally
{
if (dbReader != null)
dbReader.Close();
if (dbConnection != null)
dbConnection.Close();
}
}
Nov 16 '05 #1
1 10242

"Rodrigo DeJuana" wrote...
Can someone tell me how im suppsoed to do this? string UpdateString = "UPDATE REPORTS SET "
+ "TXT_RPT_FULL_NAME = @fullName "
+ "WHERE NM_RPT_SQR_NAME = 'ccf04o' "
+ " AND NM_RPT_SQR_VER = '00' " ;


How to format the variablename in a commandstring for parameterization is
dependant on which provider you use.

AFAIK, SQL Server use the "@", while Oracle instead uses a ":", like:
string UpdateString = "UPDATE REPORTS SET "
+ "TXT_RPT_FULL_NAME = :fullName "
+ "WHERE NM_RPT_SQR_NAME = 'ccf04o' "
+ " AND NM_RPT_SQR_VER = '00' "

Furthermore, that symbol isn't a part of the actual name, but just a marker
for it, hence it shouldn't be used when you add the parameters.

dbCommand.Parameters.Add(
new OracleParameter("fullName",
OracleType.VarChar,32));

dbCommand.Parameters["fullName"].Value =
reportDetailInfo.fullName;

However, the behavior of parameter-settings is actually depending on which
DataProvider you're using, so I can't guarantee that these changes is
sufficient.

In some providers it's possible to use a simple question-mark as holder in
the commandstring (still depending on which provider you use):

string UpdateString = "UPDATE REPORTS SET "
+ "TXT_RPT_FULL_NAME = ? "
+ "WHERE NM_RPT_SQR_NAME = 'ccf04o' "
+ " AND NM_RPT_SQR_VER = '00' "

In this case (if it works with your dataprovider), you don't have any name
to connect the parameter to, but it's just as easy. If you have more than
one parameter, just add the parameters in the right order (which by the way
is recommended even if you're using named parameters).

OracleParameter par1 = new OracleParameter();
par1.OracleDbType = OracleType.VarChar;
par1.Size = 32;
par1.Value = reportDetailInfo.fullName;

dbCommand.Parameters.Add(par1);

However, I believe microsoft.public.dotnet.framework.adonet would be a more
appropriate group for this kind of questions, as it has more to do with
ADO.NET, than with C#.
// Bjorn A
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: simianphile | last post by:
OK, I had a problem that I've now fixed but I can't really understand what was causing it in the first place. I have an intranet site that uses basic authentication to allow users to view and...
7
by: NTidd | last post by:
Since we have upgraded to oracle 9i every day or so we have to go in and shutdown oracle and restart it, here is what we do: sqlplus /nolog connect sys as sysdba password: connected to an idle...
4
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline...
2
by: Cherrish Vaidiyan | last post by:
Hello all, A warm Xmas greetings to all. I have a small problem with starting up the database. Here my strategy. I have installed Oracle 9i R 2 on Red Hat 9. i created two database on this...
2
by: chets | last post by:
Hi All, I am facing problem in executing one dynamic query in PRO *C program on linux. I want to update table mytable by data MADURAI for a column mycolumn1 where primary key is myPK.I want to...
1
by: Reshmi Jacob | last post by:
Hello, Can any one help me in creating a trigger to update system date into a table while inserting a record into that table. I tried it like this, it is showing error !!! The following...
5
by: ravi | last post by:
Hello, I have the following piece of code in my server written in C++ (CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-12 2002/12/16) ProC++ (Pro*C/C++: Release 8.1.7.4.0) ...
1
by: Buckaroo Banzai | last post by:
Hi, I was wondering if it is possible to update two columns in two different tables. I'm creating a procedure, but it does not seems to work, and I cannot find any references which says that this...
1
by: =?Utf-8?B?U3VzYW4=?= | last post by:
The database team just patched the Oracle database with the latest and greatest security patch. Since they patched it, my application has not been stable. My application uses ODP 10.1.0.4 and C#....
3
by: darrenttl | last post by:
Hi, I am getting the following error: ORA-00604:error occurred at recursive sql level 1. ORA-06519:active automous transaction detected and rolled back. This error occurred when I was trying...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.