Database uniqueidentifier column

Post Reply
Jamesnic7
Newbie
Posts: 6
Joined: Sat Dec 31, 2016 3:21 pm

Database uniqueidentifier column

Post by Jamesnic7 »

Hi

New to the forum and Switch so forgive me if this is a stupid question.
I am trying to access from a script an SQL db column that is a type 'uniqueidentifier'.
The intention is to write it as privatedata for use later in the flow.
While SwitchScripter returns a value (although the text encoding looks wrong) Switch itself hangs and requires a restart.
Is there a way to deal with this data type within Switch or is it better to try a different approach?
Thanks for any advice

James
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Re: Database uniqueidentifier column

Post by freddyp »

Read the scripting documentation Scripting reference - Database module - Text encoding.

I have not tried but I would think that you will have to use getBinary for the uniqueidentifier type. As you can see in the documentation the return value of getBinary is a ByteArray object. You will have to convert that to a string in order to be able to add it to private data.
Jamesnic7
Newbie
Posts: 6
Joined: Sat Dec 31, 2016 3:21 pm

Re: Database uniqueidentifier column

Post by Jamesnic7 »

Hi

Thanks freddyp :D
Yes your spot on just did a check and this is BINARY.
I assume it should be possible to read and convert as suggested.
However I have a second table that uses the same field that I need to access.
Is it likely I will be able to use the (now String) Private data created to search or am I wasting my time because of the Data Type conversion?
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Re: Database uniqueidentifier column

Post by freddyp »

No, you are not wasting your time. You can create a ByteArray object from a string:

Code: Select all

var bin = new ByteArray(stringFromPrivateData);
You may have to experiment a bit with the text encoding, eg:

Code: Select all

var bin = new ByteArray(stringFromPrivateData,"UTF-8");
More on this in the documentation on ByteArray and text encoding.
Post Reply