<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Cannot create scalar function with SUBSTR_REGEXPR in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394442#M40385</link>
    <description>&lt;P&gt;Ok, SQL Script is not a superset of SQL, which also means that not all SQL functions will just work in SQL Script statements (like the assignment you used).&lt;/P&gt;&lt;P&gt;  SELECT however is a supported command and it provides the SQL context which in turn gives access to all SQL functions. &lt;/P&gt;&lt;P&gt;The warning really is just that: a warning about possible unacknowledged side effects (worse performance and higher resource consumption in this case).&lt;/P&gt;</description>
    <pubDate>Thu, 20 Oct 2016 03:53:48 GMT</pubDate>
    <dc:creator>lbreddemann</dc:creator>
    <dc:date>2016-10-20T03:53:48Z</dc:date>
    <item>
      <title>Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaq-p/394441</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;when I run this create function statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;create function f_test_regexp(
  p_txt      NVARCHAR(5000)
, p_pattern  NVARCHAR(64)
)
returns found NVARCHAR(5000)
as
begin
    found := substr_regexpr(:p_pattern in :p_txt);
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get this error message:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Started: 2016-10-19 10:25:34
Could not execute 'create function f_test_regexp( p_txt NVARCHAR(5000) , p_pattern NVARCHAR(64) ) returns found ...' in 64 ms 267 µs . 
SAP DBTech JDBC: [8]: invalid argument: exception: CompilationFailedException: No details
Program : 

#pragma function "\"NLRBVD\".\"F_TEST_REGEXP\""
export Void main(NullString "P_TXT" sP_TXT, NullString "P_PATTERN" sP_PATTERN, NullString "FOUND" &amp;amp; sFOUND)
{
    RSHeap heap = RSHeap();
    RSEnv env = RSEnv(heap);
    Int32 ucnt = 0;
    // scalar input parameter: P_TXT
    RSNString vP_TXT = RSNString( sP_TXT , env );
    // scalar input parameter: P_PATTERN
    RSNString vP_PATTERN = RSNString( sP_PATTERN , env );
    RSNString vFOUND = expr::null_&amp;lt;RSNString&amp;gt;(); // scalar output parameter
    RSNString vFOUND___2; // FOUND_2: intermediate def-variable
    #pragma location " line 8 col 5 (at pos 129)"
    {
        RSNString tFOUND = expr::substr_regex_&amp;lt;RSNString&amp;gt;(env,vP_TXT,vP_PATTERN,expr::typecast_&amp;lt;RSInteger&amp;gt;(1),expr::typecast_&amp;lt;RSInteger&amp;gt;(1),expr::typecast_&amp;lt;RSInteger&amp;gt;(0),expr::typecast_&amp;lt;RSNString&amp;gt;(expr::constructor_&amp;lt;RSString&amp;gt;("",0)));
    tFOUND.checkLengthLEAndThrow(5000z);
        vFOUND = tFOUND;
    }
    sFOUND = NullString(vFOUND);
    return;
}
line 16 ("NLRBVD"."F_TEST_REGEXP": line 8 col 5 (at pos 129)): Error: Function 'expr::substr_regex_&amp;lt;RSNString&amp;gt;(RSEnv, RSNString, RSNString, RSInteger, RSInteger, RSInteger, RSNString)' not found
line 16 ("NLRBVD"."F_TEST_REGEXP": line 8 col 5 (at pos 129)): RSNString tFOUND = expr::substr_regex_&amp;lt;RSNString&amp;gt;(env,vP_TXT,vP_PATTERN,expr::typecast_&amp;lt;RSInteger&amp;gt;(1),expr::typecast_&amp;lt;RSInteger&amp;gt;(1),expr::typecast_&amp;lt;RSInteger&amp;gt;(0),expr::typecast_&amp;lt;RSNString&amp;gt;(expr::constructor_&amp;lt;RSString&amp;gt;("",0)));
                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But when I rewrite it like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;create function f_test_regexp(
  p_txt      NVARCHAR(5000)
, p_pattern  NVARCHAR(64)
)
returns found NVARCHAR(5000)
as
begin
    select substr_regexpr(:p_pattern in :p_txt)&amp;lt;br&amp;gt;    into found&amp;lt;br&amp;gt;    from dummy;
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I only get a warning:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;java.sql.SQLWarning: Not recommended feature: Using SELECT INTO in Scalar UDF
&lt;/CODE&gt;&lt;/PRE&gt;
but the function seems to work fine.&lt;BR /&gt;&lt;BR /&gt;So, how come? SAP/HANA, have you been drinking?</description>
      <pubDate>Wed, 19 Oct 2016 08:51:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaq-p/394441</guid>
      <dc:creator>roland_bouman</dc:creator>
      <dc:date>2016-10-19T08:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394442#M40385</link>
      <description>&lt;P&gt;Ok, SQL Script is not a superset of SQL, which also means that not all SQL functions will just work in SQL Script statements (like the assignment you used).&lt;/P&gt;&lt;P&gt;  SELECT however is a supported command and it provides the SQL context which in turn gives access to all SQL functions. &lt;/P&gt;&lt;P&gt;The warning really is just that: a warning about possible unacknowledged side effects (worse performance and higher resource consumption in this case).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 03:53:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394442#M40385</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2016-10-20T03:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394443#M40386</link>
      <description>&lt;P&gt;Hi Lars, &lt;BR /&gt;&lt;BR /&gt;Thanks for taking the time to respond and to share your insights. &lt;BR /&gt;&lt;BR /&gt;I understand the point you are making. I guess I would expect a more descriptive error message.&lt;BR /&gt;&lt;BR /&gt;It's also quite different from what I am used to of procedural extensions in other RDBMS-es - there, calling built-in scalars inside procedural code is typically transparent. And in HANA too, for example, SUBSTR gives none of these issues. To me, SUBSTR_REGEXPR is more or less a fancy SUBSTR, It does not strike me as intuitive that it would behave so differently.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:04:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394443#M40386</guid>
      <dc:creator>roland_bouman</dc:creator>
      <dc:date>2016-10-20T13:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394444#M40387</link>
      <description>&lt;P&gt;I agree. It's not intuitive.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:08:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394444#M40387</guid>
      <dc:creator>lbreddemann</dc:creator>
      <dc:date>2016-10-20T13:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394445#M40388</link>
      <description>&lt;P&gt;Development is aware of this particular issue and is working to implement a solution in an upcoming release.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;P&gt;SAP HANA Product Management&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:51:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394445#M40388</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2016-10-20T13:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394446#M40389</link>
      <description>&lt;P&gt;Thank you! Much obliged.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 14:36:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394446#M40389</guid>
      <dc:creator>roland_bouman</dc:creator>
      <dc:date>2016-10-20T14:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394447#M40390</link>
      <description>&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;sorry to bother you again.&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I'm assuming you and the dev team is already aware of it, but just to be clear: other %_REGEXPR functions suffer from the same issue. It'd be great if all of the REGEXPR functions would be transparently available in sqlscript.&lt;BR /&gt;&lt;BR /&gt;BTW - I realize you might not have this info at this point, but if it is: can you perhaps give me an indication in which future version the fix will be available? If not, what method would you recommend for me to stay up to date and find out when this will be fixed?&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Roland.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Oct 2016 13:08:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394447#M40390</guid>
      <dc:creator>roland_bouman</dc:creator>
      <dc:date>2016-10-23T13:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot create scalar function with SUBSTR_REGEXPR</title>
      <link>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394448#M40391</link>
      <description>&lt;P&gt;We do rollout blogs for every SPS around the time of the release. Features like this would be included in that rollout.  I do not have any information as to when these particular issues will be resolved.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2016 20:36:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cannot-create-scalar-function-with-substr-regexpr/qaa-p/394448#M40391</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2016-10-25T20:36:16Z</dc:date>
    </item>
  </channel>
</rss>

