Skip to main content

Hi, im trying to retrieve the parent_row_id from a newly added row. However @ and T1 both dont work. Anyone knows how I should fix this?

select top 1 step_nr + 1from calculation_step--where calculation_method_id = t1.calculation_method_id «order by step_nr desc

 

 

Hey Dennis,

Is this a Default value expression for a Task parameter? Or for a different object?


For a datamodel column.


Can you show the datamodel? I'm trying to understand what your goal is and possibly can give an alternative.


calculation_method 1 - * calculation_step

When adding a new calculation step row it should take the maxvalue step_nr and add + 1. It should filter on the calculation_method_id, because steps belong to methods.

Is that sufficient enough?

Error message for reference:

 

 


Okay, that clears it up. I'm afraid you will not be able to use t1. nor @something, because Default value expressions cannot do that: Data model | Thinkwise Documentation

Query - The expression used to determine the default value. The query cannot use values from a new record.

Examples: getdate() or dateadd(month, 1, getdate())

The correct way to do what you would like to achieve is using Default logic. In here you can access all the data of the current row and you will be able to set the column value.

It will most likely be similar to this:

if @cursor_from_col_id is null -- Initially
and @default_mode = 0 -- Insert
or @step_nr is null -- If for some reason it has no value, set a value
begin
select top 1 @step_nr = s.step_nr + 1
from calculation_step s
where s.calculation_method_id = @calculation_method_id
order by s.step_nr desc
end

Hope this helps!


Thanks, will see to it straight away.


Reply