bind-variables

Oracle - using bind variable in LIKE clause of dynamic cursor

老子叫甜甜 提交于 2020-01-21 04:57:05
问题 I am using dynamic cursor for fetching data. Query that is being executed looks similar to: query := 'SELECT column1, column2 FROM my_table WHERE column1 LIKE ''%:bv1%'''; And the cursor itself is executed like this: OPEN my_cursor FOR query USING my_var1; I also tried to check the query and print it: ... WHERE column1 LIKE '%:bv1%' ... so apostrophes are escaped, but the cursor fetches no data. Is it even possible to use bind variables in LIKE clause and if yes, what did I do wrong? 回答1:

Oracle optional bind variables

扶醉桌前 提交于 2020-01-06 08:04:15
问题 I have a query to select users from a table, given user id. This parameter is optional. This is the query: SELECT * FROM USERS WHERE (USER_ID = :USER_ID OR :USER_ID IS NULL) ORDER BY USER_ID; Now I execute the query finding one user, so :USER_ID takes the valor 1 : SELECT * FROM USERS WHERE (USER_ID = 1 OR 1 IS NULL) ORDER BY USER_ID; This query takes 5 seconds. And then, I add to the previous query OR :USER_ID IS NULL many times. This example takes much more time than the first: SELECT *

PLSQL not all variables bound

纵然是瞬间 提交于 2019-12-13 16:07:26
问题 i keep getting the following errror, 'ORA-01008: not all variables bound', im guessign its all based on my pPostcode param but im not sure. I am a beginner the the whole PLSQL secne and any help would be greatly apriciated here is my procedure: procedure all_customer_postcode(pPostcode in carer.postcode%type ,pReport out SYS_REFCURSOR) is begin open pReport for select c.id, c.forename, c.surname,c.address_1,c.address_2, c.address_3,c.address_4, c.postcode, c.date_of_birth, cf.id from customer

TOAD thinks &String as bind variable

自古美人都是妖i 提交于 2019-12-12 14:31:49
问题 I am developing some ETL with Oracle Data Integrator and sometimes test parts of my code by TOAD. Today I had a problem with TOAD I had a line like AND column_value like('DEV&PROD') when I tried to run the SQL which includes filter above, TOAD ask for the value of PROD, it thought like PROD is a bind or substitution variable. Is there any option in TOAD settings to turn this feature of. I am using bind variable with a column (:), and my data includes & so I need to use it. This code works in

jooq issue with limit and offset

眉间皱痕 提交于 2019-12-12 13:39:11
问题 I have integrated jooq with spring and for all types of querying to the database (MySQL), I am using JDBC Template of spring. jooq library is used here to generate the sql query to pass to jdbc template. Though my rest of the query works fine until I add limit and/or offset to the query. I am generating query as follows: create.select(Factory.field("table_name")) .from("tables t") .where("t.table_schema LIKE '" + schemaName + "'") .limit(10) .offset(2) .getSQL(); I am getting error as follows

Using bind variables in SQL Plus with more than one row returned?

强颜欢笑 提交于 2019-12-11 03:22:40
问题 This is a stupid problem, but I can't seem to get around it. I have a query that's causing trouble in an OCI program, so I want to run it manually in SQL*Plus to check if there is any difference there. This is the query: select e.label as doc_name, e.url, i.item_id, 'multi' as form_type from cr_items i, cr_extlinks e where i.parent_id = :comment_id and e.extlink_id = i.item_id UNION select null as doc_name, utl_raw.cast_to_varchar2(DBMS_LOB.SUBSTR(r.content, 2000, 1)) as url, r.item_id,

sqlplus - using a bind variable in “IN” clause

谁都会走 提交于 2019-12-10 19:05:42
问题 I am setting a bind variable in a PL/SQL block, and I'm trying to use it in another query's IN expression. Something like this: variable x varchar2(255) declare x varchar2(100); begin for r in (select id from other_table where abc in ('&val1','&val2','&val3') ) loop x := x||''''||r.id||''','; end loop; --get rid of the trailing ',' x:= substr(x,1,length(x)-1); select x into :bind_var from dual; end; / print :bind_var; select * from some_table where id in (:bind_var); And I get an error (ORA

Oracle in C#, bind variables, and queries like ID IN (1, 2, 3)

岁酱吖の 提交于 2019-12-06 07:44:57
问题 I'm looking for a C# ODAC adaptation of the following Java technique, where code is able to bind an array of numbers (the array size can vary) into a non-PL/SQL SELECT statement and then use the resulting array in a WHERE ID IN (...) style check. http://rafudb.blogspot.com/2011/10/variable-inlist.html Here's another example of this technique used in OCI-based C programs: Oracle OCI, bind variables, and queries like ID IN (1, 2, 3) Specifically, we want to execute a query like SELECT * FROM

How to get tracing info for binding variables passed through OracleParameter in ODP.NET?

北战南征 提交于 2019-12-06 06:18:39
问题 After Googling a lot and not finding what I'm looking for I decided to ask this question. I'm using binding variables as demonstrated in this awesome article from 2005 titled The Values That Bind by Mark A. Williams, like this: OracleParameter p_APP_NAME = new OracleParameter("p_APP_NAME", OracleDbType.NVarchar2, ParameterDirection.Input); p_APP_NAME.Size = 50; p_APP_NAME.Value = log.Application.Name; cmd.Parameters.Add(p_APP_NAME); I successfully enabled ODP.NET debug tracing but one key

Oracle in C#, bind variables, and queries like ID IN (1, 2, 3)

左心房为你撑大大i 提交于 2019-12-04 12:32:22
I'm looking for a C# ODAC adaptation of the following Java technique, where code is able to bind an array of numbers (the array size can vary) into a non-PL/SQL SELECT statement and then use the resulting array in a WHERE ID IN (...) style check. http://rafudb.blogspot.com/2011/10/variable-inlist.html Here's another example of this technique used in OCI-based C programs: Oracle OCI, bind variables, and queries like ID IN (1, 2, 3) Specifically, we want to execute a query like SELECT * FROM MyTable WHERE ID IN (SELECT * FROM TABLE(:1)) And pass in an array of Numbers into :1 . Talloran Code: