Been playing with CURRENT_SCHEMA it doesn't do what I need it to so...
If I write the following in HANA in the context of SchemaA
Select CURRENT_SCHEMA as CS from dummy;
It returns the current schema "SchemaA" that's very useful.
BUT if I make this a view called SchemaName in SchemaA and run the following
set schema "SchemaB";
Select * from "SchemaA"."SchemaName";
I don't see the result "SchemaA" I see "SchemaB". I get the technical reason for that but its not what I need.
I'd really like to know programmatically speaking that the data is from "SchemaA".
As an example, say I am running some kind of multi-company query against sales data and want to be able to distinguish which company each marketing document is from. I can do this with some hard-coding but what I want is a simple piece of generic code I can export from any schema to any other without having to edit it. So is there a better way to do this - a command like CURRENT_SCHEMA that actually returns the schema the view we are using is in and not the context of the session it is running under?
I tried using the company field under OADM but the problem there is users can edit that so its not consistant.