-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example for selecting from view with parameters #839
base: main
Are you sure you want to change the base?
Conversation
@renejeglinsky : this is the example on using a view with parameters that we talked about yesterday. @agoerler @johannes-vogel : do you have docu/examples showing how to select from a view w/ params in the runtimes that we could link here? This was explicitly asked for in a cap issue. |
We do not have a sample as we do not have a proper API for that. As of now, it's basically a CQN snippet you need to provide |
entity UsingView ( bar: Boolean ) | ||
as SELECT * from SomeView(foo: 17, bar: :bar); | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johannes-vogel Could you translate your example on this example? Does it make a difference if it's a view with param or a view selecting from a view with params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean this example you added in a comment:
SELECT.from({ id: 'ViewWithParams', args: { p1: {val: 1}, p2: {val:2} })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Node.js, there's no programmatic API yet. You need to provide a [CQN snippet](/cds/cqn#select). | |
For Java, you [build a select statement and execute it with the corresponding named parameters](/java/working-with-cql/query-execution#querying-views). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johannes-vogel @MattSchur @agoerler Is the previous suggestion fine for you?
as SELECT * from SomeView(foo: 17, bar: :bar); | ||
``` | ||
|
||
**TODO** add links to how to write queries on views w/ parameters in the runtimes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
**TODO** add links to how to write queries on views w/ parameters in the runtimes. | |
In CAP Java, run a select statement against the view with named [parameter values](/java/working-with-cql/query-execution#querying-views): | |
```Java | |
var params = Map.of("bar", true); | |
Result result = service.run(Select.from("UsingView"), params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> #909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johannes-vogel If you'd provide a similar specific example, I'd put both examples in a Node/Java code group.
No description provided.