Subject RE: SPAM-LOW: RE: [IBO] Creating duplicate database through scripts
Author Jason Wharton
I must confess, I got lost reading through this and couldn't spot any
definitive place where I could help.

I suggest you tidy things up a bit and try and create an isolated case that
will be easier to diagnose.

Jason

> -----Original Message-----
> From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]On
> Behalf Of Lee
> Sent: Sunday, December 17, 2006 1:34 PM
> To: IBObjects@yahoogroups.com
> Subject: Re: SPAM-LOW: RE: [IBO] Creating duplicate database through
> scripts
>
>
> Lee wrote:
> >
> >
> > Jason Wharton wrote:
> >
> > >
> > > Send me exactly what you did.
> > >
> >
> > Hi Jason,
> >
> > Here is the code that I am trying to use. It's got a little sloppy
> > after I tried so many ways to make it work so I had to
> clean it up a bit ;)
> >
> > Incidentally, I have also tried saving the output of
> TIB_DDL_ETRACT to a
> > file and running it through IBExpert and I get all kind of errors.
> >
> > Here is my code and the exception produced is as follows:
> > "ISC ERROR CODE:335544332 ISC ERROR MESSAGE: invalid transaction
> > handle (expecting explicit transaction start) "
> >
> > VAR
> > sStatement: String;
> > sFile: String;
> > slOut, slErrors: TStringList;
> > Begin
> >
> > // get new file name/path
> > If (Not sdDB.Execute) Then Exit;
> > sFile := sdDB.FileName;
> >
> > // extract meta data from current db
> > slOut := TStringList.Create;
> > slErrors := TStringList.Create;
> > Try
> > // assign connect property to current, connected database
> > // IBExtract = TIB_DDL_EXTRACT
> > IBExtract.IB_Connection := IBDB;
> > // get ddl from database
> > IBExtract.ExecuteStrings(slOut, slErrors);
> > // save to use later
> > sStatement := slOut.Text;
> > Finally;
> > FreeAndNil(slOut);
> > FreeAndNil(slErrors);
> > End;
> >
> > // assign connection and transaction for new database
> > // to be created.
> > scriptExtract.IB_Connection := dbExtract;
> > scriptExtract.IB_Transaction := transExtract;
> >
> > // assign a create database statement and run it.
> > // Seem to have problems with the create statement in same
> > // script as ddl.
> > scriptExtract.SQL.Text := 'CREATE DATABASE ' +
> QuotedStr(sFile) + ' USER ' +
> > QuotedStr('sysdba') + ' PASSWORD ' + QuotedStr('masterkey') + '
> > PAGE_SIZE 4096;';
> > scriptExtract.Execute;
> >
> > // here I have tried testing with/without explicit commit
> and start of
> > trans either way
> > // still exihibits same exception.
> > dbExtract.IB_Transaction.Commit;
> > dbExtract.Disconnect;
> > dbExtract.Path := sFile;
> > dbExtract.Connect;
> > dbExtract.IB_Transaction.StartTransaction;
> >
> > // apply the extracted ddl to IB_Script component
> > scriptExtract.SQL.Text := sStatement;
> > // save a copy for testing
> > scriptExtract.SQL.SaveToFile(ExtractFilePath(ParamStr(0)) +
> 'test.sql');
> >
> > scriptExtract.Execute;
>
> Hi, any idea on this one? I'm out of ideas so any help would be
> appreciated.
>
> Thanks again,
>
> --
>
> Warm Regards,
>
> Lee