cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to insert binary data using vc++

Former Member
0 Likes
6,729

Hello,

I am an engineering student working on a project in which sql anywhere will works as a back-end database. I have faced a problem to insert binary data into tables using

FUNC_INFO( extern, void, esqlentry, dbpp_execute_imm, (SQLCA ,char ,unsigned short int ))

I also try to run FUNC_INFO( extern, void, esqlentry, dbpp_prepare, (SQLCA ,char ,char ,short int ,char ,struct sqlda ,unsigned int )), but fails because there is no documentation found on net about these functions.

Please guide me, I am waiting for a reply.

Thanks

View Entire Topic
ian_mchardy
Product and Topic Expert
Product and Topic Expert

It is unsupported and undocumented to call dbpp_prepare directly. You must use embedded SQL (EXEC SQL...) and use the sqlpp pre-processor.

To insert binary data into a table using Embedded SQL, you may want to do something like the following (assuming the data to be inserted is in source_data, and the table you want to insert into is my_table with one column):

EXEC SQL BEGIN DECLARE SECTION;

DECL_LONGBINARY(100000) binary_host_var;

EXEC SQL END DECLARE SECTION;

memcpy( binary_host_var.array, source_data, source_data_len );

binary_host_var.stored_len = source_data_len;

db_string_connect( &sqlca, "uid=dba;pwd=sql" );

EXEC SQL INSERT INTO my_table values( :binary_host_var );

EXEC SQL COMMIT;

db_string_disconnect( &sqlca );

VolkerBarth
Contributor
0 Likes

What exactly do you mean with "everything at run time dynamically"?

I'm sure there are even more infos available but I would strongly recommend to have a look at the docs.

Former Member
0 Likes

I saw all suggested documents already, please check link below: ftp://58.130.54.4/cmis/ediasoft100315/ediasoft/asa9/SQL%20Anywhere%209/h/sqlfuncs.h

Now I want to know about ant documentation or another help how can I use the functions of "sqlfuncs.h", I done all works except insertion of binary, long binary & long varchar data. Please help me.