Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v6.0
  HXTT Cobol v3.0
  HXTT DBF v6.0
  HXTT Excel v5.0
  HXTT Paradox v6.0
  HXTT Text(CSV) v6.0
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT XML v2.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Beijing City (abbr, HXTT)

HXTT Text(CSV)
Using text driver to parse denormalized data
John Johnson
2017-11-03 11:49:37.0
I develop solutions for an RSA product that includes a version of the HXTT Text JDBC driver. I have a situation where I need to parse data that is packed into a field from a CSV file; the value is basically a CSV within a CSV. I see there is a split function referenced in the documentation, but I cannot find any useful examples for how it can be used within a SELECT statement. My ultimate goal is to produce normalized query results.

Simple example, the input CSV might look like:

1,"a,b,c,d"
2,"e,f,g"

The output that I'm looking for is:

1 a
1 b
1 c
1 d
2 e
2 f
2 g

I know how to achieve the above with both Oracle and MS SQL, but it's not clear how to do this with the HXTT Text driver. Can you provide any suggestions?
Re:Using text driver to parse denormalized data
HXTT Support
2017-11-06 05:40:47.0
What's the sql in Oracle or MS SQL?
Re:Re:Using text driver to parse denormalized data
John Johnson
2017-11-06 06:26:10.0
The solutions are very different for each database. For Oracle, this is the basic pattern:

SELECT REGEXP_SUBSTR('a,b,c,d', '[^,]+', 1, LEVEL) VAL FROM DUAL
CONNECT BY REGEXP_SUBSTR('a,b,c,d', '[^,]+', 1, LEVEL) IS NOT NULL

For MS SQL, I found this article that describes a few different approaches:

https://stackoverflow.com/questions/5722700/how-do-i-split-a-delimited-string-in-sql-server-without-creating-a-function

Lack of support for "Common Table Expression" (CTE) and XML in the HXTT Text driver seem to get in the way for any of the approaches described in that thread.

The only thing I spotted in the documentation that might work is the SPLIT function that conceptually sounds like the STRING_SPLIT function in newer MS SQL Server versions. But I haven't been able to get any useful output.
Re:Re:Re:Using text driver to parse denormalized data
HXTT Support
2017-11-06 08:38:07.0
HXTT Text (CSV) supports CONNECT BY, CUBE, ROLLUP, CUBE, and so on. I don't think CONNECT BY can do it in Oracle for such a table.

For CSV, you can use:
SELECT column1,wantValue FROM testvi, (VALUES 'a','b','c','d','e','f','g' ) AS matchValues(wantValue) where INSTR(column2+',', wantValue+',')>0 ;
Re:Re:Re:Re:Using text driver to parse denormalized data
HXTT Support
2018-02-02 05:36:43.0
A new feature will be available in 48 hours.

Split Multivalue Column Into Rows

If each row has multiple multi value columns, a special subquery table can be used in special join sql. For instance,

select User,Role from aTable,(select split(aTable.Roles,',') as Role) AS bTable;

select User,Role,Year from aTable,(select split(aTable.Roles,',') as Role,split(aTable.Years,',') as Year) AS bTable;

Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 1999-2017 Heng Xing Tian Tai Lab of Beijing City. | All Rights Reserved. | Privacy | Legal | Sitemap