name of variable with braces - what is it in kotlin [duplicate] - kotlin

This question already has an answer here:
What is this syntax, parentheses around variable/property names at declaration site?
(1 answer)
Closed 9 months ago.
I have such code:
val (valName) = list[fileAndMediaHolder.adapterPosition] as FileAndMediaItem
() - what is it in Kotlin?

Sometimes it is convenient to destructure an object into a number of variables, for example:
val (name, age) = person

Related

Passing an array of values as a parameter to a SQL query [duplicate]

This question already has answers here:
How to execute an IN lookup in SQL using Golang?
(9 answers)
How to pass variable ids to statement.Query() in golang?
(1 answer)
Closed 10 months ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
I have a sql query like
SELECT SOME_FIELD FROM SOME_TABLE WHERE ID_FIELD IN ("abc", "def", "...", ...)
And an array that i need to pass as a parameter
p := []interface{"abc", "def", "blah", "foo"}
I prepare the statement:
stmt, err := conn.Prepare("SELECT SOME_FIELD FROM SOME_TABLE WHERE ID_FIELD IN (:1)")
rows, err := stmt.Query(p) // <- this complains that I pass an array as a value
I know that i can convert that array into a comma separated string of quoted values, but i wonder if there is a better way of passing an array of values as a parameter to a query
For moderators who closed my question previously: There is a similar question How to pass variable ids to statement.Query() in golang? but it is not the same. The answer to that question suggests unpacking the array when passing to the Query, like stmt.Query(...p) - but this will not work in my case as this will be treated as a number of parameters instead of one array parameter

Oracle functions - Unknown number of parameters [duplicate]

This question already has answers here:
Oracle equivalent of Java's Varargs
(2 answers)
Closed 3 years ago.
Can a function in Oracle have an unknown number of parameters?
for example: create function sample(parameters... varchar)
so it can call something like: sample("A") or sample("A","B") or sample("A","B","C")
You can use sys.odcivarchar2list:
function sample(parameters sys.odcivarchar2list)
And then call it by:
sample(sys.odcivarchar2list('A','B','C'))
or
sample(sys.odcivarchar2list('A'))
and so on.

Ternary Conditional Operator in kotlin [duplicate]

This question already has answers here:
How to write ternary conditional operator?
(33 answers)
Closed 4 years ago.
What is the equivalent of this expression in Kotlin.
a ? b : c
This is giving error.
In Kotlin, if statements are expressions. So the following code is equivalent:
if (a) b else c
Hope it's working for you.

Is it possible to reference a variable via string manipulation? [duplicate]

This question already has answers here:
T-SQL: How to use parameters in dynamic SQL?
(4 answers)
how to pass variables this in dynamic query in sql
(1 answer)
Closed 7 years ago.
I have a series of datetime variables that need to be referenced, and the key to which variable needs referencing is reached by using substring on another field. I can create the name of the variable as a string using string manipulation, something like this:
'#' + SUBSTRING(field, CHARINDEX(',', field) + 2, LEN(field) - CHARINDEX(',', field) + 1) + 'start'
Is there a way to get SQL to recognize that this is the name of one of my variables? Some kind of function to convert the string?

SQL Detecting if only integers in varchar [duplicate]

This question already has answers here:
How to get only numeric column values?
(5 answers)
Closed 8 years ago.
I'm hoping that there is some basic string function which will do this that I just haven't found yet.
Specifically for scenarios where length of the string is unknown:
Is there a succinct method of telling if a string variable only contains [0-9] values?
For example, the following method works but require additional mention of all possible characters that would appear other than numerals.
SELECT VAR
FROM #TABLE1
WHERE VAR NOT LIKE '%[A-Z]%'
and
SELECT VAR
FROM #TABLE1
WHERE VAR LIKE '[0-9][0-9][0-9][0-9][0-9]...'
doesn't work because the length of the VAR is required for this filter.
Thanks in advance
SELECT VAR FROM #TABLE1
WHERE VAR NOT LIKE '%[^0-9]%'