Running Custom DDL SQL

delphi

(Nathan Zimmer) #1

Hi guys,

I am working on a project and want to create and run custom DDL SQL on my database based upon some user input (Create custom tables, Drop other tables, etc). I would like to use something remobjects provides to run these scripts against my dbs. Currently I am gathering user input and then manipulating it into a SQL Create table string.

I tried to use a SQL CMD in the DASchema but it gave me errors against my oracle db. Any suggestions would be greatly appreciated.

Thanks,
N


(EvgenyK) #2

Hi,

what exactly SQL you have used?
we can drop email with details to support@ if you want to keep it privately


(Nathan Zimmer) #3

Thank you for the quick reply. I was able to figure it out over the weekend by using

var
  ic : IDASQLCommand;
  lSL: TStringList;
  i: integer;
begin

  try
    try
      lSL := TStringList.Create;
      lSL.Clear;
      lSL.Delimiter := ';';
      lSL.StrictDelimiter := True;
      lSL.DelimitedText := aSQLString;
      for i:=0 to lSL.Count-1 do
      begin
        if lSL[i] = '' then continue;
        ic := Connection.NewCommand(lSL[i], stSQL);
        ic.Execute;
      end;
    finally
      lSL.Free;
    end;
  except raise;
  end;
end;

My issue occurred when trying to run multiple statements in oracle where the “;” is not accepted. I just decided to use a Tstringlist to break up the lines using the delimiter as ‘;’.