0

I use EF6.0 + Oracle 10g and code first approach.

In my migration there is such fragment of code:

Sql(@"
begin
    insert into t_new1 (p1, p2) 
       select p1, p2 from t_old1;

    insert into t_new2 (p1, p2) 
       select p1, p2 from t_old2;
...other DML operations.....
end;");

When I try to apply my migration using Update-Database, I get error which does not give any hints about true nature of a problem.

It looks like

Devart.Data.Oracle.OracleException (0x80004005): ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:

begin case declare exit for goto if loop mod null pragma raise return select update while with
close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe

I suspect that it's not allowed to use Begin-End blocks in DbMigration Sql function. But I can not state it for sure and would like to hear some advices about this situation.

As a workaround it's possible to create stored procedure, execute it and then drop. However it seems not enough elegant.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
DotNetter
  • 426
  • 2
  • 6
  • 19
  • can you run the commands somewhere else without errors? Can you isolate the command that is causing the exception? "other DML operations" is not very specific. – default Apr 02 '15 at 12:46
  • have you looked at [this](http://stackoverflow.com/questions/20334067/pls-00103-encountered-the-symbol-create)? i.e. is it the `;` character that should be a `/`? – default Apr 02 '15 at 12:49
  • I used `Update-Database -script` to generate plain Sql script. After that this script was run directly with SqlPlus. Everything works as supposed without errors and warnigs. – DotNetter Apr 02 '15 at 12:50
  • @Default Unfortunately, adding `/` in new line after `end;` had now effect. – DotNetter Apr 02 '15 at 13:03

0 Answers0