ODBC Output with delimiters in values
Posted: Sat Mar 19, 2022 7:30 am
Hi all,
Just looking for a bit of advice to see if there is an easy way to solve this before I go down a path that will cause a lot of time/effort to be spent on developing something.
Here are some details of what I'm trying to do:
I have a cube that I'd like to export to a SQL DB.
The cube has 80+ measures that need to be exported with a mix of numeric and string values.
The string values are causing issues while doing a simple insert to the SQL table as they contain possible delimiter values (i.e. single quote, double quote, commas)
As an example of a an string value;
Jé 12 - DC Sacacoyo " Km 00.1 123 Anywhere, Any'where Avenue
A sample of the TI code is as follows:
## Insert into SQL table
sSQL = 'INSERT INTO [MYDB].[MYTable] ( [RecordID], [Address], [Account], [Time] )
VALUES ( ''' | vID | ''', ''' | sQualifiedString1 | ''', ''' | vAccount | ''',''' | sTime | ''' )';
OdbcOutput ( cODBC, sSQL );
I can parse out the single and double quote but am unable to remove the comma and what's happening is that the text after the comma is being inserted into the next field. So my sQualifiedString1 is being cutoff at the comma, and the remaining string after the text is being inserted to the account field.
I'm hoping there is a cleaner way than checking every string cell for possible delimiter characters and any advice would be greatly appreciated.
Thank you.
Just looking for a bit of advice to see if there is an easy way to solve this before I go down a path that will cause a lot of time/effort to be spent on developing something.
Here are some details of what I'm trying to do:
I have a cube that I'd like to export to a SQL DB.
The cube has 80+ measures that need to be exported with a mix of numeric and string values.
The string values are causing issues while doing a simple insert to the SQL table as they contain possible delimiter values (i.e. single quote, double quote, commas)
As an example of a an string value;
Jé 12 - DC Sacacoyo " Km 00.1 123 Anywhere, Any'where Avenue
A sample of the TI code is as follows:
## Insert into SQL table
sSQL = 'INSERT INTO [MYDB].[MYTable] ( [RecordID], [Address], [Account], [Time] )
VALUES ( ''' | vID | ''', ''' | sQualifiedString1 | ''', ''' | vAccount | ''',''' | sTime | ''' )';
OdbcOutput ( cODBC, sSQL );
I can parse out the single and double quote but am unable to remove the comma and what's happening is that the text after the comma is being inserted into the next field. So my sQualifiedString1 is being cutoff at the comma, and the remaining string after the text is being inserted to the account field.
I'm hoping there is a cleaner way than checking every string cell for possible delimiter characters and any advice would be greatly appreciated.
Thank you.