Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add new row data while/after importing?
Message
Information générale
Forum:
Oracle
Catégorie:
PL/SQL
Divers
Thread ID:
00465710
Message ID:
00467169
Vues:
17
Sorry there are no memory variable in VFP.

But there is a ROW object you can use in a cursor. But the code is not simple
for me to whip up here ..

Assumming you only need to create the table once try the following.

create table tablenew as select * from table,table2 where
table1key=table2key;

This will both create and populate the table with data...

Then you could add the columns with...
alter table tablenew add deletestatus number(1) default 0;
alter table tablenew add user varchar2(20) default user;
alter table tablenew add lastedit date default sysdate;
alter table tablenew add uniqueid number(20);

Then create a sequence for the uniqueid ...
create sequence tablenewseq start with 1;

Then you could create a trigger like:
CREATE OR REPLACE TRIGGER tablenew_audit_info 
 BEFORE INSERT OR UPDATE ON tablenew
  FOR EACH ROW 
  BEGIN 
   IF INSERTING THEN 
      :new.user_name := user; 
      :new.lastedit  := sysdate; 
      :new.uniqueid := tablenewseq.nextval
   ELSIF UPDATING THEN 
      :new.user_name := user; 
      :new.lastedit  := sysdate; 
   END IF; 
 END; 
About the delete status.
You should know oracle just deletes rows completely and does not store a status.
You will need to:
update tablenew set deletestatus=1 where tablenewkey=key;
instead of using the delete...

Then when you get your records you will need to
select * from tablenew where deletestatus=0;

In my opinion this information and overhead is not necessary. Just delete it.
If they want it back too bad or get it from a backup.

Also note that oracle tables already have a rowid column with a unique
rowid but this should not be used as the primary key.

I also don't like sequences because they can cause extra database I/0 and database calls...

I use the following vfp function for primary keys...I've never ever had
a duplicate key.
**Generates a unique number based on date and time and to use as a Primary Key
**Returns a Number: Should always be a ten digit number
FUNCTION GetKey
LOCAL cdatetime
	CdateTime=str(recno())+str(seconds())+str(ROUND(RAND()*1000000000,0))
	CdateTime=strtran(cdatetime,' ','')
	nkey=ROUND(ABS(val(substr(CdateTime,1,10))),10)
RETURN nkey
Hope that helps..
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform