StrebenMonch: Thanks for the ideas.
Optimized the SQL is what i have been thinking about.
I attached the SQL here, I could only see to eliminate the calculation of the cost where I used 'case' to check null value and use sum function again. Please correct me if you think any other ones could be done in the Perl.

After bind_columns, then use loop and array to do the summation?
select
mvmnt_data.region
,store_name
,nvl(i_a.nat_upc,i_b.nat_upc)
,nvl(i_a.long_description,i_b.long_description)
,nvl(i_a.item_size,i_b.item_size)
,nvl(i_a.item_uom,i_b.item_uom)
,vsi.vend_item_num
,salesUnits
,salesDollars
,case_size
,cost
,ps.ps_prod_subteam
from
(select wm.upc,sum(wm.mvmnt_units) salesUnits
,sum(wm.mvmnt_dollars) salesDollars
,wm.store
,wm.pos_dept
,wm.case_size
,sum(round (case when wm.case_size is null or
wm.case_cost=0
then null
else (wm.case_cost/wm.case_size) *
wm.mvmnt_units end, +3)) cost
,s.store_name
,s.region
from stella.mvmnt_wkly wm,vim.store@vim s
where wm.mvmnt_date between to_date
('10/01/2004', 'mm/dd/yyyy')and to_date
('10/03/2004', '/mm/dd/yyyy')
and wm.store in ('10036')
and wm.store=s.ps_bu
--and wm.upc='000000015232'
and wm.pos_dept='0110'
group by wm.case_size
,s.region
,wm.pos_dept,
wm.upc
,wm.store
,s.store_name) mvmnt_data,
vim.item_region@vim ir,
vim.item_master@vim i_a,
vim.item_master@vim i_b,
vim.reg_pos_dept_ref@vim rpdr
,vim.ps_team_ref@vim ps
,vim.vendor_store_item@vim vsi
where mvmnt_data.region=ir.region(+)
and mvmnt_data.upc=substr(ir.upc(+),-12,12)
and substr(ir.nat_upc, 12, 12)=substr(i_a.nat_upc(+),-
12,12)
and mvmnt_data.upc=substr(i_b.nat_upc(+),-12,12)
and mvmnt_data.region=rpdr.region(+)
and mvmnt_data.pos_dept=trim(leading 0 from rpdr.pos_dept
(+)) and rpdr.pos_dept=ps.pos_dept
and rpdr.region=ps.region
and mvmnt_data.store=ps.ps_bu
and mvmnt_data.upc=substr(vsi.upc,-12,12)
and vsi.region=ps.region
and vsi.ps_bu=mvmnt_data.store
and vsi.v_auth_status='P'
Jewang

In reply to Re^2: Perl CGI timeout by jewang
in thread Perl CGI timeout by jewang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.