I have the following query to create a partition, it's working with hardcoded values but is unable to replace parameters dynamically.
@Modifying
@Query(value = "CREATE TABLE :name PARTITION OF sample_table\n"
+ "FOR VALUES FROM (a) TO (b)", nativeQuery = true)
void createPartition(@Param("name") String name, @Param("a") long a, @Param("b") long b);
This statement I want to generate which is working fine on postgres console:
CREATE TABLE sample_table_p1 PARTITION OF sample_table
FOR VALUES FROM ('1020000') TO ('2000000');
error:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Thanks in advance :)