{"id":3010,"date":"2019-11-22T22:01:15","date_gmt":"2019-11-23T05:01:15","guid":{"rendered":"https:\/\/oracletutorial.com\/?page_id=3010"},"modified":"2025-05-31T18:45:59","modified_gmt":"2025-06-01T01:45:59","slug":"bind-variables","status":"publish","type":"page","link":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/","title":{"rendered":"Bind Variables"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='an-introduction-to-bind-variables'>An introduction to bind variables <a href=\"#an-introduction-to-bind-variables\" class=\"anchor\" id=\"an-introduction-to-bind-variables\" title=\"Anchor for An introduction to bind variables\">#<\/a><\/h2>\n\n\n\n<p>If you want to pass data to and from the Oracle database, you use placeholders in the SQL statement as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">sql = <span class=\"hljs-string\">''' SELECT customer_id, name\n          FROM customers\n          WHERE customer_id = :customer_id '''<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this query, the <code>:customer_id<\/code> is a placeholder. It is also known as a bind variable or bind parameter.<\/p>\n\n\n\n<p>When you execute a query using the <code>Cursor<\/code> object, you need to pass the value of the bind variable:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cursor.execute(sql, {<span class=\"hljs-string\">'customer_id'<\/span>: customer_id})<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this case, the value of the customer_id variable will be used for the <code>:customer_id<\/code> bind variable in the SQL statement when the query is executed.<\/p>\n\n\n\n<p>Bind variables make the code more secure and help avoid SQL injection security issues because user data is never treated as a part of the executable SQL statement.<\/p>\n\n\n\n<p>If user data is concatenated with a SQL statement, it will be vulnerable to a SQL injection attack:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">sql = <span class=\"hljs-string\">''' SELECT customer_id, name\n          FROM customers\n          WHERE customer_id = '''<\/span> + customer_id;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For this reason, it is a good practice to always use bind variables in your query and never concatenate or interpolate user data into an SQL statement like the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">sql = <span class=\"hljs-string\">f''' SELECT customer_id, name\n          FROM customers\n          WHERE customer_id = <span class=\"hljs-subst\">{customer_id}<\/span>'''<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Besides the security benefit, bind variables can improve the performance of a query if an SQL statement is executed multiple times with different values because Oracle just needs to parse and cache the SQL statement once.<\/p>\n\n\n\n<p>The following example illustrates how to find the customer&#8217;s name by id using bind variables:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> typing <span class=\"hljs-keyword\">import<\/span>  Optional\n<span class=\"hljs-keyword\">import<\/span> oracledb\n<span class=\"hljs-keyword\">import<\/span> logging\n<span class=\"hljs-keyword\">from<\/span> customer <span class=\"hljs-keyword\">import<\/span> Customer\n<span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> connect\n\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">find_by_id<\/span><span class=\"hljs-params\">(customer_id: int)<\/span> -&gt; Optional&#91;Customer]:<\/span>\n\n    sql = <span class=\"hljs-string\">''' SELECT customer_id, name\n              FROM customers\n              WHERE customer_id = :customer_id '''<\/span>\n\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">with<\/span> connect() <span class=\"hljs-keyword\">as<\/span> connection:\n            <span class=\"hljs-keyword\">with<\/span> connection.cursor() <span class=\"hljs-keyword\">as<\/span> cursor:\n                cursor.execute(sql, {<span class=\"hljs-string\">'customer_id'<\/span>: customer_id})\n                row = cursor.fetchone()\n                <span class=\"hljs-keyword\">if<\/span> row:\n                    <span class=\"hljs-keyword\">return<\/span> Customer(customer_id=row&#91;<span class=\"hljs-number\">0<\/span>], name=row&#91;<span class=\"hljs-number\">1<\/span>])\n                <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">None<\/span> <span class=\"hljs-comment\"># Return None if no customer is found<\/span>\n    <span class=\"hljs-keyword\">except<\/span> oracledb.Error <span class=\"hljs-keyword\">as<\/span> e:\n        logging.error(<span class=\"hljs-string\">f\"Error executing query to find customer by ID: <span class=\"hljs-subst\">{e}<\/span>\"<\/span>)\n        <span class=\"hljs-keyword\">raise<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Note that here is the <code>config.py<\/code> module if you haven&#8217;t followed the previous tutorial:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">username = <span class=\"hljs-string\">'OT'<\/span>\npassword = <span class=\"hljs-string\">'oracle'<\/span>\ndsn = <span class=\"hljs-string\">'192.168.2.18\/freepdb1'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='binding-by-names'>Binding by names <a href=\"#binding-by-names\" class=\"anchor\" id=\"binding-by-names\" title=\"Anchor for Binding by names\">#<\/a><\/h2>\n\n\n\n<p>If bind variables are associated with names, you have named binds. The named binds require the keyword parameter names or key of the dictionary to match the bind variable names. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">from<\/span> typing <span class=\"hljs-keyword\">import<\/span>  Optional\n<span class=\"hljs-keyword\">import<\/span> oracledb\n<span class=\"hljs-keyword\">import<\/span> logging\n<span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> connect\n\n<span class=\"hljs-keyword\">from<\/span> dataclasses <span class=\"hljs-keyword\">import<\/span> dataclass\n\n\n<span class=\"hljs-meta\">@dataclass(frozen=True)<\/span>\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Product<\/span>:<\/span>\n    product_id: int\n    product_name: str    \n    category_id: int\n    list_price: float\n\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">find_products<\/span><span class=\"hljs-params\">(category_id: int, list_price: float)<\/span> -&gt; Optional&#91;Product]:<\/span>\n\n    sql = <span class=\"hljs-string\">''' SELECT product_id, product_name, category_id, list_price\n              FROM products\n              WHERE category_id = :category_id and list_price &gt; :list_price\n              ORDER BY list_price '''<\/span>\n\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">with<\/span> connect() <span class=\"hljs-keyword\">as<\/span> connection:\n            <span class=\"hljs-keyword\">with<\/span> connection.cursor() <span class=\"hljs-keyword\">as<\/span> cursor:\n                <span class=\"hljs-comment\"># Pass the parameter using a dictionary<\/span>\n                cursor.execute(sql, {\n                    <span class=\"hljs-string\">'category_id'<\/span>: category_id, \n                    <span class=\"hljs-string\">'list_price'<\/span>: list_price\n                })\n                \n                rows = cursor.fetchall()\n                \n                <span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-keyword\">not<\/span> rows:\n                    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-literal\">None<\/span>\n                \n                products = &#91;]\n                <span class=\"hljs-keyword\">for<\/span> row <span class=\"hljs-keyword\">in<\/span> rows:\n                    <span class=\"hljs-comment\"># Create a Customer object from the fetched row<\/span>\n                    product =  Product(\n                        product_id=row&#91;<span class=\"hljs-number\">0<\/span>], \n                        product_name=row&#91;<span class=\"hljs-number\">1<\/span>],\n                        category_id=row&#91;<span class=\"hljs-number\">2<\/span>],\n                        list_price=row&#91;<span class=\"hljs-number\">3<\/span>]\n                    )\n                    products.append(product)\n                <span class=\"hljs-keyword\">return<\/span> products\n                \n    <span class=\"hljs-keyword\">except<\/span> oracledb.Error <span class=\"hljs-keyword\">as<\/span> e:\n        logging.error(<span class=\"hljs-string\">f\"Error executing query to find customer by ID: <span class=\"hljs-subst\">{e}<\/span>\"<\/span>)\n        <span class=\"hljs-keyword\">raise<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>:list_price<\/code> and <code>:standard_cost<\/code> bind variables are named binds:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">sql = <span class=\"hljs-string\">''' SELECT product_id, product_name, list_price, standard_cost\n          FROM products\n          WHERE list_price &gt;= :list_price and standard_cost &lt;= :standard_cost '''<\/span>        <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>When executing the SQL statement with named binds, you need to pass the keyword parameter names that match the named binds:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cursor.execute(sql, list_price=<span class=\"hljs-number\">15<\/span>, standard_cost=<span class=\"hljs-number\">13<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Alternatively, you can pass parameters as a dictionary instead of as keyword parameters:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cursor.execute(sql, {<span class=\"hljs-string\">'list_price'<\/span>: list_price, <span class=\"hljs-string\">'standard_cost'<\/span>: standard_cost})<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The binding by names allows you to specify meaningful names and use them freely in any position.<\/p>\n\n\n\n<p>In addition, you just need to specify the name parameters once if a variable is repeated multiple times in a query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='binding-by-positions'>Binding by positions <a href=\"#binding-by-positions\" class=\"anchor\" id=\"binding-by-positions\" title=\"Anchor for Binding by positions\">#<\/a><\/h2>\n\n\n\n<p>A positional bind is performed when a list of bind values is passed to the <code>Cursor.execute()<\/code> call. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The order of the bind values must exactly match the order of each bind variable. If you use a bind variable multiple times in the query, you must repeat the bind values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='bind-directions'>Bind directions <a href=\"#bind-directions\" class=\"anchor\" id=\"bind-directions\" title=\"Anchor for Bind directions\">#<\/a><\/h2>\n\n\n\n<p>Bind variables can be <code>IN<\/code> or <code>OUT<\/code>.<\/p>\n\n\n\n<p>The <code>IN<\/code> bind variables allow you to pass data from Python to Oracle Database while the <code>OUT<\/code> bind variables allow you to get data back from the Oracle Database to Python.<\/p>\n\n\n\n<p>In the previous examples, you have passed in bind variables to the Oracle Database to query data and used a <code>Cursor<\/code> to fetch the result.<\/p>\n\n\n\n<p>To have the Oracle Database return data to Python, you need to create a variable by using the <code>Cursor.var()<\/code> method. See the following example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> oracledb\n<span class=\"hljs-keyword\">from<\/span> connect <span class=\"hljs-keyword\">import<\/span> connect\n\n<span class=\"hljs-comment\"># construct a PL\/SQL anonymous block<\/span>\nplsql = <span class=\"hljs-string\">'''\n    begin \n        select count(*) into :customer_count \n        from customers; \n    end;\n'''<\/span>\n\n<span class=\"hljs-keyword\">try<\/span>:\n    <span class=\"hljs-keyword\">with<\/span> connect() <span class=\"hljs-keyword\">as<\/span> connection:\n        <span class=\"hljs-keyword\">with<\/span> connection.cursor() <span class=\"hljs-keyword\">as<\/span> cursor:\n            <span class=\"hljs-comment\"># create a variable<\/span>\n            customer_count = cursor.var(int)\n\n            <span class=\"hljs-comment\"># execute the pl\/sql anonymous block<\/span>\n            cursor.execute(plsql, customer_count=customer_count)\n\n            <span class=\"hljs-comment\"># show the value of the variable<\/span>\n            print(<span class=\"hljs-string\">f'The number of customers is <span class=\"hljs-subst\">{customer_count.getvalue()}<\/span>'<\/span>)\n<span class=\"hljs-keyword\">except<\/span> oracledb.Error <span class=\"hljs-keyword\">as<\/span> error:\n    print(error)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example:<\/p>\n\n\n\n<p>First, declare a variable that holds an anonymous PL\/SQL block:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">plsql = <span class=\"hljs-string\">'''\n    begin \n        select count(*) into :customer_count \n        from customers; \n    end;\n'''<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, connect to the Oracle Database and create a new Cursor object from the Connection object.<\/p>\n\n\n\n<p>Third, create a variable to hold the returned data from the execution of the anonymous PL\/SQL block:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">customer_count = cursor.var(int)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Fourth, execute the PL\/SQL block and receive the returned data:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cursor.execute(plsql, customer_count=customer_count)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, show the value of the variable by calling the <code>getvalue()<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">print(<span class=\"hljs-string\">f'Customer count is <span class=\"hljs-subst\">{customer_count.getvalue()}<\/span>'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The output is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">The number of customers <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-number\">319<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this tutorial, you have learned how to use bind variables to pass data to and from Oracle Database.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3010\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/\"\n\t\t\t\tdata-post-title=\"Bind Variables\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3010\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/\"\n\t\t\t\tdata-post-title=\"Bind Variables\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2999,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3010","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using Bind Variable to Pass Data to and from Oracle Database<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Bind Variable to Pass Data to and from Oracle Database\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"Oracle Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-01T01:45:59+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/bind-variables\\\/\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/bind-variables\\\/\",\"name\":\"Using Bind Variable to Pass Data to and from Oracle Database\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\"},\"datePublished\":\"2019-11-23T05:01:15+00:00\",\"dateModified\":\"2025-06-01T01:45:59+00:00\",\"description\":\"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/bind-variables\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/bind-variables\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/bind-variables\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Oracle\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/python-oracle\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bind Variables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/\",\"name\":\"Oracle Tutorial\",\"description\":\"Oracle Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.oracletutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Bind Variable to Pass Data to and from Oracle Database","description":"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/","og_locale":"en_US","og_type":"article","og_title":"Using Bind Variable to Pass Data to and from Oracle Database","og_description":"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.","og_url":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/","og_site_name":"Oracle Tutorial","article_modified_time":"2025-06-01T01:45:59+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/","url":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/","name":"Using Bind Variable to Pass Data to and from Oracle Database","isPartOf":{"@id":"https:\/\/www.oracletutorial.com\/#website"},"datePublished":"2019-11-23T05:01:15+00:00","dateModified":"2025-06-01T01:45:59+00:00","description":"In this tutorial, you will learn how to use the bind variables to pass data to and from Oracle Database.","breadcrumb":{"@id":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.oracletutorial.com\/python-oracle\/bind-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.oracletutorial.com\/"},{"@type":"ListItem","position":2,"name":"Python Oracle","item":"https:\/\/www.oracletutorial.com\/python-oracle\/"},{"@type":"ListItem","position":3,"name":"Bind Variables"}]},{"@type":"WebSite","@id":"https:\/\/www.oracletutorial.com\/#website","url":"https:\/\/www.oracletutorial.com\/","name":"Oracle Tutorial","description":"Oracle Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.oracletutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/3010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/comments?post=3010"}],"version-history":[{"count":0,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/3010\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2999"}],"wp:attachment":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/media?parent=3010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}