Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can someone explain 2 dbc open at the same time?
Message
 
À
14/02/1999 23:40:06
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00187584
Message ID:
00187591
Vues:
20
My problem is new tables getting created in the wrong dbc. I am trying to write a small program to create my database with the structure stored in another database. kinda redundant, but with 42 relationships between 31 tables, I came up with a program to create the foreign key field names based on a small table of relations. Much more fun than entering all of those field names by hand.

I keep changing things, and sometimes I get it to work, then other times it dosn't. I just don't have a good grip on it.

here is the program:
* program ddmakdbc.prg

close all

open database dd

cd \persware\dev\data\
create database pw 
modify database nowait

do lmaktbl
do lmakrel

return
*************************************************************************
procedure lmaktbl

select * ;
 from dd!dddbfs ;
 into cursor qdbfs

scan

* drop table ("Pw" + dnam)

 m.tdsc = lfixnam( tdsc )
 create table ("Pw" +tnam) name (m.tdsc) ( ;
  ("c" + tid +"Key") c (6)  primary key, ;
  ("c" + tid +"ID")  c (10) unique ,;
  ("c" + tid +"Nam") c (20), ;
  ("c" + tid +"Stt") c (1) )

endscan

return
*************************************************************************
procedure lmakrel

SELECT cld.tord as tord, ;
 "Pw" + cld.tnam as cldtbl, ;
 cld.tdsc as cldnam, ;
 "c" + proper(rcid) + proper( rpid ) +"Key" as fldnam, ;
 "Pw" + pnt.tnam as pnttbl, ;
 pnt.tdsc as pntnam ;
 FROM  dd!ddtbls cld JOIN dd!ddrels on cld.tid = rcid ;
  JOIN dd!ddtbls pnt ON  rpid = pnt.tid ;
 into cursor qrelcmd ;
 order by cld.tord

scan
  
  m.cldnam = lfixnam( cldnam )
  m.pntnam = lfixnam( pntnam )
  
  alter table (m.cldNam) ;
   add (fldnam) c (6) references (m.pntNam)

endscan

return
*************************************************************************
function lfixnam( lcNam )

local lnLen, lcRet

lnLen = len( lcNam )
lcRet = strt( trim(lcNam), " ", "_" )

return lcRet
*************************************************************************
* eof: ddmakdbc.prg
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform