Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STRSQL Help

Status
Not open for further replies.

dhascup

Programmer
May 8, 2001
24
US
This has slipped my mind.

How do I make copies of records within a file to the same file using strsql?



 
Hi,


You may fire the following, provided u dont have a unique/primary key constraint:

insert into <PF NAME> values (select * from <PF NAME>)

Please explain ur requirement in detail.

regards
Satya
 
I have a 10 record with 50+ fields all populated. All 10 records are for a particular account number.

I need to add the exact same ten lines to a new account number.

I figured i would copy all 10 records and just change the account number through DBU.

Thanks
David
 
Hi

As Satya says, you may run into duplicate record problems if the account number is part of the unique key

If this is the case you could create a copy of all records into an outfile, update all those records with the new account number, then add them into your original file

Select * from <pfile> (output to <outfile>)
Update <outfile> set <accountno> = 12345
Insert into <pfile> select * from <outfile>

Does this help?

Suzie

 

Its cool , Suzie.

There is one more way of solving this in one shot:

insert into <pf name> (<column list>) select <column list> from <pf name> where <some condition if needed>


For example, if the PF (ACCOUNT) contains ACC# & ACCAMT and we want to create a new set of records similar to acc# 12345 but with a new acc# as 34567

then the following will do the work:

insert into ACCOUNT (ACC#,ACCAMT) select '34567',ACCAMT from ACCOUNT where ACC# = '12345'


Regards
Satya

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top