Closed sakshatshinde closed 8 months ago
@sakshatshinde
Getting the following error:
InvalidBindIndex(1)
That's because you put :1
between single quotation marks. Oracle think it as a part of a string, not a bind variable.
The following code will work. In the case, id
should start with or end with %
or both.
"like" => format!("SELECT * FROM {table} where {col} {operator} :1"),
If you intend that rows where the col
column contains id
should be fetched when operator
is like
,
"like" => format!("SELECT * FROM {table} where instr({col}, :1) > 0"),
Otherwise, construct %:1%
in SQL, though it fetches all rows where col isn't null when id
is null or an empty string.
"like" => format!("SELECT * FROM {table} where {col} {operator} '%' || :1 || '%'"),
I just wanted to grab the rows if the given substring (id) exists in the col
.
Example row
1 | I have an apple | 2 | I have a banana |
select * from table where col like '%apple%'
So it should return the 1st row.
I think the last option would work for me.
FYI.
"in" => format!("SELECT * FROM {table} where {col} {operator} (:1)"),
It doesn't work as you might expect. You cannot pass multiple values to a single bind paramater. See #25
I just wanted to grab the rows if the given substring (id) exists in the col.
In that case,
"like" => format!("SELECT * FROM {table} where instr({col}, :1) > 0"),
Thank you instr
did the trick!
Am I doing this right? This works for
=
operator but doesn't forlike
with the % wildcardsGetting the following error:
InvalidBindIndex(1)