[BulkInsert] [BulkInsert] Specified cast is not valid
Forge component by João Pedro Abreu
Application Type
Reactive
Service Studio Version
11.10.11 (Build 39017)
Platform Version
11.8.0 (Build 12006)

Hi guys,

I have the error "BulkInsert: Specified cast is not valid" when I try to insert the list into the Oracle database.

Details:

[1] BulkInsert: Specified cast is not valid.
   at OutSystems.NssBulkInsert.CssBulkInsert.MssBulkInsert(Object ssRecordList, String ssTableName, String ssColumnsToIgnore, String ssReferenceColumns, Boolean ssUseTableLock, String ssCatalog, String ssExternalDatabaseConnectionName)
   at SampleProject.RssExtensionBulkInsert.MssBulkInsert(HeContext heContext, Object inParamRecordList, String inParamTableName, String inParamColumnsToIgnore, String inParamReferenceColumns, Boolean inParamUseTableLock, String inParamCatalog, String inParamExternalDatabaseConnectionName)

[2] Specified cast is not valid.
   at OutSystems.NssBulkInsert.CssBulkInsert.OracleBulkInsert(IOSList recordList, String tableName, String columnsToIgnore, Dictionary`2 recordFields, String Catalog, String ExternalDatabaseConnectionName)
   at OutSystems.NssBulkInsert.CssBulkInsert.MssBulkInsert(Object ssRecordList, String ssTableName, String ssColumnsToIgnore, String ssReferenceColumns, Boolean ssUseTableLock, String ssCatalog, String ssExternalDatabaseConnectionNam 

Here is the flow of the function:

How to know which column/attribute has an issue to cast the datatype?

Does anyone know how to solve this issue?


Thanks in advance.

Hello Asyraf.

Where comes the ID?

Do you need to have it there?

I am asking because according to the screenshot from an example we have a structure and an ExampleData entity and we don't have any column to ignore. Is this the same use case?

Also if you have columns to ignore be aware this cloud be case sensitive.

Regards

Gonçalo Almeida


Hello Goncalo Almeida,

Thank you for your reply.

For my case, I'm using the Database Entity directly, so the ID is the identifier of the table. I'm not sure to ignore that column or not (set the ID as 0). I already tried both ways, but still, receive the same error.

Should I ignore the column ID? Noted for the case sensitive. And I need to change that to get from entity attribute aggregate (if needed to ignore).

Or I should use a custom structure for that?

Regards.

Asyraf

Suggestion, can we use "Convert.ToInt32(columnData[i])" instead of "(int)columnData[i]"

and the code can be simplified from

int[] intParam = new int[columnData.Length];
for (int i = 0; i < columnData.Length; i++)
{
   intParam[i] = (int)columnData[i];
}
param = new OracleParameter(prop.name(true), OracleDbType.Int32);
param.Value = intParam;

to something like

int[] intParam = columnData.Select(x => Convert.ToInt32(x)).ToArray();
param = new OracleParameter(prop.GetName(true), OracleDbType.Int32)
{
   Value = intParam
};
changes.txt

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.