Here is the query-
sql = "SELECT EMP_NAME, EMP_NUMBER, EMP_JOINING_DATE, :joiningDate as NAMED_PARAM_DATE from EMP_TABLE where EMP_JOINING_DATE>:joiningDate"
code:
NamedParameterJdbcTemplate jdbcTemplate;
.....
MapSqlParameterSource sqlParams = new MapSqlParameterSource();
sqlParams.addValue("joiningDate", System.getenv("JOIN_DATE"), Types.DATE);
results = this.jdbcTemplate.query(sql, sqlParams, new BeanPropertyRowMapper<Employee.class>(Employee.class))
This gives me below error
nested exception is com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-418, SQLSTATE=42610, SQLERRMC=unresolved untyped expression, DRIVER=4.25.1301
Is it possible to do that? I can do it alternate way but just wanted to check from Query perspective as we can select any hard-coded value in SQL query using any DB client.
Note: Updated the query for more clarity, also this code works fine when I take out joiningDate from SELECT statement.