i have a below qry
IF EXISTS (SELECT * FROM trans WHERE cid =36 and pid=37)
UPDATE trans set pid='37' WHERE cid =36 and pid=37
Else
insert into trans (tid,cid,pid,qty,rate,frmdt,todt)
values (207,36, 37,0,55 ,'1/1/1900','1/1/1900')
here currently when inserting i need to get the rate value from another table
select prate from M_PRDT where PID=37
this rate value needs to be put in place of 55
how can it be done in a single stmt without having to use another qry & execute it and get the records