3

I have procedure:

create or replace function add_task( _g uuid, _name character varying, _ind bytea, _rate integer, _type integer )
returns void as 
$$
begin       
    insert into tasks (g, name, ind, rate, type) values (_g, _name, _ind, _rate, _type);    
end;
$$
language plpgsql;

I need to insert bytea field (_ind). The data is represented as bytes sequence and may be various.

std::vector<uint8_t> data = { 0x01, 0x02, 0x03 };
tr.exec("SELECT add_task_type('" + guid + "', '" + name + "', ......

How I can insert bytea field using SELECT string query?

1 Answer 1

3

The most straight forward way would be to use hex format.

SELECT E'\\xDEADBEEF';

See http://www.postgresql.org/docs/9.1/static/datatype-binary.html#AEN5285

Sign up to request clarification or add additional context in comments.

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.