Is it possible to emit event in view function (via event or logi)?
Since event logs are stored in transaction receipts, I do not believe it is possible to emit an event within a view function since no transaction occurs.
I don't think this is possible either. The return value from a function which creates a transaction will be the transaction receipt. Within the receipt, you can find any events which were emitted within that function.
Q1: An event is a state change. It's not possible to emit them from
pure functions, or
constant in the old syntax.
Q2: It is not possible to get response values from a signed transaction. You will always get a transaction receipt.
The patterns take some getting used to. I'm a big believer in emitting auditable event logs for every important state change. When transactions are mined, the pertinent information arrives with the confirmation as event log arguments. Those are for off-chain clients.
return values or still important. They are the response values if the function is called from another function or contract.
bool result = myOtherContract.insertSomething(); // expecting "true"/success
If that's important to a client, something like:
emit LogResult(msg.sender, result);
Hope it helps.
The first question, It is not possible because the event modifies the state. In Remix you will see a warning for doing this.
The second question. You can execute the functions locally without sending a transaction to the network using Call, it will not consume gas and will be executed immediately.
However, if what you are aiming at is to get transaction made by users of your system before the transactions are mined, this is not possible.
Hope this helps