select t3.customername customer_name,t3.address 
customer_address,t5.classname customer_zone,t3.contactperson 
contact_man,t3.contactphone tel,t1.timevalidated item_saledate,
t4.name item_name,t4.spec item_spec,t4.unit item_unit,t2.serial 
item_batch,t2.total item_number,t2.price item_price 
from t_bill_header t1,t_bill_detail t2,t_customer t3,t_goods_info t4,
t_area t5 where t1.bseqid=t2.bseqid and t1.customerid=t3.customerid 
and t3.areaclassid=t5.classid(+) and t1.deptid=2 
and t4.factory like '%东阿阿胶%' 
and nvl(t3.issupplier,0)=0 and t1.timevalidated between
to_date(@startdate,'yyyy/mm/dd hh24:mi:ss') 
and to_date(@enddate,'yyyy/mm/dd hh24:mi:ss') AND t1.billtypeid in (12,14,16,18)
select sysdate item_invdate,t5.name item_name,t5.spec item_spec,t5.unit item_unit,sum(t1.total) 
item_number,t4.serial item_batch,t4.expired item_createdate from t_stock t1,t_goods_batch t2,t_bill_detail 
t3,t_goods_serial_info t4,t_goods_info t5 where t1.goodsid=t2.goodsid and t1.batchno=t2.batchno and t2.bseqid=t3.bseqid 
and t2.lineno=t3.lineno and t3.serial=t4.serial and t1.goodsid=t4.goodsid and t1.goodsid=t5.goodsid and t5.factory 
like '%东阿阿胶%' and t1.storeid in (select storeid from t_store where deptid=2) 
group by sysdate,t5.name,t5.spec,t5.unit,t4.serial,t4.expired
就是这两个语句,不知道为什么,在sql* plus里面是正常的,原封不动的放到我做的程序里面就有问题了。报错ORA-00920.为什么呢高手,请赐教。

解决方案 »

  1.   

    “to_date(@startdate,'yyyy/mm/dd hh24:mi:ss')”这个里面的@错了,没这个运算符
      

  2.   

    那参数怎么写,我先写一个带参数的SQL语句,请高手指点啊!!!
      

  3.   

    那参数怎么写,我先写一个带参数的SQL语句,请高手指点啊!!!
      

  4.   

    改为:
    todate('",startdate,"','yyyy-mm-dd')
      

  5.   

    知道为什么了,原来是between and在搞鬼。