|
List Info
Thread: RE: Strange PL Table behavior
|
|
| RE: Strange PL Table behavior |
  United States |
2008-08-14 15:15:31 |
|
|
Did you mean for the END LOOP to be where it is for the first loop? That
will always only enter one record, the last one. Shouldn't the "Process Table
Row" bit be inside that first end loop? ... just a thot ..
Suzanne ( 2Bwy
A13.32) desk: 646-252-8663, cell: 347-907-1125
I
am having a strange problem with a PL table I am using in my application. It is
a pl table that stores rules for the current table I am processing, so it is a
pl table that is based on a record type and indexed by binary_integer.
When
I populate it for this one particular table I can see that there is only one
row. I pass this pl table to a different procedure within my package. For
testing purposed I loop through each row in the pl table by using the tbl.FIRST
and tbl.NEXT built ins prior to calling the procedure, I also do it first thing
in my called procedure. In both cases there only appears to be one item in the
table because I only go through the loop one time. In the called procedure as I
am looping through the columns being processed for the database table, I check
each column to see if its id exists in my pl table. Here is where it gets
strange, using the tbl.EXISTS(id) I get two columns that say they exist in the
pl table, even though my previous loop check said there were only one row.
Here
is some of the code:
Pl
table definition:
TYPE
col_rule_type IS RECORD
(column_name
VARCHAR2(30),
RULE
mms.sysman_dd_mrg_rule_pr.rule%TYPE,
data
mms.sysman_dd_mrg_rule_pr.data%TYPE,
parent_table
mms.sysman_dd_mrg_rule_pr.parent_table_name%TYPE);
TYPE
col_rule_tbl IS TABLE OF
col_rule_type INDEX BY BINARY_INTEGER;
TYPE
proc_data_type IS RECORD (select_stmt
VARCHAR2(32767),
column_list
VARCHAR2(32767),
column_types
VARCHAR2(32767),
nbr_columns
NUMBER,
pk_column
VARCHAR2(30),
pk_idx
NUMBER,
uk_cols
VARCHAR2(32767),
uk_idxs
VARCHAR2(32767),
lob_tbl
col_LOB_tbl,
rules
col_rule_tbl);
TYPE
proc_data_tbl IS TABLE OF proc_data_type INDEX BY
BINARY_INTEGER;
Note:
the rule table is part of another table that is used to store info about the
database table
Here
is where I test to see how many rows are in the table prior to calling the
stored proc:
ndx :=
p_proc_data(j.sysman_dd_table_id).rules.FIRST;
LOOP
exit when ndx IS NULL;
column :=
p_proc_data(j.sysman_dd_table_id).rules(ndx).column_name;
rule :=
p_proc_data(j.sysman_dd_table_id).rules(ndx).rule;
ndx :=
p_proc_data(j.sysman_dd_table_id).rules.NEXT(ndx);
END LOOP;
ProcessTableRow(j.table_name, v_columns, v_values, v_col_types, v_idx,
p_proc_data(j.sysman_dd_table_id).rules,
'INSERT', v_pk_col, v_pk_val, v_old_pk_val,
v_col_lob, v_new_uk_sql, v_old_uk_sql, v_out);
Here
is where I test the rule table in processTableRow:
ndx := p_rule_tbl.FIRST;
LOOP
exit when ndx IS NULL;
column := p_rule_tbl(ndx).column_name;
rule := p_rule_tbl(ndx).rule;
ndx := p_rule_tbl.NEXT(ndx);
END LOOP; -- The debugger only went through this loop one
time
Here
is the code where I test if a rule exists for the column being
processed:
IF
p_rule_tbl.EXISTS(ndx) THEN – this is where it says a row exists for two columns
even though there is only one row in the table
It
is like there is some kind of memory leak or something. I have tried everything
I can think of and nothing seems to work. If anyone sees something or has an
idea I would appreciate your input.
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|