You are on page 1of 4

List<Account> accounts = [select id,Name,Phone, Rating from account];

for(Account a:accounts){
system.debug(a.name);
system.debug(a.phone);
system.debug(a.rating);
}

Account a1=new Account();


a1.Name='Sam';
a1.Phone='1234';

Account a2=new Account();


a2.Name='Ram';
a2.Phone='2222';

Account a3=new Account();


a3.Name='Kiran';
a3.Phone='3333';
accs.add(a1);
accs.add(a2);
accs.add(a3);

List<Contact> contacts=[select id,lastname,firstname,phone from contact];

for(Contact c:contacts){
system.debug(c.lastname);
system.debug(c.firstname);
system.debug(c.phone);
}

-------------------

List<Opportunity> opportunities = [select id,name,amount,stagename from


Opportunity];

for(opportunity op:opportunities){
system.debug(op.name)
system.debug(op.amount)
system.debug(op.stagename)
}

------------------------------

List<account> accounts = [select id,name,phone from account where industry


='Energy'];

for(Account a:accounts){
a.rating='Warm';

update accounts;

--------------------------------

List<Account>accounts = [select id,name,phone from account where rating='cold'];


for(account a:accounts){
a.ownership = 'private'
}

update accounts;

-----------------------------------------
List<Account>accounts = [select id,name,phone from account where
ownership='public'];

for(account a:accounts){

a.rating='cold';
}

update accounts;

--------------------------------------------
List<Opportunities>Optylist = [select id,name,phone,amount from opportunity where
stagename='prospecting'];

for(opportunity op:optylist){

op.closeDate = system.today()+15;
}

update opportunity;

------------------------------------------------

List<opportunity>Optylist1 = [select id,name,phone,amount from opportunity where


stagename="closedwon"];

for(opportunity op:optylist1){
op.closedate = system.today();

update opportunity;
---------------------------------------

delete accounts
------------------
List<Account> accounts = [select id,name,phone from accounts];
delete accounts;
-----------------

List<Account>accoutns = [select id,name,phone, from accounts where rating = 'warm']

delete accounts;

----------------------

List<Account>accounts = [select id,name,phone from account where rating='cold']

delete accounts;
----------------------

List<opportunites>optylist = [select id,name,phone, from opportunity where


stagename='prospecting' ];

delete opptylist;

--------------------------

List<opportunites>optylist1 = [select id,name,phone, from opportunity where


stagename='closedown' ];

delete opptylist1;
---------------------------------------

List<Opportunity> optyList=[select id from Opportunity where


stagename='ClosedLost'];
delete optyList;

-----------------------------

You might also like