0

I am trying to execute an SQL statement at AWS QLDB like the example in the AWS SDK Git but using Kotlin. The example shows me that I can return something at "execute" (represented by "searchValue")

  String searchValue = driver.execute(
        txn -> {
            Result result = txn.execute(searchQuery);

            String value = "";
            for (IonValue row : result) {
                value = ((IonString) row).stringValue();
            }
            return value;
        });

Based on the example, I've tried to receive the return in "executionReturn" and transform the values at "let" function but "executionReturn" cames as undefined.

        val executionReturn = driver.execute { txn: TransactionExecutor ->
            val result: Result = txn.execute(
                "SELECT * FROM Table")
            )
            result

        }
        executionReturn.let {
            list.plus(it as IonStruct)
}

How could I return a specific value from "driver.execute"?

2 Answers2

0

Thanks for your interest in QLDB. Does something like the following help you?

        val executionReturn = driver.execute<List<IonValue>> { txn: TransactionExecutor ->
            val result = txn.execute(
                "SELECT * FROM Table").toList()
            result
        }
        executionReturn.let {
            list.plus(it as IonStruct)
        }
Ang
  • 66
  • 3
0

I've changed the approach of the collection. I've created a mutableListOf and then used the method "add"

Then it worked