Hello,
We're using Oracle 11g and LLBL Gen Pro 3.1 with adapter-templates.
I am fairly new to llblgen and want to achieve the following:
I have a master - detail table: ProductName and NamePart. The ProductName consists of several PartNames, so the ProductName-table has several foreign keys to the NamePart-table.
I am trying to update a ProductName-entity and it's related NameParts in a recursive SaveEntity call. This works fine when I fill the foreign key of the ProductName with the primary key of a NamePart.
However when I create a new NamePart-Entity, add this to the ProductName-Entity and then call SaveEntity, the new NamePart gets inserted, but the foreign key of the ProductName is not updated.
PrefetchPath2 path = new PrefetchPath2((int)EntityType.ProductNamenEntity);
path.Add(ProductNamenEntity.PrefetchPathNaamdelenSrt);
taxnaam = new ProductNamenEntity(id);
adapter.FetchEntity(taxnaam , path);
// create a new NamePart
NaamdelenEntity soortEnt = new NaamdelenEntity();
soortEnt.SType = stype.SelectedValue;
if (nieuweSoortNaam)
{
soortEnt.Naam = soort.Text;
soortEnt.NdlType = "SRT";
}
taxnaam.NaamdelenSrt = soortEnt;
adapter.SaveEntity(taxnaam, false, true);
Is it possible to save this in a single SaveEntity-call, or should I save the NamePart first and set its primary key to ProductName foreign key?
The generated queries are :
This inserts the NamePart OK
Query: INSERT INTO "PSCIMP"."PSC_NAAMDELEN" ("NAAM", "NDL_NDL_ID", "NDL_TYPE", "S_TYPE") VALUES (p1, p2, p3, p4)
Parameter: p1 : String. Length: 80. Precision: 0. Scale: 0. Direction: Input. Value: "test 7".
Parameter: p2 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 366.
Parameter: p3 : String. Length: 3. Precision: 0. Scale: 0. Direction: Input. Value: "SRT".
Parameter: p4 : String. Length: 1. Precision: 0. Scale: 0. Direction: Input. Value: "N".
The foreign key is set with "undefined value"
Query: UPDATE "PSCIMP"."PSC_PRODUCT_NAMEN" SET "NDL_ID_SRT"=p1 WHERE ( "PSCIMP"."PSC_PRODUCT_NAMEN"."PNM_ID" = p2)
Parameter: p1 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: <undefined value>.
Parameter: p2 : Int32. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 102917.
Can someone point me in the right direction?
Annet