Solved

ODP.NET Default Column Values

Posted on 2014-11-17
3
200 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
Comment Utility
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
Comment Utility
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
Comment Utility
I included the information on how the problem was actually solved.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

772 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

14 Experts available now in Live!

Get 1:1 Help Now