Questions tagged [bind-variables]

A bind variable is an unspecified value (in other words, a placeholder) in a prepared database statement/command. The actual values of the bind variable is to be assigned when the statement or command is executed.

147 questions
2
votes
1 answer

Oracle Bind Variable to_date parameter Error

I am writing code which uses a Python script to execute a SQL (Oracle) statement, as shown below: PYTHON: with open(os.path.join(WORKING_PATH, "sql", "fetchCalendar.sql"), 'r') as fetch_date = fetch.read() #(Some other code) CD =…
NicholasTW
  • 85
  • 1
  • 10
2
votes
2 answers

ORA-01722: invalid number - Python with cx_Oracle

I have the below script inserting into an Oracle database. If I manually put all the passed in values into an INSERT statement and run the hardcoded statement in Python the INSERT works but for some reason when I use the below way it always fails…
llanato
  • 2,508
  • 6
  • 37
  • 59
2
votes
1 answer

Inner join statement in bind variables

I use bind variables to get data from the SQL tables. The code: string commandText = string.Format("SELECT {0} FROM {1} WHERE {2} ORDER BY {3}", fields, from, whereStr, orderBy); DbCommand command = GetSqlCommandWrapper(commandText); int index =…
rikush
  • 520
  • 1
  • 6
  • 20
2
votes
0 answers

How do I get a compiled SQL query from a SQLAlchemy expression if params is a dict?

I have this code (using sqlalchemy): session = self._new_session(database_id=dbname) with session.begin(): result_proxy = session.execute(sql_query, sql_params) where sql_query = 'select * from t_client where id = :id' sql_params = {'id':…
insomniaqq
  • 61
  • 1
  • 5
2
votes
2 answers

passing value of sqlplus variable from one script to another

I have a script that gets the current time, and must pass it to another script. variable v_s_time varchar2(30); exec :v_s_time := to_char(sysdate,'YYYY-MM-DD HH:MI:SS AM'); --Lots of unrelated code here variable v_e_time varchar2(30); exec :v_e_time…
FrustratedWithFormsDesigner
  • 26,726
  • 31
  • 139
  • 202
2
votes
1 answer

Bind Aware Cursor Matching Explanation

Hi I am having a little trouble trying to find a simple explanation for bind aware cursor matching in oracle.. Is bind aware cursor matching basically having Oracle monitor a query with a bind variable over time and seeing if there's an increase in…
bdavies6086
  • 382
  • 1
  • 5
  • 19
2
votes
1 answer

PLSQL not all variables bound

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: …
user250643
  • 221
  • 3
  • 4
  • 8
2
votes
1 answer

Verify dbms_sql.execute executed code PL/SQL

Is there a way to track what code has been executed using dbms_sql.execute? For example if I run this query: DECLARE cursor_name INTEGER; rows_processed INTEGER; BEGIN cursor_name := dbms_sql.open_cursor; DBMS_SQL.PARSE(cursor_name,…
Charles Henry
  • 353
  • 3
  • 16
2
votes
1 answer

rails activerecord insert with binds

I am using mysql2 adaptor with activerecords in rails 3.2.6 I would like to use bind variables while doing a raw insert. I can not use a regular model since I am doing an insert into select. Something like: insert into t(col1, col2) select ?, c from…
serverman
  • 1,314
  • 5
  • 22
  • 39
2
votes
2 answers

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

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, …
TrojanName
  • 4,853
  • 5
  • 29
  • 41
2
votes
1 answer

Cannot use bind variables in a DDL statement. Alternatives?

first of all, a preface: I'm writing a java class that creates temporary tables on a database using jdbc. I'm using JSE6 and Oracle 11XE as a test DB, but the class needs to be also DB2 compliant. The temporary tables I'm trying to create come from…
SirBif
  • 305
  • 2
  • 8
1
vote
1 answer

Bind variable options

Is it possible to denote a bind variable in SQL Server using the same notation as Oracle i.e. :0, :1 instead of using ?. I have searched but not found anything conclusive on this. At the moment my solution uses bind variables to introduce values to…
CSharpened
  • 11,674
  • 14
  • 52
  • 86
1
vote
1 answer

Is it possible to create bind variables without a colon?

I generated this code via CHATGPT to better understand Bind variables in Oracle SQL: DECLARE v_employee_id NUMBER := 1001; v_employee_name VARCHAR2(50); v_salary NUMBER; BEGIN -- SQL statement with bind variables SELECT employee_name,…
1
vote
0 answers

How to use loop variables as bind variables Snowflake?

I want to use the row_variable from a for loop as a bind variable, FOR IN DO statement; [ statement; ... ] END FOR [
1
vote
1 answer

Snowflake - using binding variables

I am trying to call the below procedure and I'm getting an unexpected ':' error due to binding variable. If I am using simple JS concatenation instead,its working. But please let me know if there is any alternative using binding variables.Also in…
1 2
3
9 10