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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PL/SQL from excel

Status
Not open for further replies.

Gumster

IS-IT--Management
Feb 2, 2003
17
SE
How can I get this PL/SQL Statement to run from an excel macro?
And I also need to be able to change the "from date" and "to date" from cells in excel. It's a Oracle 8 database.



-- select trade info (standard contracts) about trades that are in delivery during selected period
select
'STD ' AS CType,
sp.tradeid,
0 as Detailsid,
'N/A' as portfolioid,
sp.accountcode,
sp.counterparty,
sp.power,
-- sp.power * p.totalhours,
sp.price,
sp.currencycode,
sp.physical,
sp.productid ,
sp.audited,
p.totalhours,
p.startdate,
p.enddate
from kw4_sptrades sp, kw4_standardprod p
where
sp.productid = p.standardproductid and
sp.physical = 0 and accountcode <>'ND' and
(
(p.startdate between to_date('01.10.2003','dd.mm.yyyy') and to_date('31.10.2003','dd.mm.yyyy') or
p.enddate between to_date('01.10.2003','dd.mm.yyyy') and to_date('31.10.2003','dd.mm.yyyy')
) or
(p.startdate < to_date('01.10.2003','dd.mm.yyyy') and p.enddate > to_date('31.10.2003','dd.mm.yyyy') )
)
UNION
select
'NONSTD' AS CType,
ch.tradeid,
cd.detailsid as Detailsid,
ch.portfolioid as portfolioid,
ch.accountcode,
ch.counterparty,
cd.power,
-- cd.power * cd.totalhours,
cd.price,
ch.currencycode,
ch.physical,
ch.productid ,
ch.audited,
cd.totalhours,
cd.startdate,
cd.enddate
from kw4_contractsheader ch, kw4_contractsdetails cd
where
ch.portfolioid = cd.portfolioid and
ch.physical = 0 and
accountcode <>'ND' and
(
(cd.startdate between to_date('01.10.2003','dd.mm.yyyy') and to_date('31.10.2003','dd.mm.yyyy') or
cd.enddate between to_date('01.10.2003','dd.mm.yyyy') and to_date('31.10.2003','dd.mm.yyyy')
) or
(cd.startdate < to_date('01.10.2003','dd.mm.yyyy') and cd.enddate > to_date('31.10.2003','dd.mm.yyyy') )
)
order by tradeid
;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top