0

I am storing json object into Postgresql database table for each insertion or on Submit button using Play Framework and Postgresql. But my requirement is that, I need to create and execute/call one sample batch file to load/save this json object into created batch file on each clicking of Submit button (that is while storing json object into Postgresql database simultaneously). I don't know how to create the batch file for it and call ?(either using triggers or any ?). Please help me and Thanks in advance.

appjson.scala: (which saves submitted json object into database)

case class JsonData (
  id: Pk[Long], content: String
)
object JsonData {
  val extractor = {
    get[Pk[Long]]("jsondata.id") ~
    get[String]("jsondata.content") map {
      case id~content => JsonData(id, content)
 }
 }
  def save(jsondata: JsonData): Unit = {

    DB.withConnection { implicit connection =>
      SQL("INSERT INTO jsondata(content) VALUES(CAST({content} AS json))").on(
        'content -> jsondata.content
      ).executeInsert()
    }
  }
}
cchantep
  • 9,118
  • 3
  • 30
  • 41
Dhana
  • 711
  • 3
  • 14
  • 40
  • 1
    This has nothing to do with batch files. Remove the tag. Hover over it for a brief description. –  Feb 05 '16 at 07:57
  • Why would you want to store a JSON document in a batch file? Windows batch files can "execute" a JSON document. That makes no sense –  Feb 05 '16 at 09:18
  • @a_horse_with_no_name, I need whatever I store the json object into my database that should be stored in my either in any text file or as a batch file on my Submit button ? I am not sure how can I implement it ? Please let me know. Thanks in advance. – Dhana Feb 05 '16 at 09:58
  • have you looked at just writing the value into a text file, with [better-files](https://github.com/pathikrit/better-files) or @epicurist's answer in [this SO question](http://stackoverflow.com/questions/4604237/how-to-write-to-a-file-in-scala)? – wwkudu Feb 05 '16 at 12:31

0 Answers0