Progress
Language Reference


CREATE DATABASE Statement

Interfaces
OS
SpeedScript
All
All
Yes

Creates a new Progress database.

SYNTAX

CREATE DATABASE new-database [ FROM old-database ]
  [ REPLACE ] [ NO-ERROR ] 

new-database

A CHARACTER expression that returns the full or relative pathname of the database you want to create. If the database already exists, a new database is not created unless you specify REPLACE.

FROM old-database

A CHARACTER expression that returns the name of the database whose schema and data you want to copy to the new database. The value of old-database can be a full or relative pathname or one of the special strings "EMPTY", "DEMO", or "SPORTS". If you omit this option, Progress creates an empty database.

REPLACE

If you specify this option and a database already exists with the name specified by new-database, then the existing database is deleted and replaced with the new database. If you do not specify REPLACE, you receive an error occurs if the database exists.

NO-ERROR

If you specify this option and the CREATE DATABASE statement fails, the error condition is not raised.

EXAMPLE

This procedure prompts for the name of a database to connect. If the database does not exist, the user can create it.

r-credb.p
DEFINE VARIABLE dbpath  AS CHARACTER LABEL "Database" FORMAT "x(65)".

/* Prompt the user for the name of a demo database to connect. */
SET dbpath HELP "Enter the path of your database."
    WITH FRAME dbname-frame SIDE-LABELS.

/* If the entered name does not have the .db suffix, add it.
   This is necessary for the search function to work correctly. */
IF LENGTH(dbpath) < 3
THEN dbpath = dbpath + ".db".
ELSE IF SUBSTR(dbpath, LENGTH(dbpath) - 2) = ".db"
     THEN dbpath = dbpath + ".db".

/* If the database does not exist, create it from SPORTS. */
IF SEARCH(dbpath) = ?
THEN DO:
  MESSAGE "Database does not exist. Do you want to create it?"
     VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO TITLE "Connect Database"
       UPDATE create-it AS LOGICAL.

  IF create-it
  THEN DO:  
    CREATE DATABASE dbpath FROM "SPORTS".
    MESSAGE "New database created:" dbpath.
  END.
  ELSE UNDO, RETRY.
END.

/* Connect the database. */
CONNECT VALUE(dbpath) -1. 

NOTES

SEE ALSO

ALIAS Function, CONNECT Statement, CONNECTED Function, CREATE ALIAS Statement, DATASERVERS Function, DBCODEPAGE Function, DBCOLLATION Function, DBRESTRICTIONS Function, DBTYPE Function, DELETE ALIAS Statement, DISCONNECT Statement, ERROR-STATUS System Handle, FRAME-DB Function, LDBNAME Function, NUM-DBS Function, PDBNAME Function, SDBNAME Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095