Logo

dev-resources.site

for different kinds of informations.

Tips and tricks of the brand new LOAD DATA command

Published at
2/20/2023
Categories
beginners
tutorial
sql
jdbc
Author
intersystemsdev
Categories
4 categories in total
beginners
open
tutorial
open
sql
open
jdbc
open
Author
15 person written this
intersystemsdev
open
Tips and tricks of the brand new LOAD DATA command

The last days I've work with the great new feature: LOAD DATA With this post I would like to share my first experiences with you. The following points do not contain any order or other evaluation. These are only things that I noticed when using the LOAD DATA command. It should also be noted that these points are based on the IRIS Version 2021.2.0.617 which is a preview release. So it may be that my observations do not apply to newer IRIS versions. But maybe they are helpful for others.

1) The file path is on server side

I have done my first tests via JDBC. The first trap I stumbled into: The file and the filepath must-, of course ;-) be on serverside! The JDBC driver handle this not on client side. Probably this is obvious, but I had not considered this at first.

2) The file suffix is not  relevant

The docs says:

"The file name must include a .txt or .csv (comma-separated values) suffix."

According to my observation the behavior is not so. The suffix is irrelevant.

3) Read the docs! ... or where are the error rows?

While loading some datafiles, i missed rows. If there is a problem with a line, this line is ignored. This happens silently in the background and the client is not actively notified. After viewing https://https//youtu.be/jm7bDK0FoiI I've noticed that I have to check %SQL_Diag.Result and %SQL_Diag.Message to see the problems in details. I also noticed that this behavior is already described on this page: https://docs.intersystems.com/iris20212/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_loaddata ... so RTFM ;-)

Some examples about what you can see:

SELECT * FROM %SQL_Diag.Result ORDER BY createTime DESC 

Image description

Check the errorCount column of your loading.

You can see (row) details in %SQL_Diag.Message

SELECT * FROM %SQL_Diag.Message ORDER BY messageTime DESC />

Image description

You can filter for a specific diagResult (%SQL_Diag.Result.ID = %SQL_Diag.Message.diagResult)

SELECT * FROM %SQL_Diag.Message
WHERE diagResult=4
ORDER BY messageTime DESC
/>

Image description

 

4) LOAD DATA is not supported by $SYSTEM.SQL.Schema.ImportDDL

For my sample app Openflights Dataset I've tried to load all external files with LOAD DATA. The Statements are bundled within a text (sql) file where I also create the tables before.

I've learn you can't do that via $SYSTEM.SQL.Schema.ImportDDL.

By the way the documentation of ImportDDL says that not all SQL Statements are supported. Only a few sql statements are listed on this page.

LOAD DATA unfortunately does not belong to... by the way USE DATABASE unfortunately also not.

5) For unicode handling you have change a setting

To avoid problems with data encoding during loading, please make the following setting on the %Java Server: -Dfile.encoding=UTF-8

See more details in this post. This problem should be gone in a next IRIS release.

6) Loading stops with error, but data are loaded

Loading data via JDBC stops with an %qparsets error. That looks like this:

Error: [SQLCODE: <-400>:<Fatal error occurred>]
[Error: <<UNDEFINED>zExecute+83^%sqlcq.OPENFLIGHTS.cls10.1 *%qparsets>]
[Location: <ServerLoop>]

But don't worry the data was loaded anyway :-)  See more details in this post.

This problem should be gone in a next IRIS release.

Andreas

jdbc Article's
30 articles in total
Favicon
Simplify Python-Informix Connections with wbjdbc
Favicon
🚀 Mastering JDBC: Bridging Java and Databases Seamlessly 📊
Favicon
LIBRARY MANAGEMENT SYSTEM USING JAVA AND SQL
Favicon
Java JDBC + IntelliJ + SQLite - A Beginner's Walkthrough
Favicon
Java Backend Management Project
Favicon
JDBC and Streams have never been simpler
Favicon
Quick tip: Using SingleStore for Iceberg Catalog Storage
Favicon
Introducing Kuery Client for those who love writing SQL in Kotlin/JVM
Favicon
Performance tests IRIS - PostgreSQL - MySQL
Favicon
Mastering Conversations: A Guide to Building and Using a Java-Based Chat (StarChat) with IRIS Cloud SQL.
Favicon
Understanding JDBC Three-Tier Architecture: A Detailed Overview
Favicon
Spring Boot Security with JDBC Authentication
Favicon
Wednesday Links - Edition 2024-01-10
Favicon
Constant Lag in CDC Pipeline (JDBC Sink Connector)
Favicon
How to Connect Java Applications to Databases with JDBC
Favicon
Wednesday Links - Edition 2023-08-30
Favicon
How JDBC Paved the Way for Java Frameworks! 🛤️
Favicon
Connect to JDBC in java using MySQL
Favicon
JDBC program for Delete operation
Favicon
Spring JDBC 6 CRUD Operations
Favicon
Java JDBC CRUD Operations in Eclipse using MySql
Favicon
Tutorial - Develop IRIS using SSH
Favicon
Spark Update Optimizations
Favicon
Tips and tricks of the brand new LOAD DATA command
Favicon
Configure the SQuirreL SQL Client to use the SingleStore JDBC Driver
Favicon
Mapping with SCHEMA
Favicon
Built in multi model integration using InterSystems iris data platform
Favicon
Use JDBC to connect TiDB Cloud through TLS
Favicon
Connect your Java application with any SQL databases
Favicon
Java and MySQL

Featured ones: