Sql query is not updated if the new query returns the same columns

Take a look to these tables

TABLE_A

  • name
  • address

TABLE_B

  • name
  • country

Now, I will create a query in purpose to select a column that does not exists in a table

SELECT a.name, a.country
FROM TABLE_A a, TABLE_B b
WHERE a.name = b.name

Take a look how I am selecting the country from table a, but it does not exists in this table, as a result ScriptCase will display a error as expected. Now, fix the select:

SELECT a.name, b.country
FROM TABLE_A a, TABLE_B b
WHERE a.name = b.name

As you can see the result’s structure stills the same, but it is returned from another table, the query now is correct. However, ScriptCase “thinks” that is the same query, so it does not apply the changes, this can be confirmed by setting the debug mode to true and seeing the old query there.

Another example:

I have entered this sql query:


SELECT ACCION, TPO_ACCION, ENLACE,
ESTADO_ACCION_FORMATIVA('[cedula]', [B]A.ACCION[/B]) AS ESTADO, competencia
  FROM SRH257
 WHERE COMPETENCIA = '[competencia]'
   AND COD_GRADO <= '[esperado_cualitativo]'
   AND EDO_ACCION = 'A'

The column A.ACCION does not exists because the table has not alias, so ScriptCase advised me of this error after save. So, I proceed to fix it:


SELECT ACCION, TPO_ACCION, ENLACE,
ESTADO_ACCION_FORMATIVA('[cedula]', [B]ACCION[/B]) AS ESTADO, competencia
  FROM SRH257
 WHERE COMPETENCIA = '[competencia]'
   AND COD_GRADO <= '[esperado_cualitativo]'
   AND EDO_ACCION = 'A'

Now, it compiles good, but SC stills executing the old query. The worse thing is that is not easy to work around this issue.