0

The code snippet shown below is supposed to be used to retrieve some data from database.

import anorm._

object Instruction {

 def findAll(date:String):List[RealTimeInstruction]={

    query = SQL("""
                select * from instructions where date > {dd}
                """).on("dd"->date)
 }

}

Then I would like to use pattern matching to execute the query and process the results. However, when I attemp to use query.map(...) I get the following:

value map is not a member of anorm SimpleSql.

How can I do it?

1
  • queryis just an SQL query. You first have to execute it. Then you can pattern match results or use the parser to create the objects you want. The usage depends on what you are trying to do. You should perhaps read again the anorm tutorial. If it's not clear for you, you should edit your code snippet to explain your goal. Commented May 14, 2012 at 13:36

1 Answer 1

1

You need to create a ResultSetParser to parse the result set into somehting you can pattern match on. perhaps something like

val rowParser : RowParser[String~Date] = get[String]("instructions.name")~get[Date]("instructions.date")
val resultSetParser = rowParser *
(query as resultSetParser) map { case name~date => ... }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.