Timestamp compatibility while performing delta imp

2019-07-15 11:17发布

问题:

Im new to solr.I have successfully indexed oracle 10g xe database. Im trying to perform delta import on the same. The delta query requires a comparison of last_modified column of the table with ${dih.last_index_time}. However in my application I do not have such a column . Also, i cannot add this column. Therefore i used 'scn_to_timestamp(ora_rowscn)' to give the value of the required timestamps. This query returns the value of type timestamp in the following format 24-JUL-13 12.42.32.000000000 PM and dih.last_index_time is in the format 2013-07-24 12:18:03. So, I changed the format of dih.last_index_time as to_timestamp('${dih.last_index_time}', 'YYYY/MM/DD HH:MI:SS').

My Data-config looks like this -

<dataConfig>
<dataSource type="JdbcDataSource" driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@XXX.XXX.XX.XX:XXXX:xe" user="XXXXXXXX" password="XXXXXXX" /> 
<document name="product_info">
<entity name="PRODUCT" pk="PID" query="SELECT * FROM PRODUCT" deltaImportQuery="SELECT * FROM PRODUCT WHERE PID=${dih.delta.id}" deltaQuery="SELECT PID FROM PRODUCT WHERE scn_to_timestamp(ora_rowscn) > to_timestamp('${dih.last_index_time}', 'YYYY/MM/DD HH:MI:SS')">
  <field column="PID" name="id" /> 
  <field column="PNAME" name="itemName" /> 
  <field column="INITQTY" name="itemQuantity" />
  <field column="REMQTY" name="remQuantity" />
  <field column="PRICE" name="itemPrice" /> 
  <field column="SPECIFICATION" name="specifications" /> 
  <entity name="SUB_CATEGORY" query="SELECT * FROM SUB_CATEGORY WHERE SCID=${PRODUCT.SCID}">
    <field column="SUBCATNAME" name="brand" /> 
    <entity name="CATEGORY" query="SELECT CNAME FROM CATEGORY WHERE CID=${SUB_CATEGORY.CID}">
      <field column="CNAME" name="itemCategory" /> 
    </entity>
  </entity>
</entity>
</document>
</dataConfig>

However,This is not working and im getting the following error -

Unable to execute query: SELECT * FROM PRODUCT WHERE PID= Processing Document # 1
Caused by: java.sql.SQLException: ORA-00936: missing expression

Please help me out!!!

回答1:

I had a similar issue and had more success with *to_date*. But looking at this again, it just looks like perhaps you just need to quote your delta id in the delatImportQuery:

deltaImportQuery="SELECT * FROM PRODUCT WHERE PID='${dih.delta.id}'"