Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle sql - stored procedure - concat a variable in a string

I have a stored procedure of this kind

create or replace
PROCEDURE AAA 
(
    p_BBB       IN  VARCHAR,
    ...
)
AS 
T_QUERY varchar2(3000);
BEGIN
     OPEN A_CUR FOR SELECT ... BBB like '%' || p_BBB || '%';

   T_QUERY := 'SELECT BBB like %'|| p_BBB ||'% '; 

END AAA;

The problem is that while the first query is correctly processed, the concat between the strings in T_QUERY gives me error (invalid character).

Neither using concat() works, the T_QUERY will be pass to another stored procedure that performs the query.

Can anyone help me??

like image 650
user1683737 Avatar asked Mar 25 '26 07:03

user1683737


1 Answers

you may try

T_QUERY :='SELECT BBB like ''%'|| p_BBB ||'%''';
like image 82
Raphaël Althaus Avatar answered Mar 27 '26 00:03

Raphaël Althaus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!