Skip to Content
avatar image
Former Member

define and use a user-defined function in SAP B1

Good Morning,

I am trying to define a function ( CREATE FUNCTION ... ) and then use it in my SQL Query but for some reason it will not work.

Does anybody have any Idea how or why it is not working?

A very simple Function like :

CREATE FUNCTION translator(@text varchar(254) ) RETURNS varchar(254)

AS

BEGIN

replace (@text,'mad','sad') 
RETURN @text

END

select translator ('mad max')
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Sep 07, 2017 at 02:08 PM

    see the code below

    CREATE FUNCTION translator(@text varchar(254) ) RETURNS varchar(254)
    
    
    AS
    
    
    BEGIN
    
    
    
    
    RETURN replace (@text,'mad','sad') 
    
    
    END
    GO
    select dbo.translator ('mad max')
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 07, 2017 at 02:19 PM

    I become always the Error Message :

    Incorrect Synatx near the Keyword " select "...

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 08, 2017 at 10:25 AM

    Hi

    I tried your SQL statement and the function is ok: no message error shown.

    Where are you running these SQL statement?

    Kind regards

    Agustín Marcos Cividanes

    Add comment
    10|10000 characters needed characters exceeded