Skip to main content

Load Flex Table data from another table

  • Mar 17, 2015 12:08 AM UTC
  • 2 replies
  • 21 views

TrovadorSF

Hi,

Instead of loading from a file with JSON data, is there a way to read in the json data from another table that his it in a LONG VARCHAR field?

2 replies

DerrickR
Forum|alt.badge.img
  • Participating Frequently
  • Mar 17, 2015 3:45 PM UTC

Hi TrovadorSF,

 

Thanks for your interest in Flex!

 

Currently the only way to add data to a Flex table is with a COPY statement. UPDATE and INSERT are not available, and therefore you aren't able to use "INSERT SELECT" statements either.

 

We're working on it!

 

In the meantime, you can export your data in delimited format from an existing table and load it back into flex. Like so:

 

vsql -A -c 'select * from my_table;' | tail -n-1 > /tmp/data.delimited

 

  • -A drops "alignment" in output
  • tail -n-1 removes the last row (the row count)

 

vsql -c "copy my_flex from '/tmp/data.delimited' parser fdelimitedparser()"

 

(Note: I didn't run these commands, but they show the gist of what you'd want to use. Sorry if there are small errors.)

 

If the pipe character ("|") is not a safe delimiter, be sure to change the record separator in vsql and in fdelimitedparser. Both of options for doing so.

 

- Derrick


TrovadorSF
  • Author
  • New Participant
  • Aug 25, 2016 5:49 PM UTC

Hi Derrick,

I'm wondering if there has been any update on loading JSON data in from another table?