ORM Persistence: FireDacApdater Oracle database, Delphi XE7

Issue #84 resolved
Former user created an issue

``` #!delphi Hello, sorry for for non formated message preview

function TOracleSQLGenerator.GenerateCreateSequence(
  const command: TCreateSequenceCommand): string;
var
  LSequence: SequenceAttribute;
begin
  LSequence := command.Sequence;
  Result := 'BEGIN ';
  if command.SequenceExists then
    Result := Result + 'EXECUTE IMMEDIATE ' + QuotedStr(Format('DROP SEQUENCE "%0:S" ', [LSequence.SequenceName])) + ';';

//AL 18/02/2015
//  Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE',
//    [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment]));
  Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE',
    [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment])) + ';'; // <-- if i add this all work ok

  Result := Result + ' END;';
end;

1 - first time (no sequence in database): i create this sequence manualy and i get others error :

585928170887 14:01:11.639 8604 TFDPhysOracleCommand TFDQuery($05CC71D0) >> Execute [Command="BEGIN EXECUTE IMMEDIATE 'DROP SEQUENCE "SEQ_PUB_SUBCPTION" '; EXECUTE IMMEDIATE 'CREATE SEQUENCE "SEQ_PUB_SUBCPTION" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE' END; ", ATimes=0, AOffset=0] 585928170914 14:01:11.639 8604 TFDPhysOracleCommand TFDQuery($05CC71D0) . OCIStmtExecute [ARows=1, AOffset=0, AExact=False, ACommit=False] 585928182170 14:01:11.643 8604 <nil> . ORA-06550: Ligne 1, colonne 221 : PLS-00103: Symbole "END" rencontré à la place d'un des symboles suivants :

  • & = - + ; < / > at in is mod remainder not rem return returning <exposant (**)> <> or != or ~= >= <= <> and or like like2 like4 likec b [Lvl=1, ErrCode=6550]

2- If i add + ';' in the end of second command (Result := Result + ..) all work ok

Comments (11)

  1. Alphonse ngayap

    hello, not work because char ';' is not in the correct way see :

    function TOracleSQLGenerator.GenerateCreateSequence(
      const command: TCreateSequenceCommand): string;
    var
      LSequence: SequenceAttribute;
    begin
      LSequence := command.Sequence;
      Result := 'BEGIN ';
      if command.SequenceExists then
        Result := Result + 'EXECUTE IMMEDIATE ' + QuotedStr(Format('DROP SEQUENCE "%0:S;" ', [LSequence.SequenceName]));
    
    //AL 18/02/2015
    //  Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE',
    //    [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment]));
      Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE;',
        [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment])) ';
    
      Result := Result + ' END;';
    end;
    

    my modif

    function TOracleSQLGenerator.GenerateCreateSequence(
      const command: TCreateSequenceCommand): string;
    var
      LSequence: SequenceAttribute;
    begin
      LSequence := command.Sequence;
      Result := 'BEGIN ';
      if command.SequenceExists then
        Result := Result + 'EXECUTE IMMEDIATE ' + QuotedStr(Format('DROP SEQUENCE "%0:S" ', [LSequence.SequenceName])) + ';';
    
    //AL 18/02/2015
    //  Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE',
    //    [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment]));
      Result := Result + ' EXECUTE IMMEDIATE ' + QuotedStr(Format('CREATE SEQUENCE "%0:S" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY %2:D START WITH %1:D CACHE 20 NOORDER NOCYCLE',
        [LSequence.SequenceName, LSequence.InitialValue, LSequence.Increment])) + ';'; // <-- if i add this all work ok
    
      Result := Result + ' END;';
    end;
    

    Best Regards

  2. Log in to comment