Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Hi,

here is another problem with the OData service.

I have a user-defined function like this:

create or replace function "SystemData".GetCurrentUtcTimestamp()
returns timestamp
begin
     declare utc timestamp;
     select CURRENT UTC TIMESTAMP into utc;
     return utc;
end;

I granted execution permission to the corresponding role.

At the end of the osdl-file I have the serviceop Definition as:

serviceop get "SystemData"."GetCurrentUtcTimestamp" returns multiplicity "1";

Taking a look at the generated metadata I see a FunctionImport element in the EntityContainer-object like:

<FunctionImport Name="GetCurrentUtcTimestamp" MethodAccess="GET" ReturnType="Edm.DateTime"/>

So at first glance everything seems to be fine ... but ;-)

When generating the service reference in Visual Studio I don't have an ability to call this function. And navigating to the following URL http://localhost:8090/odata/GetCurrentTimestamp doesn't work either.

What am I doing wrong or what is missing here?

Any help are very much appreciated.

TIA

Armin

asked 07 Oct '14, 11:12

Armin%20Back's gravatar image

Armin Back
101348
accept rate: 0%

edited 08 Oct '14, 03:49

Volker%20Barth's gravatar image

Volker Barth
40.2k361550822

You are also using the wrong URL to access the service operation. The metadata states the name is GetCurrentUtcTimestamp not GetCurrentTimestamp.

(07 Oct '14, 13:49) PhilippeBert...

There is an issue with invoking SQL functions through Service Operations.

As a work around, try making the function a stored procedure instead.

permanent link

answered 07 Oct '14, 11:22

PhilippeBertrand%20_SAP_'s gravatar image

PhilippeBert...
1.8k42139
accept rate: 22%

edited 09 Oct '14, 10:59

Hi Philippe,

thanks, will give it a try and let you know if this works.

Armin

(07 Oct '14, 11:25) Armin Back

Just tried it with a stored procedure but that doesn't work either ;-(.

(07 Oct '14, 12:12) Armin Back
Replies hidden
2

The following works fine for me :

create procedure GetCurUTC()
result (t1 timestamp)
begin
  select CURRENT UTC TIMESTAMP;
end;

service {
  serviceop get "DBA"."GetCurUTC" returns multiplicity "1";
}

I can then browse to http://machine:port/model/GetCurUTC

Reg

(07 Oct '14, 12:21) Reg Domaratzki

I just did a test again and you're absolute right that it works with a stored procedure ... don't know what I have done wrong yesterday ... maybe it was an URL typo as Philippe noted ... but I can't really believe it because I have checked everything twice before posting a question ... anyway, problem solved ;-)

(08 Oct '14, 03:48) Armin Back
Replies hidden

Well, I have another question regarding the stored procedure: calling it via the browser works fine ... but how to call it from within Visual Studio?

I had expected to find a static method at the generated service reference class, but there is no method or something called GetCurrentUtcTimestamp ...

Am I doing something wrong or can't a stored procedure be called through the service reference class (or an instance of it)?

Armin

(08 Oct '14, 08:30) Armin Back

The use of functions as service operations has been fixed for build 16.0.0.2030.

permanent link

answered 23 Oct '14, 19:54

PhilippeBertrand%20_SAP_'s gravatar image

PhilippeBert...
1.8k42139
accept rate: 22%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×16

question asked: 07 Oct '14, 11:12

question was seen: 2,054 times

last updated: 23 Oct '14, 19:54