Scope of an SQL Object
An SQL object can be instantiated only from PeopleCode.
This object can be used anywhere you have PeopleCode, that is, in an application class, Application Engine PeopleCode, record field PeopleCode, and so on.
Your SQL statements sometimes change the database. When your SQL changes the database, your code should be only in one of the following events:
SavePreChange
WorkFlow
SavePostChange
Message Subscription
FieldChange
Application Engine PeopleCode action