Oracle从.NET查询多个删除语句

时间:2013-11-21 13:10:49

标签: c# sql oracle odp.net odac

我在使用.NET(ODP)在Oracle中执行简单查询时遇到了问题:

        const string sql = @"
            delete from CLIENTS where CAMPAIGN_ID = :campaignId
            delete from OPERATORS where CAMPAIGN_ID = :campaignId
            delete from CAMPAIGNS_EXCLUDE_DAYS where CAMPAIGN_ID = :campaignId
            delete from CAMPAIGNS where ID = :campaignId";

        var p = new DynamicParameters();
        p.Add("campaignId", campaignId);

        Connection.Execute(sql, p);

我在那里使用Dapper作为轻量级ORM。甚至可能在不知道Dapper的情况下也很清楚。

这是一个例外:

ORA-00933: SQL command not properly ended

1 个答案:

答案 0 :(得分:1)

const string sql = @"
     delete from CLIENTS where CAMPAIGN_ID = @campaignId
     delete from OPERATORS where CAMPAIGN_ID = @campaignId
     delete from CAMPAIGNS_EXCLUDE_DAYS where CAMPAIGN_ID = @campaignId
     delete from CAMPAIGNS where ID = @campaignId";

var p = new { campaignId=campaignId };
Connection.Execute(sql, p);