Unhandled exception when importing Oracle db

Posts   
 
    
bhoatvolue
User
Posts: 6
Joined: 02-Sep-2022
# Posted on: 21-Sep-2022 11:31:02   

I am importing an Oracle db which ends up in an unhandled exception as shown below. I suspect that there is something in the database that causes this because I succeed in importing another Oracle db with a simpler schema. Anyway, I think llblgen should come up with some better description of the error.

Object reference not set to an instance of an object.

LLBLGen Pro version 5.9. Build 5.9.2

-----[Core exception]--------------------
   at SD.LLBLGen.Pro.DBDriverCore.DBUniqueConstraint.<>c.<.ctor>b__5_0(DBTableField f)
   at SD.Tools.Algorithmia.GeneralDataStructures.KeyedCommandifiedList`2.<>c__DisplayClass14_0.<IndexElement>b__0()
   at SD.Tools.Algorithmia.UtilityClasses.GeneralUtils.PerformSyncedAction(Action toPerform, Object syncRoot, Boolean isSynchronized)
   at SD.Tools.Algorithmia.UtilityClasses.GeneralUtils.PerformSyncedAction(Action toPerform, Object syncRoot, Boolean isSynchronized)
   at SD.Tools.Algorithmia.GeneralDataStructures.CommandifiedList`1.<>c__DisplayClass44_0.<PerformInsertItem>b__0()
   at SD.Tools.Algorithmia.UtilityClasses.GeneralUtils.PerformSyncedAction(Action toPerform, Object syncRoot, Boolean isSynchronized)
   at SD.Tools.Algorithmia.GeneralDataStructures.CommandifiedList`1.PerformInsertItem(Int32 index, T item)
   at SD.LLBLGen.Pro.DBDriverCore.DBCatalog.ObtainAndInsertUniqueConstraintObjectsFromMetaData(DataTable uniqueConstraints, String columNameSchema, String columNameTable, String columnNameField, String columNameConstraint)
   at SD.LLBLGen.Pro.DBDrivers.Oracle.OracleCatalogRetriever.RetrieveNormalUniqueConstraints(DBCatalog catalogMetaData) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.9\Drivers\Oracle\OracleCatalogRetriever.cs:line 145
   at SD.LLBLGen.Pro.DBDriverCore.DBCatalogRetriever.PerformAdditionalActions(String catalogName, DBCatalog catalogMetaData, IEnumerable`1 actionsToPerform)
   at SD.LLBLGen.Pro.DBDriverCore.DBCatalogRetriever.RetrieveCatalog(String catalogName, List`1 elementsToRetrieve)
   at SD.LLBLGen.Pro.DBDriverCore.DBDriverBase.PopulateCatalogs(Dictionary`2 callBacks, Dictionary`2 elementsToRetrieve)
   at SD.LLBLGen.Pro.Gui.Classes.GuiController.ObtainMetaDataFromDatabase(DBDriverBase driverUsed, Dictionary`2 selectedElements)
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 21-Sep-2022 14:56:34   

The null reference exception is of course not expected so it's not an error we can report more info on, it shouldn't happen at all.

It's likely caused by a unique constraint on a table T which has a field which isn't in the table (based on name).

I don't know how many unique constraints there are in your schema, the designer uses the following query:

SELECT ALL_CONSTRAINTS.*, ALL_CONS_COLUMNS.COLUMN_NAME, ALL_CONS_COLUMNS.POSITION 
FROM ALL_CONSTRAINTS, ALL_CONS_COLUMNS WHERE ALL_CONSTRAINTS.CONSTRAINT_NAME = ALL_CONS_COLUMNS.CONSTRAINT_NAME 
    AND ALL_CONSTRAINTS.OWNER = ALL_CONS_COLUMNS.OWNER AND ALL_CONSTRAINTS.CONSTRAINT_TYPE='U' 
    AND ALL_CONSTRAINTS.OWNER IN ('schema1', 'schema2', ...) 
ORDER BY ALL_CONSTRAINTS.OWNER ASC, ALL_CONSTRAINTS.TABLE_NAME ASC, ALL_CONSTRAINTS.CONSTRAINT_NAME ASC, ALL_CONS_COLUMNS.POSITION ASC

please adjust the ('schema1', 'schema2', ...) section with the schema name(s) of your project, if you use one schema you can just fill in one schema there.

It should give a resultset of all unique constraints of all tables in the schema and the fields in the unique constraints. As we trim the spaces off the names in the unique constraint data returned by that query, my suspicion is that the name of the field in the constraint after that doesn't match with the field in the table.

Frans Bouma | Lead developer LLBLGen Pro
bhoatvolue
User
Posts: 6
Joined: 02-Sep-2022
# Posted on: 22-Sep-2022 09:40:46   

The table below is the culprit. Oracle decides that MSGID should be the primary key. Hence it appears to llblgen as primary key and that seems to derail llblgen. In my understanding your suggestion below was quite spot on. Thx.

``CREATE TABLE "XYZ"."CULPRITTABLE" ( "Q_NAME" VARCHAR2(128 BYTE), "MSGID" RAW(16), ......