Appendix 7. SQL queries with bound variables [3.1.4]

Parser's Oracle SQL driver can work with bound variables. IN, OUT and IN/OUT variables are supported, they are bound to hash you pass to query.

There are known problems with
CALL and EXECUTE constructs in Oracle versions, we recommend using PL/SQL wrapper (begin …; end;), do not forget to escape «;» character.

Note: values of
void type correspond to NULL. In second example below days is initially NULL.

Example of using IN variables

#procedure 
ban_user(user_id in number, days in number)

^void:sql
{begin ban_user(:user_id, :days)^; end^;}[
    $.bind[
        $.user_id(7319)
        $.days(10)
    ]
]

Example of using IN and OUT variables

#procedure 
read_user_ban_days(user_id in number, days out number)

$
variables[
    $.user_id(7319)
#we still must pass something in, though current value will be discarded
    $.days[]
]


^void:sql
{begin read_user_ban_days(:user_id, :days)^; end^;}[
    $.bind[$variables]
]

User is banned for 
$variables.days days!


Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 24.12.2004