prasanna p

prasanna p

  • 1.7k
  • 322
  • 40.9k

how to get the records greater than date in the oracle database

Apr 10 2021 11:16 AM
Hi Friends,
I am sending sql db  datetime field  LastId paramater like this
 
cmd = new OracleCommand("select BUSINESS_DATE, TRANS_SEQ ,sum(UNIT_PRICE) TotalPrice,,sum(VAT_AMT) TotalTax,sum(GROSS_AMT) TotalPricewithTax from LINEITM_VIEW group by TRANS_SEQ ,BUSINESS_DATE Having BUSINESS_DATE >= TO_TIMESTAMP(:LastId,'yyyyMMddHH24missffff')", con);
cmd.CommandType = CommandType.Text;
OracleParameter param = new OracleParameter(":LastId", OracleDbType.TimeStamp, ParameterDirection.Input);
param.Value = LastID();
cmd.Parameters.Add(param);
 
I am not getting the correct result in the front end.
 
I am also sending oracle query like this
 
Select \"BUSINESS_DATE\",\"TRANS_SEQ\",SUM(\"VAT_AMT\") \"TotalTax\",SUM(\"UNIT_PRICE\") \"TotalPrice\",SUM(\"GROSS_AMT\") \"TotalPricewithTax\" from \"LINEITM_VIEW\" GROUP BY \"TRANS_SEQ\",\"BUSINESS_DATE\" HAVING BUSINESS_DATE >= TO_TIMESTAMP('2018-12-31 08:52:09.270', 'yyyyMMddHH24missffff')
 
 getting errors : object cannot be cast from DBNull to other types
 for this error I changed query like this
Select to_char(BUSINESS_DATE,'YYYY-MM-DD') BUSINESS_DATE,TRANS_SEQ,SUM(NVL(VAT_AMT, 0)) TotalTax,SUM(NVL(UNIT_PRICE, 0)) TotalPrice,SUM(NVL(GROSS_AMT, 0)) TotalPricewithTax from LINEITM_VIEW GROUP BY TRANS_SEQ,BUSINESS_DATE 
 
getting error: ORA-01810: format code appears twice 
 missingg expression error also coming .
 
Please tell me how to get the oacle db records  by passing sql datetime parameter.
 
 
 

Answers (2)