ADW ADW - 1 month ago 5x
Scala Question

To multi insert in cql for scala

I want to insert the result of first query in second query, I need to know how to multi insert values in Cassandra Query Language.Please enlighten me.

def daomethod(seconditemtable:SecondItemTable):java.util.List[Row]={

val query=session.execute("select item from itemtable").all() //first query

val>x.getString("item")).toList.distinct //List(item1,item2,item3)

val secondquery="select * from seconditemtable where entity=? and item=? and date>=? and date<=?" //second query

val statement=session.prepare(secondquery)

val boundstatement= new Boundstatement(statement)

session.execute(boundstatement.bind(seconditemtable.entity,queryvalue,, //how to insert multiple value of firstquery in item column

Thanks in advance


You can try something like that

val secondquery=s"select * from seconditemtable where entity=? and item in (${queryvalue.mkString(",")}) and date>=? and date<=?"

to take advantage of cql in statement. More details on it