1

I wonder if there's some way to insert Byte[] in to my database column using the INSERT statement through my SQL Editor.

For example

INSERT INTO Temp (id,name) VALUES(1,'rg_book');

I just wanna to test my data and I don't want to make a user interface (file uploader ,...etc).

How to write this statement?

0

2 Answers 2

2

The CLR Byte array type (Byte[]) maps to a VARBINARY type in Informix DB2. See typing information here.

If your name field is expecting character data, use the VARBINARY function to convert the data into a binary representation of the string. See here.

For example:

INSERT INTO Temp (id, name) VALUES (1, VARBINARY('rg_book'));
Sign up to request clarification or add additional context in comments.

Comments

1

If I were you I would do the following (if I've understood your question correctly):

  1. Create test console project
  2. Using Foreach or For (on your Byte[] array) compose required Insert's and (for example) add them to some file on a disk.
  3. Run this script in Management Studio to fill in a table.
FileInfo f = new FileInfo(@"d:\Inserts.txt");
Byte[] list = {0, 1, 2};

using (StreamWriter w = f.CreateText())
{
    for (int i = 0; i < list.Length; i++)
    {
        w.WriteLine("INSERT INTO [TEMP] ([id], [Name]) VALUES ({0}, 'rg_book')", list[i]);
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.