737
Views
15
Comments
Solved
Get Entity Data from Database Using Physical_table_Name

In Sql Query node from Server Action is it possible to get entitys data from Outsystem database using entity physical_table_name. If it is possible pleases help to get Dynamic entity data and store in a variable.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

There's two things here:

  1. Indeed you can't specify "OSUSR" (or "OSSYS") in either the SQL or an expand-inline parameter, but fortunately the check is pretty dumb. You can circumvent it by using something like:
    SELECT * FROM OS@TableName
    where @TableName contains "USR_9ls_Seller".
  2. As I said, there's no way to properly get all the attributes from the entity dynamically. In your case, having a structure with a single Text attribute will output the first column only. You can of course just add 100 attributes to get the first 100 columns, but that's rather cumbersome.
2025-10-18 11-13-53
Ramesh subramanian

Hi nani pappala,

Please check this discussion, will get the solution.

https://www.outsystems.com/forums/discussion/46809/dynamic-advanced-sql-table-name-as-a-parameter/

Thanks,

Ramesh

UserImage.jpg
Nani

I have already checked this Discussion but i couldn't find the solution for my requirements.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Can you explain why it doesn't offer a solution? It seems that it is exactly what you need. Either you didn't understand what is written in that topic, or you didn't explain your requirements very well.

UserImage.jpg
Nani

The sql output will be dynamic, so how should i create a dynamic structure based on the sql output

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Ah, that's what you mean. You cannot do that of course. OutSystems is statically typed, there's absolute no way to have an SQL with a dynamic output.

UserImage.jpg
Nani

I have a entity called "seller" and its physical_Table_Name is "OSUSR_9ls_Seller".
I need to get data inside a Seller Entity by using its physical_Table_Name and convert into json format. (what ever the process i am asking you is it possible.)

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

There's two things here:

  1. Indeed you can't specify "OSUSR" (or "OSSYS") in either the SQL or an expand-inline parameter, but fortunately the check is pretty dumb. You can circumvent it by using something like:
    SELECT * FROM OS@TableName
    where @TableName contains "USR_9ls_Seller".
  2. As I said, there's no way to properly get all the attributes from the entity dynamically. In your case, having a structure with a single Text attribute will output the first column only. You can of course just add 100 attributes to get the first 100 columns, but that's rather cumbersome.
2022-12-09 04-50-17
Shubham Doshi

How to do this for external database? Physical table name is '[MDMStaging].[dbo].BAU_EASY_CMSL'

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Shubham,

I'm not sure what you mean. This topic is explicitly about system entities. Connecting to external databases is done in quite a different way. Note that the SQL you put in a SQL node is sent to the OutSystems database, there's nothing you can change about that.

2022-12-09 04-50-17
Shubham Doshi


Hi,

I understand that this topic is about system entities but I am facing very similar problem with external db entities.

I have already integrated the external db. However I want to fetch the data of the particular entity from the external db on the basis of entity name that will be provided through input.

In short I am trying to achieve SQL query to fetch records from any entity on the entity name

I hope you understand the question 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

I suggest you open a new topic on the forum, as what you want may seem similar, but I don't think it actually is. It will also get more views than replies to 1,5 year old posts.

2022-09-01 09-52-33
Carlos Rodrigues

Hi @nani pappala,

The actual table information is available in Entity. Manage dependencies>System Entities> Espace,Espace_Entity and Entity. Run an aggregate with the joins of the above three entities and pass your table name in Entity>Name.

Note that you need to define an Output Entities/Structures that matches the type of your SQL output.

May I ask why you need this behavior?

Regards


UserImage.jpg
Nani

Thank you for your response,

But i need to fetch the entity data from database not from the system (entities) and system entities are not the Correct to fetch entity data.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.