You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cds/cdl.md
+27-2Lines changed: 27 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -787,12 +787,37 @@ By using a cast, annotations and other properties are inherited from the provide
787
787
788
788
### Views with Parameters
789
789
790
-
You can equip views with parameters that are passed in whenever that view is queried. Default values can be specified. Refer to these parameters in the view's query using the prefix `:`.
790
+
You can equip views with parameters that are passed in whenever that view is queried. Default values can be specified.
791
+
Refer to these parameters in the view's query using the prefix `:`.
791
792
792
793
```cds
793
794
entity SomeView ( foo: Integer, bar: Boolean )
794
795
as SELECT * from Employees where ID=:foo;
795
796
```
797
+
798
+
When selecting from a view with parameters, the parameters are passed by name.
799
+
In the following example, `UsingView` also has a parameter `bar` that is passed down to `SomeView`.
800
+
801
+
```cds
802
+
entity UsingView ( bar: Boolean )
803
+
as SELECT * from SomeView(foo: 17, bar: :bar);
804
+
```
805
+
806
+
For Node.js, there's no programmatic API yet. You need to provide a [CQN snippet](/cds/cqn#select).
807
+
808
+
In CAP Java, run a select statement against the view with named [parameter values](/java/working-with-cql/query-execution#querying-views):
809
+
810
+
::: code-group
811
+
```js [Node]
812
+
SELECT.from({ id:'UsingView'. args: { bar: { val:true }}})
813
+
```
814
+
```Java [Java]
815
+
var params =Map.of("bar", true);
816
+
Result result = service.run(Select.from("UsingView"), params);
817
+
```
818
+
:::
819
+
820
+
796
821
[Learn more about how to expose views with parameters in **Services - Exposed Entities**.](#exposed-entities){ .learn-more}
797
822
[Learn more about views with parameters for existing HANA artifacts in **Native SAP HANA Artifacts**.](../advanced/hana){ .learn-more}
798
823
@@ -1817,7 +1842,7 @@ service MyOrders {
1817
1842
entity OrderWithParameter( foo: Integer ) as select from data.Orders where id=:foo;
1818
1843
}
1819
1844
```
1820
-
A [`view with parameter`](#views-with-parameters) modeled in the previous example, can be exposed as follows:
1845
+
A parametrized view like modeled in the section on [`view with parameter`](#views-with-parameters) can be exposed as follows:
0 commit comments