How to bring in the SELECT result the conditions entered as parameters?

Asked

Viewed 1,273 times

3

Is there any way to bring in the result of SELECT the parameter values used in the clause WHERE ?

Example:

SELECT 
  a.*, cast(:dataIni as date) AS inidate , cast(:dataFin as date) AS inidate 
FROM 
  mytable a 
WHERE 
  a.date BETWEEN :dataIni AND :dataFin

Is there any way to return the values of the parameters as query fields using Firebird?

  • It is not very clear what you are asking. Please explain better.

  • You want to cast before submitting the date for validation?

  • I believe that what AP wants, is to bring the values of the parameters as query fields

  • You’re probably trying to solve some mystery. Tell us the goal of wanting to bring the value of the parameters in the query result and we can help.

  • There’d be no way to do it using Prepared Statements? I don’t know much about Irebird to know if it has such functionality.

  • @gabrielhof Yes, Firebird has Prepared statements. But I don’t understand how this relates to bringing the value of the parameters in the Select result.

  • It could pass this as parameters in the execution of the statement. But anyway, it would be necessary to pass the same parameter twice (one to the select and another to the where). As you replied, it makes no sense to do this, but I was wondering if it was possible to do.

  • It would be an XY Problem?

  • What is the test environment?

Show 4 more comments

2 answers

3


If I understood right is just put the parameters as Fields:

SELECT 
  a.*, 
  cast(:dataIni as date) AS inidate , 
  cast(:dataFin as date) AS inidate,
  :dataIni as DataInicial,
  :dataFin as DataFinal 
FROM 
  mytable a 
WHERE 
  a.date BETWEEN :dataIni AND :dataFin

I don’t know if that’s what you need!!!

0

There’s no way to do that.

Nor does a resource like this seem necessary because who sent the query is also who will get the results and this subject knows the values that passed as parameter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.