db2 - SQLBindParameter with variable length strings -


how use sqlbindparameter write array of strings varchar field in db2 in memory-efficient way?

the example in db2 docs this

sqlchar description[num_prods][257] = {     "aquarium-glass-25 litres", "aquarium-glass-50 litres",     "aquarium-acrylic-25 litres", "aquarium-acrylic-50 litres",     "aquarium-stand-small", "aquarium-stand-large",     "pump-basic-25 litre", "pump-basic-50 litre",     "pump-deluxe-25 litre", "pump-deluxe-50 litre",     "pump-filter-(for basic pump)",     "pump-filter-(for deluxe pump)",     "aquarium-kit-small", "aquarium-kit-large",     "gravel-colored", "fish-food-deluxe-bulk",     "plastic-tubing" };  rc = sqlbindparameter(hstmt, 2, sql_param_input, sql_c_char, sql_varchar, 257, 0, description, 257, null); 

i can work without issues isn't efficient since each string stored using 256 characters(+null-terminator) regardless of actual length. more generally, if had 1 long string (say 500 chars) , every other string 1 character, still need two-dimensional array of size [num_strings][500] wastes lot of memory.

what pass sqlbindparameter array looks like

sqlchar* description[num_strings]; 

where each element of array points string. more memory-efficient since each string uses space needs can't figure out how work using sqlbindparameter. appreciated.

note: general answers db great answers specific db2 helpful.

the sizes working involve millions of strings varying lengths being memory-efficient significant factor.

i using db2 on linux, specific usecase, example find in db2 z/os docs. work correctly though except memory usage issue.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -