Solved

ODP.NET Default Column Values

Posted on 2014-11-17
3
206 Views
Last Modified: 2014-11-23
We are trying to migrate from System.Data.OracleClient to the Managed ODP.NET (4.121.1.20131211) data provider.  The main issue that we are having at the moment is we are unable to load the default column values from the database.  With System.Data.OracleClient this happened when calling OracleDataAdapter.FillSchema().  Unfortunately, it doesn't appear that Oracle implemented the logic the same as Microsoft and I can find much information on possible workarounds.

For my purposes I believe that if I manually set the default value on the column that my problem will be solved.  I was considering running the following schema query:

SELECT TABLE_NAME, COLUMN_NAME, DATA_DEFAULT
FROM USER_TAB_COLUMNS 
WHERE data_default IS NOT NULL AND TABLE_NAME = 'MY_TABLE'

Open in new window


My issue is that I am not sure how I can easily take the value that I get from the query and convert it to the value that should be used to set the default column value in all cases.  Can anyone help point me in the right direction?
0
Comment
Question by:kmcbrearty
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Michael74
ID: 40448492
Just a thought as no one else has jumped in but I have seen this solution where the error is not all variables bound.

You Can Solve Your Problem by calling Stored Procedures this way... "begin yourStoredProce(param);end;"
NOTE:  COMMAND TYPE IS TEXT NOT STORED pROCEDURE
OracleCommand cmd = new OracleCommand("begin U_50004REG_REPORTS.USRUNI114(2612);end;", this.conn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();

Hope this helps
0
 
LVL 3

Accepted Solution

by:
kmcbrearty earned 0 total points
ID: 40450349
I was able to workaround the issue by redefining the update and insert queries on the DataAdapter to only include the columns that exist in the DataTable.  By not including the values in the queries it allows the database to handle the default values.  I am not sure that this is entirely consistent with the way that the System.Data.OracleClient classes worked but it should solve my problem.
0
 
LVL 3

Author Closing Comment

by:kmcbrearty
ID: 40460453
I included the information on how the problem was actually solved.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now