oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
264 stars 75 forks source link

Additional lob API #135

Closed felipenoris closed 3 years ago

felipenoris commented 4 years ago

Hi!! I would like to request some additional lob API, if this is not available.

I'm currently applying a patch in odpi to add these functions, since I can't directly deref this data from the caller.

dpiOracleTypeNum dpiLob_getOracleTypeNum(dpiLob *lob) {
    return lob->type->oracleTypeNum;
}
felipenoris commented 3 years ago

Hi @anthony-tuininga ! Do you mind adding this API to your lib?

anthony-tuininga commented 3 years ago

Thanks for the ping! If I were to add such a function, I would do the following:

int dpiLob_getType(dpiLob *lob, dpiOracleTypeNum *oracleTypeNum)

This is to ensure that you can determine if the function succeeded -- which it will if the LOB value you supply is valid, but won't if it is NULL or invalid in some other way. You can determine if that type refers to character data by simply checking to see if it matches one of DPI_ORACLE_TYPE_CLOB or DPI_ORACLE_TYPE_NCLOB. Another possibility is to add an additional parameter to the function above:

int dpiLob_getType(dpiLob *lob, dpiOracleTypeNum *oracleTypeNum, int* containsCharacterData)

Comments?

felipenoris commented 3 years ago

@anthony-tuininga thanks for your reply! Sorry for the delay.

So for the interface:

int dpiLob_getType(dpiLob *lob, dpiOracleTypeNum *oracleTypeNum)

If what I understand is correct, then this solution will surely work for me.

I took the time to look at my code and definitely I don't need the extra parameter. I can implement it as checking wether it is a DPI_ORACLE_TYPE_CLOB or DPI_ORACLE_TYPE_NLOB as you suggested.

Many thanks!

anthony-tuininga commented 3 years ago

@felipenoris, I've pushed changes to implement this function. Please let me know if this resolves your request. Thanks!

felipenoris commented 3 years ago

@anthony-tuininga Thanks for the patch! I just tested it and it solves this issue.

anthony-tuininga commented 3 years ago

ODPI-C 4.2 has just been released which includes this enhancement. Thanks for the suggestion!