A script that reads or changes the repository directly in the database must first log on to the business layer, because every business object shows no rows until a [[Invantive Studio/Repository/Concepts/Session|session]] is opened. A script that runs as the owner of the repository schema logs on as follows:
- Connect to the database as the owner of the schema that holds the repository.
- Call `itgen_session.set_session_info` before the first statement on a business object, with the name of the script as module and action:
```sql
begin
itgen_session.set_session_info
( p_module => 'my_script.sql'
, p_action => 'my_script.sql'
, p_user => itgen_constants.g_user_sys_logon_code
, p_query => 'various'
, p_remote_addr => coalesce(sys_context('userenv', 'ip_address'), '?')
, p_remote_host => sys_context('userenv', 'host')
, p_request_url => 'n/a'
, p_session_id => 'my_script.sql-' || to_char(sysdate, 'YYYYMMDDHH24MISS')
, p_password => null
, p_skip_authentication => true
, p_remote_user => null
, p_owner => null
, p_connection => null
, p_context => null
, p_partition => null
, p_application_name => 'SQL*Plus'
, p_application_version => null
, p_os_user => coalesce(sys_context('userenv', 'os_user'), '?')
);
--
-- The statements of the script follow here.
--
null;
end;
/
```
- Replace `null;` by the statements of the script, or run them after the block in the same database session.
The log-on uses the system user of the repository and skips the check of a password, which only the owner of the schema may do. A script run through Invantive Query Tool or Invantive Data Hub with the Invantive Producer connection does not need this step: the product logs on itself.