Database User Parameter Regex replaces adjacent string.

Answered

Perhaps my issues is my Regex Expression, but my testing in regex tools seems to indicate it should work. The issue is that I have defined the following expression  '&([^\s\;\.]+\.\{0,1\})' for use in providing a parameter for an Oracle schema name at the time I run a query or ddl that requires a fully qualified table name.  The objective is to get a regex that would allow the same query/ddl to work in Idea as well as my other SQL tools. So, for example my script may have a query that requires the specific schema name provided such as;

select count(*) 

from &MY_SCHEMA_NAME..my_table_name;

In other Oracle SQL Plus compatible tools the replacement would consume the first dot leaving the script as

select count(*)

from my_schema_name.my_table_name;

However, in Intellij Idea, the regex works, but instead of simply replacing the matched value in the regex parenthesis, it drops the adjacent text '.my_table_name' so that the query after parameter replacement becomes;

select count(*)

from my_schema_name;

Is this an issue with the Idea regex parser...or me ; )

Thanks for any insight.

0
2 comments

Hello,

Do you want to configure the tool so that it would consider `.my_table_name` as a user parameter which you can specify yourself when execute the query? Note that user parameters patters do not replace anything in script. They allow you to configure the patterns for symbols which would be treated as a script parameters.

0
Avatar
Permanently deleted user

Hi Andrey, No...not the table name, the portion of text beginning with '&'.  So, in my sql script I have a string like &My_Schema..my_table   and the regex identifies the portion of the string '&My_Schema.' as the symbol...but when I enter the value in the prompt in the IDE (which incidently shows the proper string My_Schema) the resulting script shows that process of replacing the symbol also seems to drops/deletes the remainder of the string in the script....which was '.my_table'. It is as if the regex is acting in a greedy fashion and treating the entire string '&My_Schema..my_table' as the parameter rather than just the part part identified by the regex. Thanks.

0

Please sign in to leave a comment.