Binding variables in xml string to execute PL/SQL statement #506
-
I have PL/SQL statement which accepts xml string as parameter as shown below:
where my_xml_string is in form like this:
I tried to bind variables by position like this (https://python-oracledb.readthedocs.io/en/latest/user_guide/bind.html#binding-by-name-or-position)
a small function to test execution:
when this function is executed i always get the following error:
if i try to use bind_names instead, i also get the same error
the same error appears when using dictionary:
in the end if i do string interpolation and assign value to the query, there is no errors but i do not want to use string interpolation in my queries
I can not figure out where is the mistake in my code. Can someone help to overcome this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Bind variables cannot be placed inside strings -- which is what you are doing. You would have to do something like this instead: query ='''
begin
my_user.AQ_UTIL.ENQUEUE('...<subscriberInfo><msisdn>' || :1 || '</msisdn><iccId>' || :2 || '</iccId><imsi>' || :3 || '</imsi><serviceProviderId>' || :4 || '</serviceProviderId><paymentType>' || :5 || '</paymentType></subscriberInfo>', 'my_user.Q_A_TO_B', NULL);
end; As noted, the other option is to use Python to create the string and pass that in as a single bind variable. |
Beta Was this translation helpful? Give feedback.
Bind variables cannot be placed inside strings -- which is what you are doing. You would have to do something like this instead:
As noted, the other option is to use Python to create the string and pass that in as a single bind variable.