Informix

Informix

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only

Best practice to insert CLOB/BLOB with generic ESQL/C code

  • 1.  Best practice to insert CLOB/BLOB with generic ESQL/C code

    Posted Thu June 04, 2020 09:11 AM
    Hello,

    What is the best solution to insert CLOB/BLOB values from ESQL/C code, when you don't know the storage options of CLOB/BLOB of the SQL columns, because you write generic code that can execute any kind of SQL statement?

    To insert a CLOB/BLOB, you create / initialize an ifx_lo_t object, by using ifx_lo_def_create_spec() / ifx_lo_create()...

    So far I do the following (shorten version edited by hand, without error checking):
    ifx_lo_create_spec_t *cs;
    ifx_lo_t *lo = (ifx_lo_t *) v->sqldata; // mallocated ...
    int lofd;
    ifx_lo_def_create_spec(&cs);
    lofd = ifx_lo_create(cs, LO_RDWR | LO_LOCKALL, lo, &err);
    ifx_lo_write(lofd, buf, len, &err);
    ifx_lo_close(lofd);
    ifx_lo_spec_free(cs);

    According to the doc, this should take "storage characteristics from the inheritance hierarchy" ...

    Is this ok?

    Is it better to use the "system-specified storage characteristics", passing NULL for the creation specs?

    What about the LO_* flags like LO_LOCKALL ...?

    Should I make all these creation options configurable?

    Thanks!
    Seb

    ------------------------------
    Sebastien FLAESCH
    ------------------------------

    #Informix