Dapper and Oracle parametrized query - ORA-01036: illegal variable name/number

OnoSendai

I'm currently trying my hand on Dapper. The following code works flawlessly:

using (var conn = 
    new OracleConnection(
        "Uid=dbusr;Pwd=dbusrpwd;Server=oraserver;"))
{
    var col = 
        conn.Query<User>(
        "SELECT * FROM Users WHERE UserName = 'uid01'"
        , null)
        .ToList();
}

But if instead of using a hardcoded parameter I try to pass it through a parametrized query plus an anonymous class, like this:

using (var conn = 
    new OracleConnection(
        "Uid=dbusr;Pwd=dbusrpwd;Server=oraserver;"))
{
    var col = 
        conn.Query<User>(
        "SELECT * FROM Users WHERE UserName = @Id"
        , new { Id = "uid01" })
        .ToList();
}

I receive the following error:

ORA-01036: illegal variable name/number

I searched around SO, but found no similar error reports; it seems I'm missing something terribly obvious but alas - I ran out of coffee. I would appreciate any hints.

Marc Gravell

In oracle's flavour of SQL, named parameters are prefixed with :. Try :Id instead of @Id.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Oracle ORA-01036 illegal variable name/number for no obvious reason

From Dev

cx_Oracle CREATE TABLE AS returns ORA-01036: illegal variable name/number

From Dev

ORA-01036: illegal variable name/number when running query through nodejs

From Dev

Python script to move data from a SQL server db to an oracle db keeps giving 'ORA-01036: illegal variable name/number'

From Dev

ORA-01036: illegal variable name/number - oci_bind_by_name

From Dev

ORA-01036 after rewriting an Oracle insert command

From Dev

Geeting error ORA-01036 while executing Oracle Procedure using C#

From Dev

Bad Dapper performance for parametrized queries

From Dev

Passing parameters to Dapper Select query for Oracle database

From Dev

Parametrized Query Using JDBC

From Dev

Parametrized Query Using JDBC

From Dev

Loop query with a variable in Oracle

From Dev

Conversion to recommended parametrized query method

From Dev

Parametrized query unknown total params

From Dev

How to print a parametrized SQL query?

From Dev

MySQL parametrized query with like operator

From Dev

Parametrized object cannot be resolved to variable

From Dev

Updating Oracle database throws illegal variable name/number exception

From Dev

python cx_Oracle Bind illegal variable name

From Dev

oracle: query timestamp with variable dates

From Dev

ORA 7445: Query causing Oracle 12c to crash

From Dev

Missing Right Parenthesis error in oracle query ORA00907

From Dev

Parametrized like query in neo4j

From Dev

Parametrized Linq to SQL query causes performance issues

From Dev

C# SQLCommand - Parametrized query is cut short

From Dev

Postgre SQL parametrized query for C#

From Dev

Oracle "ORA-01008" Error. Variable Not Bound

From Dev

Create a parametrized List from a Class variable

From Dev

Create a parametrized List from a Class variable

Related Related

  1. 1

    Oracle ORA-01036 illegal variable name/number for no obvious reason

  2. 2

    cx_Oracle CREATE TABLE AS returns ORA-01036: illegal variable name/number

  3. 3

    ORA-01036: illegal variable name/number when running query through nodejs

  4. 4

    Python script to move data from a SQL server db to an oracle db keeps giving 'ORA-01036: illegal variable name/number'

  5. 5

    ORA-01036: illegal variable name/number - oci_bind_by_name

  6. 6

    ORA-01036 after rewriting an Oracle insert command

  7. 7

    Geeting error ORA-01036 while executing Oracle Procedure using C#

  8. 8

    Bad Dapper performance for parametrized queries

  9. 9

    Passing parameters to Dapper Select query for Oracle database

  10. 10

    Parametrized Query Using JDBC

  11. 11

    Parametrized Query Using JDBC

  12. 12

    Loop query with a variable in Oracle

  13. 13

    Conversion to recommended parametrized query method

  14. 14

    Parametrized query unknown total params

  15. 15

    How to print a parametrized SQL query?

  16. 16

    MySQL parametrized query with like operator

  17. 17

    Parametrized object cannot be resolved to variable

  18. 18

    Updating Oracle database throws illegal variable name/number exception

  19. 19

    python cx_Oracle Bind illegal variable name

  20. 20

    oracle: query timestamp with variable dates

  21. 21

    ORA 7445: Query causing Oracle 12c to crash

  22. 22

    Missing Right Parenthesis error in oracle query ORA00907

  23. 23

    Parametrized like query in neo4j

  24. 24

    Parametrized Linq to SQL query causes performance issues

  25. 25

    C# SQLCommand - Parametrized query is cut short

  26. 26

    Postgre SQL parametrized query for C#

  27. 27

    Oracle "ORA-01008" Error. Variable Not Bound

  28. 28

    Create a parametrized List from a Class variable

  29. 29

    Create a parametrized List from a Class variable

HotTag

Archive