>* 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 > >Look at the SET DATABASE TO command.