cancel
Showing results for 
Search instead for 
Did you mean: 

Vew is not working in CAP (Joining condition on Generated IDs )

0 Kudos

Hi Folks,

I have two tables Header and Items, both table are as below:-

entity Header: cuid, managed,lockTransaction{
                 prop1: String(10); 
                 prop2: String(10); 
                 prop3: String(40); 
                 items      : Composition of many Items on $self = items.parent;

entity Items: cuid{
              parent  : Association to Header;
              ItemsProp1: String(4);                 
              ItemsProp2: String(40);             
              ItemsProp3: String(100);    
              ItemsProp4: String(40);              

 define view XXReport as
            select from Header as h 
            left outer join Items as i 
            on h.ID = i.parent_ID           
         {
        key h.prop1,
            h.prop2,
            h.prop3,
            i.ItemsProp1,
            i.ItemsProp2,
            i.ItemsProp3,
         }
         order by prop1; 

Throwing error that, i.parent_ID property not found. 

but same is working on CQL.

let items = await tx.run(
			SELECT.from(Items).where({
				parent_ID: req.data.ID,
			})
		);

But this is working. 

Accepted Solutions (0)

Answers (2)

Answers (2)

pfefferf
Active Contributor

parent_ID is a property not available during design time. It is created during compilation and finally available in the runtime object (therefore the query you tried works).

In the design time phase you have to use the association name for the on condition like:

 view XXReport as
            select from Header as h 
            left outer join Items as i 
            on h.ID = i.parent.ID           
         {
        key h.prop1,
            h.prop2,
            h.prop3,
            i.ItemsProp1,
            i.ItemsProp2,
            i.ItemsProp3,
         }
         order by prop1;
hjb
Advisor
Advisor
0 Kudos