SQL parameter
Question

Can we use parameters to specify Entity in the SQL? 

When I execute the SQL below, the error message 'Must declare the table variable "@qpstTargetEntity"' has appeared.How can I solve this?


DELETE FROM @TargetEntity;


Champion
Solution

Don't use input parameter to refer Entity name. 

Just Put  { and  Ctr+Space  , it will give suggestion, now pick your Entity. 

HI,

DELETE FROM @TargetEntity;

it is error, the delete from deletes a table

the @TargetEntity, refers to a variable of type string, int

Are you trying to do a dynamic delete from.

1 parámetro de entrada
2 uso del parámetro de entrada en where
3 estructura de salida.

Saludos!

Thank you for your reply.

Yes, I was trying to do a dynamic delete from. 

I understood parameters are usually used in where clauses, but can I use a text parameter to refer to an entity name?


remember that the sql parameters refer to a value.



Also when we call from {} <= we make outsystem understand that we will work with that entity.


Champion

Hi Mai,

TargetEntity is your Table name , Put Table in Curly Bracket


DELETE FROM {table_name}; 

        :- The following SQL statement deletes all rows in the table, without deleting the table: 


Please check - 1.   https://success.outsystems.com/Documentation/How-to_Guides/Data/How_to_delete_data_from_Entities

2.   

 https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Query_Data/SQL_Queries



Thanks, 

Rahul

Hi Rahul,

Thank you for your reply. I put curly bracket, but another error 'Inncorrect syntax near' has shown.

Maybe parameter cannot be used to refer Entity name..?

Champion

what is whole error message ? 


Incorrect syntax near  then .... 

             :- It means,  Sql syntax is not correct.

what is your complete sql query ?

Please paste it here and also attach screenshot.

Champion
Solution

Don't use input parameter to refer Entity name. 

Just Put  { and  Ctr+Space  , it will give suggestion, now pick your Entity. 

Rauhul

OK! Thank you so much for your quick response!!

Mai

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