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

I have created a functionA in SQL Anywhere 17, and then set it to hidden.

I want to restrict the use of this function to a list of procedures (i.e. only ProcedureA & ProcedureB may make use of the functionA).

Is there a way to ask within functionA from which procedure am I called?

In the documentation I found only the SQL SECURITY clause which is not exactly what I want!

asked 13 Feb '20, 12:07

Baron's gravatar image

accept rate: 48%

edited 13 Feb '20, 12:09

Starting with v17, there are four new special values that will be of help:

Use INVOKING USER, SESSION USER, EXECUTING USER, and PROCEDURE OWNER to determine which users can execute, and are executing, procedures and user-defined functions.

permanent link

answered 13 Feb '20, 12:41

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

Thanks for the answer, but these four special values help me to determine the user, and not the name of the calling procedure.

But yes, I can I can create my UserA, and then create my ProcedureA & ProcedureB in the name of this UserA, so that it can work as I want.

Thank you

(13 Feb '20, 12:55) Baron

Oops, sorry, apparently I misread your question...

You can probably include calls to the stack_trace() system function or the similar sa_strack_trace() system procedure to find out about invokers.

Say, something like:

message 'Function stack: ' || stack_trace('caller', 'stack+sql')  to log;
permanent link

answered 13 Feb '20, 13:23

Volker%20Barth's gravatar image

Volker Barth
accept rate: 34%

converted 23 Mar '20, 03:52

I have tried STACK_TRACE and it worked and did exactly what I want! Thank you!

(19 Mar '20, 12:50) Baron
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 13 Feb '20, 12:07

question was seen: 943 times

last updated: 19 Mar '20, 12:50