Title: | Borland Delphi conference |
Moderator: | BROUGH::DAVIES |
Created: | Tue Mar 12 1996 |
Last Modified: | Fri May 30 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 33 |
Total number of notes: | 110 |
Does any reader of this conference know of a way to do the following:- SQL commands such as CREATE TABLE can be done on the Database Desktop. I want to be able to do this from a delphi app. It seems that the SQL component has to attact to a particular table but in this case the table does not exist. Also the database desktop sql seems to be only a single shot device. By that I mean that only 1 sql command can be contained in an SQL statement. I could devise an application that uses a .ini file to create the tables but this is not so portable. In my particular case, I have a whole bunch of SQL scripts that build an ORACLE database and then populate it. With a bit of minor editing (remove tablspace defs etc) I want to be able to run that into a local database and create all the tables I need Any thoughts ? I have scanned some sites on the web but I have not found anything of use. Stephen Davies
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
29.1 | 45080::CWINPENNY | Thu May 15 1997 20:36 | 7 | ||
I've taken to using ODBC and SQL and am staying clear of the specific Tdb controls which should make porting to any SQL database easier. I'll be coming across this pretty soon as the easiest way to delete a table is to drop it and create it again. Chris | |||||
29.2 | 45080::CWINPENNY | Fri May 16 1997 14:41 | 44 | ||
Start a new project and on the empty form create a standard button called bnCreate and add a query component called quCreate. Fill in the DdatabaseName property of the query component. Double click on the button and enter the following code. procedure TfmCreate.bnCreateClick(Sender: TObject); begin quCreate.close; quCreate.sql.clear; quCreate.sql.add ('CREATE TABLE ITEMS '); quCreate.sql.add ('(ItemNumber int, '); quCreate.sql.add (' Description char(30),'); quCreate.sql.add (' Price float); '); quCreate.ExecSql; end; Save and build the project and run the .exe from Explorer, see below. Clicking on the button will create the table ITEMS in your database. Alternatively you could use. quCreate.sql.LoadFromFile ('c:\project\create.txt'); instead of the quCreate.sql.add where the file c:\project\create.txt contains your SQL code. Note that the only thing needed to start with is DatabaseName, this could be an empty database. Obviously the above template can be used to execute any SQL code you may need to use. By using the LoadFromFile it is possible to modify your SQL after the executable has been built with the disadvantage that so can end users. The only problem I've come across is that in this simple form of a quick example if the SQL isn't spot on, ie. you miss out a comma, then the program hangs. Therefore don't run it from within the development environment. Chris | |||||
29.3 | Import .txt === Good Idea | BROUGH::DAVIES | Hype is a 4 letter word ! | Tue May 27 1997 14:22 | 6 |
Chris, Thanks for the tip. I will not experience the SQL hanups though as I will be importing files created by Paradox from working SQL. Stephen Davies | |||||
29.4 | 45080::CWINPENNY | Tue May 27 1997 14:43 | 4 | ||
The hangups probably came from not preparing the query properly. Chris |