Home > front end >  A result was returned when none was expected error in exposed ORM with KTOR
A result was returned when none was expected error in exposed ORM with KTOR

Time:10-06

This is the code block of DAO layer with kotlin and Ktor with exposed ORM

query = "WITH temporaryTable (averageValue) as (SELECT avg(Attr1) ....;"
transaction{
    exec(query){
        while(it.next()){
            ...
            ...
        }
    }
}

After running the code I am getting org.postgresql.util.PSQLException: A result was returned when none was expected error.

SELECT query is working in this way but WITH query is giving the above error.

CodePudding user response:

I would suggest to provide explicitStatementType param to help Exposed to understand that your query is a select:

val query = "WITH temporaryTable (averageValue) as (SELECT avg(Attr1) ....;"
transaction{
    exec(query, explicitStatementType = StatementType.SELECT){
        while(it.next()){
            ...
            ...
        }
    }
}
  • Related