当前位置: 首页>>代码示例>>C#>>正文


C# OracleConnection.Execute方法代码示例

本文整理汇总了C#中System.Data.OracleClient.OracleConnection.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# OracleConnection.Execute方法的具体用法?C# OracleConnection.Execute怎么用?C# OracleConnection.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.OracleClient.OracleConnection的用法示例。


在下文中一共展示了OracleConnection.Execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetupOracle

 private static void SetupOracle()
 {
     using (var connection = new OracleConnection(String.Format("data source={0};password={1};user id={2}", "INSTANCE", "pass12!", "USER")))
     {
         connection.Open();
         try
         {
             connection.Execute(@"drop table users");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop SEQUENCE users_seq");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table car");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop SEQUENCE car_seq");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table bigcar");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop SEQUENCE bigcar_seq");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table city");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table GUIDTest");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table StrangeColumnNames");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop SEQUENCE StrangeColumnNames_seq");
         }
         catch (Exception)
         { }
         try
         {
             connection.Execute(@"drop table UserWithoutAutoIdentity");
         }
         catch (Exception)
         { }
     }
     using (var connection = new OracleConnection(String.Format("data source={0};password={1};user id={2}", "DEVELOPMENT", "umhk79J&U", "BOWDENJ")))
     {
         connection.Open();
         connection.Execute(@"CREATE TABLE Users (Id number(10), NAME NVARCHAR2(100) NOT NULL, Age INT NOT NULL, ScheduledDayOff NUMBER(10), CreatedDate DATE DEFAULT sysdate, CONSTRAINT USER_PK PRIMARY KEY (Id))");
         connection.Execute(@"CREATE SEQUENCE Users_seq START WITH     1 INCREMENT BY   1 NOCACHE NOCYCLE");
         connection.Execute(@"CREATE OR REPLACE TRIGGER USERS_INS_TRIG BEFORE INSERT ON Users FOR EACH ROW BEGIN IF :new.ID IS NULL THEN SELECT Users_seq.nextval INTO :new.ID FROM DUAL; END IF;  END;");
         connection.Execute(@"CREATE TABLE Car (CarId number(10), Id number(10), Make NVARCHAR2(100) NOT NULL, Model NVARCHAR2(100) NOT NULL, CONSTRAINT CAR_PK PRIMARY KEY (CARId))");
         connection.Execute(@"CREATE SEQUENCE Car_seq  START WITH     1 INCREMENT BY   1 NOCACHE NOCYCLE");
         connection.Execute(@"CREATE OR REPLACE TRIGGER CAR_INS_TRIG BEFORE INSERT ON CAR FOR EACH ROW BEGIN IF :new.CarId IS NULL THEN SELECT Car_seq.nextval INTO :new.CarId FROM DUAL;        END IF;  END;");
         connection.Execute(@"CREATE TABLE BigCar (CarId number(10), Make NVARCHAR2(100) NOT NULL, Model NVARCHAR2(100) NOT NULL, CONSTRAINT BIGCAR_PK PRIMARY KEY (CARId))");
         connection.Execute(@"CREATE SEQUENCE BigCar_seq  START WITH     2147483649 INCREMENT BY   1 NOCACHE NOCYCLE");
         connection.Execute(@"CREATE OR REPLACE TRIGGER BIGCAR_INS_TRIG BEFORE INSERT ON BIGCAR FOR EACH ROW BEGIN IF :new.CarId IS NULL THEN SELECT BigCar_seq.nextval INTO :new.CarId FROM DUAL;        END IF;  END;");
         connection.Execute(@"INSERT INTO BigCar (Make, Model) VALUES ('car', 'car')");
         connection.Execute(@"CREATE TABLE City (NAME NVARCHAR2(100) NOT NULL, Population number(10) NOT NULL)");
         connection.Execute(@"CREATE TABLE GUIDTest (Id char(38) default sys_guid(), NAME VARCHAR(50) NOT NULL, CONSTRAINT PK_GUIDTest PRIMARY KEY (Id))");
         connection.Execute(@"CREATE TABLE StrangeColumnNames (ItemId NUMBER(10), word NVARCHAR2(100) NOT NULL, colstringstrangeword NVARCHAR2(100) NOT NULL, CONSTRAINT StrangeColumnNames_PK PRIMARY KEY (ItemId) )");
         connection.Execute(@"CREATE SEQUENCE StrangeColumnNames_seq  START WITH     1 INCREMENT BY   1 NOCACHE NOCYCLE");
         connection.Execute(@"CREATE OR REPLACE TRIGGER SColNames_INS_TRIG BEFORE INSERT ON StrangeColumnNames FOR EACH ROW BEGIN IF :new.ItemId IS NULL THEN SELECT StrangeColumnNames_seq.nextval INTO :new.ItemId FROM DUAL;        END IF;  END;");
         connection.Execute(@"CREATE TABLE UserWithoutAutoIdentity (Id number(10), NAME NVARCHAR2(100) NOT NULL, Age number(10) NOT NULL,CONSTRAINT UserWithoutAutoIdentity_PK PRIMARY KEY (Id) )");
     }
 }
开发者ID:Boggin,项目名称:Dapper.SimpleCRUD,代码行数:93,代码来源:Program.cs


注:本文中的System.Data.OracleClient.OracleConnection.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。