nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) (08/04/89)
Before the schema becomes stable every time it is modified the corresponding C declarations need to be updated manually I would like to know if there is a stand-alone SQL-schema to C declaration translator. I have seen a partial-code generator that achieve this from table definitions. It was supported by a CASE tool I have used before (Excellerator), however It did not always produce complete/correct C declarations which makes it useless. One feature that would be desired is that if the convertion from SQL to C declarations converts also the embedded comments to C comments. Has any body used or attempted a similar automation? Can one use awk to produce such a tool? Thank you -- nacer@mist.cs.orst.edu
davidm@cimshop.UUCP (David Masterson) (08/05/89)
>Before the schema becomes stable every time it is modified the >corresponding C declarations need to be updated manually I would like >to know if there is a stand-alone SQL-schema to C declaration >translator. ... >Has any body used or attempted a similar automation? >Can one use awk to produce such a tool? > The closest thing I've seen that is supported is VAX/VMS CDD+. It is a data dictionary product that will read the database and understand the declarations of all tables there in. VAX C (amongst the other VAX languages) has hooks in it that allow it to ask the data dictionary for the current definition of tables within the database. However, this should be a fairly trivial thing to develop through AWK and the like. All the information that is needed should be in the relational database's data dictionary. All that is needed is to develop an appropriate query to get the information out and then a shell script to massage the information into C syntax. The hard part would be how to make it automatic so that MAKE could recognize definitions as having changed and rebuild the code appropriately. A possibility there would be to have MAKE always execute this shell script, then DIFF the output with the previous output and only continue if there are differences. Just make sure that the script produces one file for each table in the database (so you don't MAKE everything if only one table changed). David Masterson uunet!cimshop!davidm or DMasterson@cup.portal.com
robf@squid.rtech.com (Robert Fair) (08/07/89)
>From: nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) >(wants a SQL schema to C declaration generator) Several RDBMS products have a utility called DCLGEN which takes SQL schema information, and generates #include files containing: - ESQL DECLARE TABLE statements - Host language structure definitions for each table specified, with the appropriate field names, types etc. The INGRES version of DCLGEN can generate code for any of the supported 3GLs (C, ADA, BASIC,...) and handles things like alternate structure names, output files etc. If your DBMS doesn't have DCLGEN or equivilent its pretty easy to write your own using ESQL, as long as there is a queryable set of system catalogs (which just about any decent DBMS should have). Robert Fair Technical Support Relational Technology, Inc
emuleomo@accur8.UUCP (Olumide Emuleomo) (08/08/89)
In article <1910007@hpmcaa.mcm.hp.com>, nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) writes: > Before the schema becomes stable every time it is modified the > corresponding C declarations need to be updated manually I would like > to know if there is a stand-alone SQL-schema to C declaration > translator. > If you are using Ingres then you are in *luck*. One of the features I LOVE in Ingres is a utility called DCLGEN. It lets you generate C structure declarations for any table in your database. The beauty of it is that this is completely automatic and command line driven, so that you can even write shell scripts to do the stuff. Also this method will work for almost any other DBMS. All you have to do is create the table in Ingres and then use DCLGEN to produce your C declarations and port it over to your favorite DBMS!! Emuleomo O O (emuleomo@accur8@uunet.uu.net)