Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQLExec Help Desperate!
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00462163
Message ID:
00462408
Vues:
16
Hey, this is almost fun [grin].

Hacking up your code, here is what I have
so far. I am creating table (the result
of a SQL-Select from a much larger table),
then adding columns for "updatedby" and
"updatedate" and a "primary key" . Then
I am creating a sequence and a create/replace trigger.

The only problem I have now is that I
don't have anything in the newly-added
columns, since my trigger is made after
the data gets in there. I tried to put
the trigger and sequence at the top of
the .prg but that didn't work (I guess
the table has to exist first).
cTableName = 's073_sites'

cString = 	'create table ' + cTableName + ' as '+ ;
' select inv_no , id from godlike.s073_qtrvars ' + ;
' group by inv_no , id '
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK

cString = 	'alter table ' + cTableName + ;
' add ( cUpdatedBy varchar2(32) null )'
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK

cString = 	'alter table ' + cTableName + ;
' add ( tLastUpdate date null )'
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK

cString = 	'alter table ' + cTableName + ;
' add ( nRowID number(9) null )'
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK

cString = 	'create sequence ' + cTableName +'_uniq ' + ;
' increment by 1 start with 1 nocache '
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK

cString = 	'create or replace trigger ' + cTableName + '_t1 ' + chr(13) + ;
'before insert or update on ' + cTableName +' for each row ' + chr(13) + ;
'declare ' + chr(13) + ;
' v_Id Number; ' + chr(13) + ; 
' v_Count Number ; ' + chr(13) + ;
'begin ' + chr(13) + ;
' :cUpdatedBy := USER ; ' + chr(13) + ;
' :tLastUpdate := SYSDATE ; ' + chr(13) + ;
'if nRowID is Null or nRowID < 1 then ' + chr(13) + ;
'select ' + cTableName + '_uniq.nextval into vID from dual ; ' + chr(13) + ;
' :nRowID := v_Id ; '+ chr(13) + ;
'end if ' +chr(13) + ;
'end ;' + chr(13) 
nResult = sqlexec (gnHandle , cString)
? cString
? nResult									&& Returns 1 - OK
			
?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform