Re: Creating tables
From: Dionisis Vrionis (diovr_at_dksoft.gr)
Date: 10/15/04
- Next message: Robert Wagner: "Re: Creative Javascript writing (was: OFF Topic)"
- Previous message: Lueko Willms: "Re: Cobol/400"
- In reply to: Peter E.C Dashwood: "Re: Creating tables"
- Next in thread: Frederico Fonseca: "Re: Creating tables"
- Reply: Frederico Fonseca: "Re: Creating tables"
- Reply: Peter E.C Dashwood: "Re: Creating tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 15 Oct 2004 19:20:48 +0300
Your sample it works fine.
Thanks all (specially you Peter) for help.
"Peter E.C Dashwood" <dashwood@enternet.co.nz> wrote in message
news:1097670067.BM6bnx51U2GOAH7FlW/9Hg@teranews...
>
> "Dionisis Vrionis" <diovr@dksoft.gr> wrote in message
> news:ckg68k$1km9$1@ulysses.noc.ntua.gr...
> > I Have a database named test.mdb without tables.
> > How can i create a table in a database from netcobol.
> >
> What Richard wrote is true, however, there is more than one way to skin a
> cat, and tables can be created by more than just embedded SQL.
>
> With a little imagination, some knowledge if the DB object model, and an
OO
> COBOL compiler (like NetCOBOL), you can certainly create tables "on the
> fly".
>
> Here's how....
>
> ENVIRONMENT DIVISION.
> REPOSITORY.
> CLASS COM-EXCEPTION AS "*COM-EXCEPTION"
> CLASS COM AS "*COM".
> DATA DIVISION.
> WORKING-STORAGE SECTION.
> 01 DAO-connection pic x(8192) value "DAO.DBEngine.36". *> Make sure
this
> is the COM ProgID of the
>
> *> the version of ACCESS or DAO you have on
>
> *> your system. Search the registry for DAO...
>
> *> (Data Access Objects)
> 01 OBJ-DBEngine OBJECT REFERENCE COM.
> 01 OBJ-DAOCONNECTION OBJECT REFERENCE COM.
> 01 OBJ-Database OBJECT REFERENCE COM.
> 01 NAME-DB PIC X(whatever) value "Name of the DB you want to access (can
> be ODBC DSN)".
> * [You might want to pass this through Linkage...]
>
> 01 create-stuff pic x( whatever) value "CREATE TABLE tablename (field,
> field, ...) CONSTRAINTS etc".
>
> ======================== Examples of valid CREATE entry (valid for SQL
> Server and ACCESS 2003)=============
> You could set up "create-stuff" to contain the following...
>
> CREATE TABLE jobs
> (
> job_id smallint
> IDENTITY(1,1)
> PRIMARY KEY CLUSTERED,
> job_desc varchar(50) NOT NULL
> DEFAULT 'New Position - title not formalized yet',
> min_lvl tinyint NOT NULL
> CHECK (min_lvl >= 10),
> max_lvl tinyint NOT NULL
> CHECK (max_lvl <= 250)
> )
>
> It will create the table as described.
>
> If you want a temporary table try...
>
> CREATE TABLE #tempTable (tempField int... etc)
>
> Here's the offical story on temporary tables...
>
> Temporary Tables
> You can create local and global temporary tables. Local temporary tables
are
> visible only in the current session; global temporary tables are visible
to
> all sessions.
>
> Prefix local temporary table names with single number sign (#table_name),
> and prefix global temporary table names with a double number sign
> (##table_name).
>
> SQL statements reference the temporary table using the value specified for
> table_name in the CREATE TABLE statement:
>
> CREATE TABLE #MyTempTable (cola INT PRIMARY KEY) (this would be one
EXECUTE
> statement)
> INSERT INTO #MyTempTable VALUES (1) (This would be another EXECUTE
> statement)
>
============================================================================
> =================================
>
> 01 Temp-text pic x(50).
> 01 connection-flag pic x value '1'.
> 88 no-connection value zero.
> 88 connected value '1'.
> PROCEDURE DIVISION. [using databaseName, TableName perhaps...]
> DECLARATIVES.
> ERR SECTION.
> USE AFTER EXCEPTION OLE-EXCEPTION
> move spaces to DB-path
> set no-connection to TRUE
> .
> END DECLARATIVES.
> main section.
> set connected to TRUE
> perform a-section
> .
> return-to-caller.
> exit program.
> *==============================================================
> a-section section.
> a000.
> *
> * Establish COM Object references to the specified
> * ACCESS Database using DAO.
> *
> invoke COM "CREATE-OBJECT"
> using DAO-connection
> returning OBJ-DBEngine
> end-invoke
>
> invoke OBJ-DBEngine "OpenDatabase"
> using NAME-DB
> returning OBJ-Database
> end-invoke
> *
> * Check we got to the DB OK...
> if no-connection
> yada-yada-yada...
>
> * Now you can use the EXECUTE method of the Database to create your new
> table...
>
> invoke OBJ-Database "Execute"
> using create-stuff
> end-invoke
> ....
> a999.
> exit.
>
> The above is not definitive, but it has been put together from currently
> working code. Hopefully there's enough here to get you going.
>
> Pete.
>
>
>
- Next message: Robert Wagner: "Re: Creative Javascript writing (was: OFF Topic)"
- Previous message: Lueko Willms: "Re: Cobol/400"
- In reply to: Peter E.C Dashwood: "Re: Creating tables"
- Next in thread: Frederico Fonseca: "Re: Creating tables"
- Reply: Frederico Fonseca: "Re: Creating tables"
- Reply: Peter E.C Dashwood: "Re: Creating tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|