cancel
Showing results for 
Search instead for 
Did you mean: 

trigger on select

Baron
Participant
0 Kudos
1,089

A funny question!

Unfortunately we can't create a trigger which observes SELECTs on a table.

Has maybe someone an idea how can I log each query on each table in my DB? (the goal is for analysing an error in our application).

Accepted Solutions (0)

Answers (2)

Answers (2)

Breck_Carter
Participant

Request-level logging is (apparently) described in two places...

Request Logging

Logging Server Requests

See also the Tracing tab in the ODBC Data Source Administrator. Be careful, however, to turn the trace off when you're done, otherwise you'll fill up the disk 🙂

justin_willey
Participant

Have a look at Auditing in the documentation - it might give you what you need.

Baron
Participant
0 Kudos

I find only these 2 procedures:

sa_disable_auditing_type

sa_enable_auditing_type

But how can I log all SELECTs on a specific Table?

Breck_Carter
Participant

You will not find any trigger-like features for SELECT statements, they don't exist, and they won't ever exist IMO.

justin_willey
Participant
0 Kudos

I don't think that any of the options let you specify particular tables for auditing or request logging.

Breck_Carter
Participant
0 Kudos

I find only...

See Tutorial: Auditing in the SQL Anywhere Help.

Baron
Participant
0 Kudos

Ok, what should then I understand from the answer:

Have a look at Auditing in the documentation - it might give you what you need.

justin_willey
Participant

Just what it says. You asked how to "log each query on each table in my DB?" - that's one of the things auditing can do. It records queries in the transaction log.

Whether it does it in a way that is useful to you, only you can decide.

Baron
Participant
0 Kudos

But according to the tutorial (so far as I understood), auditing logs any violation in the transaction log (i.e. it logs a failed attempt to query a table), but it doesn't log successfull queries on the same table.

VolkerBarth
Contributor
0 Kudos

Just try the sample when using a user with according permission to do the sample select, e.g. the user "BROWSER" (password "browse" according to the docs), and check what the log reveals.

(FWIW, I added a comment to your question, just in case...)