After reading about how to manage the source repository, you will probably be relieved to find that there is much less complexity involved in working with the target repository. Since the target is on the receiving end, there is no need to fiddle with the WHERE clause. You simply set and initialize the target, and then you are ready to write into that repository.
The settrg procedure defines the type of repository and its structure. The header for settrg is:
PROCEDURE settrg (trgtype_in IN VARCHAR2, name_in IN VARCHAR2 := 'PLV_source', target_name_col_in IN VARCHAR2 := 'name', trgtype_col_in IN VARCHAR2 := 'type', target_line#_col_in IN VARCHAR2 := 'line', target_text_col_in IN VARCHAR2 := 'text');
The first argument, trgtype_in , is the type of repository. The second argument, name_in , is the name of the repository. Its content varies according to the type of repository and is explained below. The third through sixth arguments provide the names of the columns required for a database table target. The default values match the structure of the default table ( PLV_source ).
The settrg procedure transfers the arguments to the trgrep record, which is defined using the repos_rectype shown earlier. If you are using a database target, then the INSERT statement that will be used to write lines to that table is constructed as follows:
trgrep.insert_sql := 'INSERT INTO ' || trgrep.name || '( ' || target_name_col_in || ', ' || trgtype_col_in || ', ' || target_line#_col_in || ', ' || target_text_col_in || ') ' || 'VALUES (:name, :type, :line, :text)';
Notice that in the INSERT statement the name of the table and its columns are not hard-coded. You can establish those names in your call to PLVio.settrg . For example, if the target table is structured like this:
CREATE TABLE temp_target (progname VARCHAR2(100), progtype VARCHAR2(30), linenum INTEGER, linetext VARCHAR2(120));
then you would need to call settrg as follows:
PLVio.settrg (PLV.dbtab, 'temp_target', 'progname', 'progtype', 'linenum', 'linetext');
If you are using a string target, all arguments after the first are ignored. Lines of text are written to the string_repos.text_out field with newline characters inserted between lines.
If you are using a file target, then the name_in argument is the name of the file. All other arguments are ignored. Lines of text are written to the file in the order of execution.
NOTE: Only the Write mode (replacing current contents of file) is supported. You cannot use PLVio to append to the end of a file.
Since there are really no intermediate actions between setting and initializing the target repository, the first line of settrg executes inittrg , so there is no need for you to do so explicitly.
If the target is a PL/SQL table, the PLVio target_table is emptied. If the target is a string, string_repos.text_out is set to NULL.
Currently, if the target is a database table or file, no initialization actions are taken. You will, therefore, need to perform the appropriate management on these data structures before using the PLVio.put_line procedure.
Copyright (c) 2000 O'Reilly & Associates. All rights reserved.