Oracle: ODP.NET is the devil

Well, those were my words yesterday.
The errors Oracle was throwing up were:
ORA-06550: line X, column X: PLS-00224: object 'X' must be of type function or array to be used this way
and
ORA-06550: line X, column X: PLS-00382: expression is of wrong type
followed by
ORA-06550: line X, column X: PL/SQL: ORA-00904: : invalid identifier
No matter what I did I had these problems, these errors were just annoyingly vague and did not help at all, Oracle might as well have just said, “ERROR”.

I noticed if I had one too many parameters I got the error:
ORA-06550: line X, column X: PLS-00382: expression is of wrong type
which made no sense as they were all Varchar2 fields and the parameters were too (well, one was a PLSQLAssociativeArray).

Today I found out why I was getting such odd behaviour that I couldn’t for the life of me figure it out.
First port of call is to check your command is correct and you have the parameter names correct.
Secondly, are sure of that are you binding parameters in order or by name? The default is to bind by order (BindByName = false). This was my mistake and I needed to set:
cmd.BindByName = true;
where cmd is my OracleCommand object.

Best of luck and I hope I remember to read this post next time.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s