Tag: oracle

如何连接到远程Oracle数据库

我必须连接到远程Oracle DBMS到我的.NET C#Web服务 请求客户端Oracle安装? 为什么? 当你必须使用ODP.NET时 谢谢

如何使用C#更快地从Oracle向Elasticsearch表中插入400万条记录?

我有以下用C#编写的代码,但据此,将数据从Oracle数据库迁移到Elasticsearch需要4-5天。 我是以100个批次插入记录。还有其他方式可以更快地移动400万条记录(如果可能的话,可能在不到一天的时间内)吗? public static void Selection() { for(int i = 1; i < 4000000; i += 1000) { for(int j = i; j < (i+1000); j += 100) { OracleCommand cmd = new OracleCommand(BuildQuery(j), oracle_connection); OracleDataReader reader = cmd.ExecuteReader(); List list=CreateRecordList(reader); insert(list); } } } private static List CreateRecordList(OracleDataReader reader) { List l = new […]

当DbDataAdapter.Update调用时,为什么我使用ODP.NET OracleDataAdapter获取OracleTruncateException而不使用System.Data.OracleClient的适配器?

我做了以下事情: protected int CreateComponent(DbConnection cnctn, string tableName) { int newId; DbCommand selectCmd = _provFactory.CreateCommand(); selectCmd.Connection = cnctn; selectCmd.CommandText = string.Format( “SELECT * FROM {0} WHERE ID = (SELECT MAX(ID) FROM {0})”, tableName); DbDataAdapter dataAdapter = _provFactory.CreateDataAdapter(); dataAdapter.SelectCommand = selectCmd; … // create Insert/Update/Delete commands with a builder for the data adapter … dataAdapter.Fill(_dataSet, tableName); newId […]

从LINQpad迁移到适当的Visual Studio项目?

我正在学习LINQpad中的LINQ to SQL并且它很棒,但是我不太了解它下面有很多魔法。 我使用可以在LINQpad中下载的可选IQ驱动程序连接到Oracle数据库。 我有我的查询工作,现在我需要将它移动到Visual Studio中的新项目。 是否可以在Visual Studio的解决方案中使用IQ? 我似乎无法找到有关在LINQpad之外使用它的任何信息。 我试图使用DbLinq的DbMetal工具来生成正确的连接类,但是我的模式中的某些东西正在以一种不适用于IQ的方式阻塞该工具。 可以以某种方式导出生成的LINQpad代码吗? 生成的Oracle连接代码在LINQpad中完美运行 – 有没有办法只重用生成的代码?

如何在没有公共构造函数的情况下模拟/伪造/存根密封OracleException?

在我的测试中,我需要测试抛出OracleException时会发生什么(由于存储过程失败)。 我正在尝试设置Rhino Mocks Expect.Call(….).Throw(new OracleException()); 无论出于何种原因,OracleException似乎都没有公共构造函数。 我该怎么做才能测试这个? 编辑:这正是我想要实例化的内容: public sealed class OracleException : DbException { private OracleException(string message, int code) { …} }

在oracle中防止SQL注入

首先我尝试使用以下代码 strQuery = @”SELECT PASSWORD FROM IBK_USERS where upper(user_id) =upper(‘” + UserPrefix + “‘)”; try { ocommand = new OracleCommand(); if (db.GetConnection().State == ConnectionState.Open) { ocommand.CommandText = strQuery; ocommand.Connection = db.GetConnection(); odatareader = ocommand.ExecuteReader(); odatareader.Read(); 最后我转换了上面的查询,以防止像这样的SQL注入 strQuery = @”SELECT PASSWORD FROM IBK_USERS where upper(user_id) =upper(:UserPrefix)”; try { ocommand = new OracleCommand(); if (db.GetConnection().State == ConnectionState.Open) […]

查询时的LINQ大小写

我在Oracle SQL语法中有一个如下所示的SQL查询,我想在LINQ中使用它。 Select Case When tbl.Id=1 then 1 else NULL End as col1, Case When tbl.Id=2 then 2 else NULL End as col2, Case When tbl.Id=3 then 3 else NULL End as col3 From Table1 tbl

ORA-22054下溢错误

我试图让我的存储过程在Oracle中工作,并且我遇到了一个下溢错误。 我试图从六个不同的表中删除相关信息。 我可以在SQL Developer中单独运行delete语句而不会出错。 当我尝试从我的C#代码隐藏中运行该过程时,我得到一个带有下溢错误的exception。 有什么建议? 这是代码: Procedure DeleteProf(i_prof_sk IN NUMBER) IS BEGIN delete from nt_fac where nt_per_sk in (select nt_per_sk from nt_per where nt_prof_sk=i_prof_sk); delete from nt_per_fact where nt_per_sk in (select nt_per_sk from nt_per where nt_prof_sk=i_prof_sk); delete from nt_per where nt_per_sk in (select nt_per_sk from nt_per where nt_prof_sk=i_prof_sk); delete from nt_prof_case where nt_prof_sk=i_prof_sk; delete […]

选择未锁定的行oracle

我在C#中有一个使用Oracle数据库的应用程序。 我需要一个查询来从oracle数据库中的表中获取未锁定的行。 如何选择所有未锁定的行? 是否有任何“翻译器”可以将此T-SQL(MS SQL Server)查询转换为Oracle方言? SELECT TOP 1 * FROM TableXY WITH(UPDLOCK, READPAST); 我对Oracle缺乏这样的function感到有些失望。 他们想让我使用AQ或者什么?

使用oracle 12c更改通知问题

OracleCommand cmd = new OracleCommand(“select * from Test WHERE TestFLAG = 1 or TestFLAGis not null”, con); 当表格发生变化时,无论条件是什么,我的.net项目仍会收到通知。 对于第二个问题,在我第一次收到任何通知后,表格上的任何更改都没有得到通知。 为什么? 解决我的问题的任何方法? public class MyNotificationSample { static string constr = “your db INFO”; public static bool IsNotified = false; static OracleDependency dep = null; public static void Main(string[] args) { //To Run this sample, make sure […]