Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 how to execute this dynamically

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-18 : 09:06:35
Previn writes "
DECLARE
G_add varchar2(100);
G_ORDER_DATE_FROM Date;
G_ORDER_DATE_TO Date;
G_INS_DATE_FROM Date;
G_INS_DATE_TO Date;

BEGIN
:G_ORDER_DATE_FROM := '&&1';
:G_ORDER_DATE_TO := '&&2';
:G_INS_DATE_FROM := '&&3';
:G_INS_DATE_TO := '&&4';

if :G_INS_DATE_FROM is null then

G_add := 'and (to_date(install_date) between nvl(:G_INS_DATE_FROM,install_date) and nvl(:G_INS_DATE_TO,install_date))';

else

G_add := ' ';

end if;

select order_number, line_number, order_line_id
, part_number, item_description,install_date
, sum(decode(category_type,'ILMI',1,'ILM',1,0)) ilm_count
, sum(decode(category_type, 'ITM',1,0)) itm_count
, sum(decode(category_type,'IDT',1,0)) idt_count
from atrd_serial_num_ship_v sn
where date_ordered between nvl(:G_ORDER_DATE_FROM,date_ordered)
and nvl(:G_ORDER_DATE_TO,date_ordered)
and decode(:G_INS_DATE_FROM,null,null,.......

if :G_INS_DATE_FROM is not null then we need to get the G_add statement in this place. I tried as ||&G_add but it never worked.

group by order_number, line_number, order_line_id
, part_number, item_description,install_date;
END;


"

Edited by - robvolk on 12/18/2001 09:41:29

robvolk
Most Valuable Yak

15732 Posts

Posted - 2001-12-18 : 09:42:59
We're really good at dynamic SQL using SQL Server, but are unfortunately at a loss with Oracle. Hopefully someone will browse through this and have an answer for you, but you should also try an Oracle site. http://dbforums.com might have something.

Go to Top of Page

neelima
Starting Member

2 Posts

Posted - 2001-12-27 : 01:53:50
fine

Go to Top of Page
   

- Advertisement -