I am trying to import the data using SQL statement ‘LOAD INTO table FROM filename’ where filename is a text file.
The code I’m using is shown below;
var query = "LOAD INTO TABLE sap_products (material_no, batch_number, batch_management, product_no, description, unit_of_measure, measurements, volume," +
"unit_of_volume, weight, unit_of_weight, kind_of_package, barcode, comodity_code, prod_hierarchy_1, prod_hierarchy_2, prod_hierarchy_3," +
"prod_hierarchy_4, prod_hierarchy_5, hierarchy_description_1, hierarchy_description_2, hierarchy_description_3, hierarchy_description_4," +
"hierarchy_description_5, apo_relevant, ean_code, ce_mark, refrigerant_type, country_of_origin, availability_date, ex_ostend_sales_price," +
"currency_key, valid_from, unit_multiplier, unit_of_measurement, validity_date) FROM '\\\\192.168.1.15\\temp\\UK_100845_BBS_MAT.txt' " +
"DELIMITED BY ',' "
var exec = plugins.rawSQL.executeSQL('spaceair', 'sap_products', query)
//flush the client's cache
plugins.rawSQL.flushAllClientsCache(controller.getServerName(), controller.getTableName())
//show the status of the import after completion
var msg = plugins.rawSQL.getException().getMessage(); //see exception node for more info about the exception obj
plugins.dialogs.showErrorDialog('Error', 'SQL exception: '+msg, 'Ok')
This returns the error shown below;
2008-02-27 17:11:06,421 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Th
rowable
java.lang.RuntimeException: com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -19
3: Primary key for table ‘sap_products’ is not unique ASA Error -193: Primary ke
y for table ‘sap_products’ is not unique
at com.servoy.extensions.plugins.rawSQL.SQLProcessor.executeSQL(Unknown
Source)
at com.servoy.extensions.plugins.rawSQL.RawSQLProvider.js_executeSQL(Unk
nown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:33
4)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1254)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2031)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.j
ava:94)
at com.servoy.j2db.scripting.e.call(Unknown Source)
at com.servoy.j2db.develop.debugger.k.a(Unknown Source)
at com.servoy.j2db.develop.debugger.k.access$100(Unknown Source)
at com.servoy.j2db.develop.debugger.k$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Should the order in which I’m importing the columns be in the same order as it is in the text file?
I have also attatched the text file for your reference.
Help would be appreciated.
Thanks in advance…
UK_100845_BBS_MAT.zip (1.64 MB)