| Auszug |
|---|
|
Nuclos calculated attributes: database function CA_, INTID parameter, SORT_CALCULATED_ATTRIBUTES, SQL example, traffic light image. |
Language: Deutsch · English
Calculated attributes
Compute attribute values at runtime via a database function – incl. SQL examples and status traffic lights.
| Status |
|---|
| colour | Blue |
|---|
| title | Application developer |
|---|
|
| Status |
|---|
| colour | Green |
|---|
| title | Updated: Jul 2026 |
|---|
|
| Status |
|---|
| colour | Grey |
|---|
| title | applies to Nuclos 4.2026.x |
|---|
|
What is a calculated attribute?
Instead of storing a fixed value, a calculated attribute derives its content from a function at database level. The value is recomputed at runtime and displayed – without having to save the record. Typical cases: an article's annual revenue, computed date values, status traffic lights.
Calculated attributes behave almost like normal attributes (shown in layouts and result lists) but are not stored in the database. Their value therefore cannot be set by a rule; reference fields cannot be calculated.
| Warnung |
|---|
|
Use sparingly: the calculation can be very time-consuming – especially in searches and result lists. |
| Info |
|---|
|
Sorting of calculated attributes in the result list is disabled by default and can be enabled via the SORT_CALCULATED_ATTRIBUTES parameter. |
- Via a database object: create a database function under database objects. It receives the record ID as a parameter and returns the result value (the data type must match the attribute). The function name starts with
CA_ (calculated attribute). - Via a data source: the calculated attribute is defined through a data source.
Example 1: calculate available articles
Computes stock − reserved. The parameter id is the INTID of the current object; the return value is varchar2 (attribute values are stored as strings).
| Codeblock |
|---|
|
CREATE OR REPLACE FUNCTION CA_ARTIKELVERFUEGBAR(id IN number) RETURN varchar2 IS
summe number(12);
bestand number(12);
reserviert number(12);
begin
SELECT strvalue INTO bestand
FROM t_ud_go_attribute
WHERE intid_t_md_attribute = (SELECT intid FROM t_md_attribute WHERE strattribute='artikelBestand')
AND intid_t_ud_genericobject = id;
SELECT strvalue INTO reserviert
FROM t_ud_go_attribute
WHERE intid_t_md_attribute = (SELECT intid FROM t_md_attribute WHERE strattribute='artikelReserviert')
AND intid_t_ud_genericobject = id;
summe:=bestand-reserviert;
RETURN(summe);
end CA_ARTIKELVERFUEGBAR; |
Example 2: return a traffic light as an image
A calculated attribute can also return an image – ideal for status traffic lights. The images are uploaded beforehand as resources (Configuration → Other → Resources).

Traffic light as a calculated attribute.
| Codeblock |
|---|
|
CREATE OR REPLACE FUNCTION C31G_CA_PROJEKT_VERFUEGBARKEIT(id numeric)
RETURNS bytea AS
$BODY$
DECLARE
ist numeric(9,2);
soll numeric(9,2);
bild bytea;
BEGIN
select dblfortschritt, dblusedbudget / dblworkingbudget * 100 into ist, soll from c31g_projekt where intid=id;
if (ist = 100) then
bild := null;
else
if (ist >= soll) then
select blbcontent into bild from t_md_resource where strname = 'Ampel grün';
else
select blbcontent into bild from t_md_resource where strname = 'Ampel rot';
end if;
end if;
RETURN bild;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100; |
Usage
In the BO wizard the calculated attribute is linked in step 7 (attribute definitions).

Linking in the BO wizard.
Related pages
Business object
Attributes.
Open →
Database objects
DB functions.
Open →
Special data types
Data types.
Open →