1087
Views
12
Comments
Cannot use variable as table name in advance sql select statement (external db)
Question

I have a drop down box with list of table names of the external db. When selected table name is passed to a variable which is used by an advance sql.

Script follows:

SELECT * FROM @tablevariable

error is table or view does not exist.

but without using the variable. data is displayed.

SELECT * FROM {table_name}

Anyone knows what is the problem?

2017-07-05 18-13-21
Tiago Neves

Hi A A,

Have you selected "expand inline" for the input parameter being used in advanced sql?

UserImage.jpg
A A

Tiago Neves wrote:

Hi A A,

Have you selected "expand inline" for the input parameter being used in advanced sql?

Hi Tiago Neves, 

Sorry I forgot to mention that I have also selected "expand inline" for the input parameter. The problem still exist.

many thanks for the reply.

UserImage.jpg
A A

Anyone has encountered this and was able to resolve?

2018-01-19 03-18-31
indra budiantho

HI, AA:

I Try and nailed it.

regards,indra

UserImage.jpg
A A

Indra Budiantho wrote:

HI, AA:

I Try and nailed it.

regards,indra

Hi Indra, 

Sorry for the delayed reply.. 

I think the table name you passed on the variable is not  on an external db that is why it worked. Tried using

 "{ }"  outside of the variable and did not forget to set the  "expand inline" to yes.  Problem still exist when calling a table on an external db,  


2018-01-19 03-18-31
indra budiantho

hi AA,

I tried in my environment,it is entity got from external Oracle database that is integrated using Integration Studio. Then I have tested in the SQL widget test and the records are successfully queried. I do not know your system, could be privilege problem? Have you managed dependency the module (and the entity) from that external table?

see this:

https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/Connect_to_an_External_Database

the last paragraph says:

regards,

indra

UserImage.jpg
A A

Indra Budiantho wrote:

hi AA,

I tried in my environment,it is entity got from external Oracle database that is integrated using Integration Studio. Then I have tested in the SQL widget test and the records are successfully queried. I do not know your system, could be privilege problem? Have you managed dependency the module (and the entity) from that external table?

see this:

https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/Connect_to_an_External_Database

the last paragraph says:

regards,

indra

Hi Indra,

I am also using Oracle DB. The external Oracle database that is integrated using Integration Studio. 

"could be privilege problem" This part I missed out, so I tried giving my user full control but unfortunately it did not solve my problem. Here are some screenshot that might help.

Fig1: External DB (Done in Manage Dependency)

Fig2: Left side when run, successfully returns a value.

         Right Side when run returns error table or view does not exist.

Fig3: When tried using "{ }" outside of variable the ff error occured.

Attached scr2 in case unreadable.

Thank you.

Regards,

A. A.

scr2.png
2018-01-19 03-18-31
indra budiantho

hi AA,

This is the same with mine and it works, test value do not need {}, but select * need it:

I think your output structure is incorrect, just use the same entity: Prod_arb_acc.., NOT this one:

change it to Prod_arb_acc entity.

regards,

indra


2021-01-29 14-18-24
Jitendra Raghuvanshi

HI AA,

Please pass columns name in advance sql. Below is the example.


Above Query is tested.

Regards,
Jitendra

UserImage.jpg
Alex Oliveira

I have the same problem.

Has anyone managed to fix this?

UserImage.jpg
Alex Oliveira
UserImage.jpg
Alexei Zaratini

Hello,

Please, does anyone know how to solve this problem? The link pasted by Alex Oliveira seems to be about wether developing .NET extension or using Integration to connect to external DBs. If the connection is already done and the tables available, how to reach them with advanced SQL query? For example, even after using {} when naming tables and [] naming columns, and making sure I've chosen the right table as for 'Output Entities / Structure', I get this error:

Error in advanced query SQL3: Database 'DB_XYZ' does not exist. Make sure that the name is entered correctly.

If I try the same advanced SQL query with an equivalent internal DB table, it returns no errors. Is there a way to name and reach external DBs in advanced SQL queries?

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