![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 2 of 2 total |
![]() |
Tue, Dec 18 2007 9:41 AM | Permanent Link |
"M. Malagoli" | Hi,
in the new syntax of elevate DB how to add a field or costraint only if not exist? like the old syntax CREATE INDEX IF NOT EXISTS ind ON "giri" thanks |
Tue, Dec 18 2007 10:51 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | You have to query the system tables. In my conversion app I'm using a query IsThere and a procedure to add the code to make indices to a script
procedure AddSimple(iName, tbl, fld: string); var sqlcode: string; begin IsThere.Close; IsThere.SQL.Text := 'SELECT * FROM Information.Indexes WHERE TableName = ' + QuotedStr(tbl) + ' AND Name = ' + QuotedStr(iName); IsThere.ExecSQL; if IsThere.RecordCount = 0 then begin IdxMaker.SQL.Add('EXECUTE IMMEDIATE'); sqlcode := StringReplace('CREATE INDEX "$iName" ON "$table" ($field)', '$iName', iName, []); sqlcode := StringReplace(sqlcode, '$table', tbl, []); sqlcode := StringReplace(sqlcode, '$field', fld, []); IdxMaker.SQL.Add(QuotedStr(sqlcode) + ';'); end; end; It is possible to embed the test into the sql creating the index and I know Tim has posted an example somewhere in the ngs. I'm hoping that EXISTS will make a reappearance. Roy Lambert |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |