1

I have used this code to store the data(name and marks) in the table, now i want to retrieve that data in the form of record. how can i get that?

void addmarks(account_name examiner, account_name student, uint64_t marks)
    {
        auto toitr = _accounts.find(student);
        if(toitr == _accounts.end())
        {
            _accounts.emplace(examiner, [&](auto& st)
            {
                st.name = student;
                st.obtainedmarks = marks;
            });
        }
        else
        {
            _accounts.modify(toitr,0,[&](auto& st)
            {
                st.obtainedmarks += marks;
                eosio_assert(st.obtainedmarks >= marks, "Marks Assigned");
            });
        } 
    } 

kindly help me to solve it?

  • use find or get, you have already write auto toitr = _accounts.find(student) – Jimmy Guo Jul 23 '18 at 12:31
  • yes but it is not working, It returns nothing – Sheharyar Ch Jul 24 '18 at 5:42
1

The way to do this with the cl would be to go:

cleos get table <contract> <scope> <table>

contract TEXT - The contract who owns the table
scope TEXT - The scope within the contract in which the table is found
table TEXT - The name of the table as specified by the contract abi

Example:

$ cleos get table eosio.token eosio accounts
{
  "rows": [{
      "balance": "999999920.0000 SYS"
    }
  ],
  "more": false
}
| improve this answer | |
  • This is working. Thankyou so much <3 – Sheharyar Ch Jul 24 '18 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.