Mike Dezarre wrote:hi guys, can you help me with the commenting on this code snippet -> codelines with //??? i dont know what is happening here...
From looking at the groovy.sq.Sql API documentation, I'd say the SQL is saying it wants to fetch a column called "WERT" (German for "value" - not a good choice for a column name) from the table ad_user_env for a given user_ref.
Then the call to sql.firstRow provides the required user reference (although the firstRow() docs seem to suggest that bind values should be provided as a list).
Anyway, the call to firstRow is supposed to fetch the "WERT" value for the required row in the database and store it in the result variable. I think that's what the ".wert" bit after the firstRow() call does - it gets the "wert" value that was returned in the firstRow query results. But I don't know if it will work like this, as the column name is UPPER in the SQL but lower here.
This is basically the same kind of thing, but this time the SQL SELECT includes several bind variables, so you need to provide several values as a list in your firstRow() call.
So I think szenario() returns the value we found in the first SQL query and then the svr() function uses that value in this query, but I'm not sure.
Anyway, it seems like a complicated way of doing something you could probably do more easily in a single query. And to be honest, you should probably find a better tutorial if this is somebody else's code that you're trying to learn from.
Meanwhile, it sounds like you might need to brush up on basic SQL, and always check the API docs if you're not sure what a method like firstRow() does.