Skip to Content
0

define and use a user-defined function in SAP B1

Sep 07, 2017 at 12:46 PM

65

avatar image
Former Member

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')
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Danilo Kasparian Sep 07, 2017 at 02:08 PM
0

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')
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Sep 07, 2017 at 02:19 PM
0

I become always the Error Message :

Incorrect Synatx near the Keyword " select "...

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I edited my answer, you can run the two parts separately, if you want to run both add "GO" between each part

0
Agustin Marcos Cividanes Sep 08, 2017 at 10:25 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi,

in a normal SQL Query in SAP B1.

0