Null value in Nested table of nested table for xml guru Steve Muench
The procedure I am using takes xml document with nested levels and insert into single table using DBMS_XMLSave.insertXML.
I am able to insert into table without any error message but when I am selecting row from table, it is showing null values in all the column of nested table's inner nested table.
When I am removing nested table's nested table by replacing with object type, it is showing data of object type for the first occurance and ignoring the rest nested occurance.
Help is greatly appreciated.
Below is the sql I used to create objects and table:-
Create or Replace Type addressType as Object
Line_one varchar2(40),
Line_two varchar2(40),
City Varchar2(30),
State Varchar2(2),
zip Varchar2(10)
Create or Replace Type ce_reqType as Object
Status varchar2(25),
Status_date Date,
type_code Varchar2(25),
review_begin_date Date,
assigned_review_date date
Create or Replace type ce_reqListType
as table of ce_reqType;
Create or Replace Type LicenseType as Object
type_code Varchar2(10),
license_number Varchar2(16),
ce_requirements ce_reqListType
Create or Replace type LicenseListType
as table of LicenseType;
Create table IndividualType
individual_id Number(9),
social_security_number Varchar2(9),
Last_name varchar2(40),
First_name Varchar2(40),
Middle_name Varchar2(40),
Birth_date Date,
address addressType,
Licenses LicenseListType
nested table licenses store as licensestab
(nested table ce_requirements store as lic_ce_reqtab);
Maddy wrote:
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)Because instead of adding an element to bookset collectionto are assigning (ergo replacing) it a collection containing last fetched book. Use:
declare
bookset book_table;
ln_cnt pls_integer;
begin
bookset := book_table(book_obj('madhu','kongara','sudhan'));
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
bookset := book_table(); --> Assigning back to NULL.
dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
for rec in (select * from book) loop --> Now Looping two times.
dbms_output.put_line(' name > '||rec.name);
bookset.extend;
bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract);
end loop;
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
end;
The count is 1
The count is 0
name > Harry Potter
name > Ramayana
The count is 2
PL/SQL procedure successfully completed.
SQL> Or better use bulk collect:
declare
bookset book_table;
ln_cnt pls_integer;
begin
bookset := book_table(book_obj('madhu','kongara','sudhan'));
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
bookset := book_table(); --> Assigning back to NULL.
dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
select book_obj(name,author,abstract)
bulk collect
into bookset
from book;
for i in 1..bookset.count loop --> Now Looping two times.
dbms_output.put_line(' name > '||bookset(i).name);
end loop;
dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
end;
The count is 1
The count is 0
name > Harry Potter
name > Ramayana
The count is 2
PL/SQL procedure successfully completed.
SQL> SY.
Similar Messages
-
Designer 9i - nested DDL structure not executable for XML
To support an XML data transfer, we need to define types,collections, and tables. When we define a table that references types and collections, we do not get adequate DDL from Designer 9i that identifies all of the nested structures, and the DDL that is generated is not executable. We can manually type the DDL and specify the appropriate nesting. We have done that, executed that successfully. We have then reverse engineered this table into Designer 9i, and requested DDL from it. The resulting DDL is not executable. Has anyone run into this problem?
Designer 9i does not support these complex datatypes, hence your errors.
Regards
Sue -
Need to display null values against table
Hi All,
I have one table in which I only need to display null values along with the rest of columns. for example
ename sal date
scott 2000 15/07/06
Michal
now my query should return---
ename sal date
michal
hare krishna
AlokMaybe it is something like this?:
michaels> select column_name || ' contains ' ||
dbms_xmlgen.getxmltype ('select sum(nvl2(' || column_name || ',0,1)) c from ' || table_name ).extract ('//text()').getnumberval() ||
' NULL values' null_columns
from cols
where table_name = 'EMP'
and dbms_xmlgen.getxmltype ('select sum(nvl2(' || column_name || ',0,1)) c from ' || table_name ).extract ('//text()').getnumberval() > 0
NULL_COLUMNS
MGR contains 1 NULL values
COMM contains 10 NULL values -
Hi Experts,
It's a challenging question to all experts
Q1)
If we create an UNIQUE Key on a table Why it's accepting morethan one NULL value.
Q2)
If we use DISTINCT key word on a column that contains morethan one NULL value why it's displaying one NULL value.
Q3)
If we use UNION on a column that contains morethan one NULL value, why it returns one NULL value.
Q4)
If we write a query like this
SELECT * FROM emp WHERE comm IS NULL
Why it returns all the employes those contain no comm.
For 1st question some pleople are answering any NULL is not equal to other NULL value so that it accepting multiple NULL values.
For 2nd,3rd question some people are answering because DISTINCT and UNION eliminates duplicate values.
According to the first question answer how it is possible.
For 4th question answer some people are saying all the NULLs are equal so that it displaying all the employess which are having no commision.
Any One Plese help how NULL works in all four scenarios.
Thanks in advance.user9077483 wrote:
Hi Experts,
It's a challenging question to all experts
Q1)
If we create an UNIQUE Key on a table Why it's accepting morethan one NULL value.It depends really. Are you talking a SINGLE COLUMN unique index? If so, Oracle won't index the NULLs values, hence you can put in as many as you want.
If it's a concatenated INDEX then the number of NULL values may be limited. See below for an example:
SQL> CREATE TABLE TEST(TXT VARCHAR2(10), TXT2 VARCHAR2(10));
Table created.
SQL> CREATE UNIQUE INDEX TEST_TXT_UNQ ON TEST(TXT);
Index created.
SQL> INSERT INTO TEST(TXT) VALUES(NULL);
1 row created.
SQL> INSERT INTO TEST(TXT) VALUES(NULL);
1 row created.
SQL> CREATE UNIQUE INDEX TEST_TXT_UNQ2 ON TEST(TXT,TXT2);
Index created.
SQL> INSERT INTO TEST(TXT,TXT2) VALUES('A',NULL);
1 row created.
SQL> INSERT INTO TEST(TXT,TXT2) VALUES('A',NULL);
INSERT INTO TEST(TXT,TXT2) VALUES('A',NULL)
ERROR at line 1:
ORA-00001: unique constraint (TUSER.TEST_TXT_UNQ) violated
Q2)
If we use DISTINCT key word on a column that contains morethan one NULL value why it's displaying one NULL value.Per the definition of DISTINCT:
Specify DISTINCT or UNIQUE if you want the database to return only one copy of each set of duplicate rows selected. These two keywords are synonymous. Duplicate rows are those with matching values for each expression in the select list.It returns only one copy of a ROW even if a column in a row contains NULLs.
>
Q3)
If we use UNION on a column that contains morethan one NULL value, why it returns one NULL value.For the same reason as above UNION removes duplicates. Use UNION ALL if you want duplicate values.
>
Q4)
If we write a query like this
SELECT * FROM emp WHERE comm IS NULL
Why it returns all the employes those contain no comm.Because you asked it to? The IS NULL condition is special in that it checks the column to see if it contains a NULL value. If it is the condition evaluates to true. You can't use WHERE COMM = NULL because you can't use an equality operator to compare NULL values. -
Null value of fax and Null value of email is not reflecting in SRM
Hi
If you change the Vendor fax and email to null value in SAP(transaction XK02 in communication for address) and replicate the vendor in SRM 5.0 with transaction BBPUPDVD, still in manage business partners BBPMAININT as vendor I am able to see old fax number and email id instead of null value in Contact for Business Partner area.
Where as if we change vendor fax and email to new fax and email , after replication we wre able to see new fax and email id in manage business partners transaction as vendor.
Regards
Dayalsolved!
-
I need to update several AD user accounts with the following:
Get-ADUser -Filter * -SearchBase 'ou=Active,ou=Students,OU=People,dc=domainr,dc=com' -Properties userPrincipalName | foreach { Set-ADUser $_ -UserPrincipalName ("{0}@{1}" -f $_.name,"domain.com")}
This works fine, but I only want to update the records that are empty/blank. How do I apply a search/apply for only those with a null value?
mdclemFausto and Clayman2, thank you for replying. I've added the changes:
Get-ADUser -Filter * -SearchBase 'ou=Active,ou=Students,OU=People,dc=domain,dc=com' -Properties userPrincipalName -Filter "userPrincipalName -eq $null"| Set-ADUser -Whatif -UserPrincipalName ("{0}@{1}" -f $_.name,"domain.com")
But now get the following error:
PS C:\Windows\system32> Get-ADUser -Filter * -SearchBase 'ou=Active,ou=Students,OU=People,dc=domain,dc=com' -Properties userPrincipalName -Filter "userPrincipalName -eq $null"| Set-ADUser -Whatif -UserPrincipalName ("{0}@{1}" -f $_.name,"domain.com")
Get-ADUser : Cannot bind parameter because parameter 'Filter' is specified more than once. To provide multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter value1,value2,value3".
At line:1 char:114
+ ... rPrincipalName -Filter "userPrincipalName -eq $null"| Set-ADUser -Whatif -UserPr ...
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : ParameterAlreadyBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Where did I mess this up?
mdclem -
Partition exchange error on table with nested table
On Oracle 11.2.0.1, I have a partitioned table with some partitions that need to be 'archived' (in terms of moving partitions to an 'archive' table).
I have a source table like:
CREATE TABLE IS_PODACI245
ID_OBJEKTA_IDENTIFIKACIJA NUMBER(10),
ID_OBJEKTA NUMBER(20),
DATUM TIMESTAMP(6) NOT NULL,
TZ NUMBER(3),
DATA1 NUMBER(10),
DATA2 NUMBER(6),
DATA3 NUMBER(10),
DATA4 NUMBER,
DATA5 T_NTCIP_CLIMATE_TABLE
NESTED TABLE DATA5 STORE AS IS_PODACI245_STORE_TABLE
TABLESPACE DATA
PARTITION BY RANGE (DATUM)
PARTITION P_201107 VALUES LESS THAN (TIMESTAMP' 2011-08-01 00:00:00')
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE VALUES LESS THAN (MAXVALUE)
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX IDX_IS_PODACI245_KOMPLEKS ON IS_PODACI245
(ID_OBJEKTA_IDENTIFIKACIJA, ID_OBJEKTA, DATUM)
TABLESPACE DATA
LOCAL (
PARTITION P_201107
LOGGING
NOCOMPRESS
TABLESPACE DATA,
PARTITION P_MAXVALUE
LOGGING
NOCOMPRESS
TABLESPACE DATA
NOPARALLEL;
CREATE OR REPLACE TYPE t_ntcip_climate_table as table of t_ntcip_climate_fmt;
CREATE OR REPLACE TYPE t_ntcip_climate_FMT as object
( dev_index number(6)
, dev_description varchar2(512)
, dev_type number(10)
, dev_status number(10)
, dev_mfr_status varchar2(512)
, dev_active number(3)
, dev_test_activation number(10)
/I would like to make exchange partition using stage table, and everything is going fine on all tables, but only on a few of them (listed source is one of them, and they're only tables with nested tables wihin), where I get an error.. but sometimes ;)
on a statement like:
ALTER TABLE IS_PODACI245_ARH EXCHANGE PARTITION P_201106 WITH TABLE IS_PODACI245_STAGE EXCLUDING INDEXES WITHOUT VALIDATION;I got an error:
ORA-00001: unique constraint (TXV.SYS_C0032911) violated
it's an unique index between parent and nested table.
what could cause that problem?Dear,
I suppose that the unique constraint
ORA-00001: unique constraint (TXV.SYS_C0032911) violatedis the one you 've created on the nested table IS_PODACI245_STORE_TABLE
If so, why not disable that constraint and try again.
I have never exchanged such a kind of partitioned table having a nested table in it. But, I could imagine that the cloned non partitioned table IS_PODACI245_STAGE should at least be the exact image of the partitioned table IS_PODACI245_ARH (of course without the partition part) but with the nested table part and including all indexes
In addition, if you have a parent/child relationship between your partitioned tables, then there is a chronological order of exchange starting by the child and then finishing by the parent
see the following link for more information about this order of exchange (and comment 2 for an example also)
http://jonathanlewis.wordpress.com/2006/12/10/drop-parent-partition/#more-65
Hope this helps
Mohamed Houri -
Fixed length outer table with nested repeating group inner table.
I had to re-create a PDF using tables in an RTF template. It has a fixed 1 page width. However, one of the rows in the template has a nested table with a repeating group. I set the width of the outer table row width to 2". However when I have repeating groups it makes the outer row grow wider than the 2" inches. The option to un-select "automatically resize to fit contents" is grayed out.
Is there a way to keep the outer table width fixed with an inner repeating group?
Thanks.
--Johnnie
Edited by: Vortex13 on Jun 13, 2012 11:15 AMHi Borris,
Found the following in the Oracle Documentation under: Oracle8i Application Developer's Guide - Object-Relational Features Release 2 (8.1.6)
2 Managing Oracle Objects / Using Collections / Collection Unnesting
URL: http://www.znow.com/sales/oracle/appdev.816/a76976/adobjmng.htm#1002885
Oracle8i also supports the following syntax to produce outer-join results:
SELECT d.*, e.* FROM depts d, TABLE(d.emps)(+) e;
The (+) indicates that the dependent join between DEPTS and D.EMPS should be NULL-augmented. That is, there > will be rows of DEPTS in the output for which D.EMPS is NULL or empty, with NULL values for columns
corresponding to D.EMPS. -
Problem in truncate/drop partitions in a table having nested table columns.
Hi,
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table? IF I change column types from nested table to varray type, will it help?
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
Thanks in advance.>
I have a table that has 2 columns of type nested table. Now in the purge process, when I try to truncate or drop a partition from this table, I get error that I can't do this (because table has nested tables). Can anybody help me telling how I will be able to truncate/drop partition from this table?
>
Unfortunately you can't do those operations when a table has a nested table column. No truncate, no drop, no exchange partition at the partition level.
A nested table column is stored as a separate table and acts like a 'child' table with foreign keys to the 'parent' table. It is these 'foreign keys' that prevent the truncation (just like normal foreign keys prevent truncating partions and must be disabled first) but there is no mechanism to 'disable' them.
Just one excellent example (there are many others) of why you should NOT use object columns at all.
>
IF I change column types from nested table to varray type, will it help?
>
Yes but I STRONGLY suggest you take this opportunity to change your data model to a standard relational one and put the 'child' (nested table) data into its own table with a foreign key to the parent. You can create a view on the two tables that can make data appear as if you have a nested table type if you want.
Assuming that you are going to ignore the above advice just create a new VARRAY type and a table with that type as a column. Remember VARRAYs are defined with a maximum size. So the number of nested table records needs to be within the capacity of the VARRAY type for the data to fit.
>
Also, is there any short method of moving existing data from a nested table column to a varray column (having same fields as nested table)?
>
Sure - just CAST the nested table to the VARRAY type. Here is code for a VARRAY type and a new table that shows how to do it.
-- new array type
CREATE OR REPLACE TYPE ARRAY_T AS VARRAY(10) OF VARCHAR2(64)
-- new table using new array type - NOTE there is no nested table storage clause - arrays stored inline
CREATE TABLE partitioned_table_array
( ID_ INT,
arra_col ARRAY_T )
PARTITION BY RANGE (ID_)
( PARTITION p1 VALUES LESS THAN (40)
, PARTITION p2 VALUES LESS THAN(80)
, PARTITION p3 VALUES LESS THAN(100)
-- insert the data from the original table converting the nested table data to the varray type
INSERT INTO PARTITIONED_TABLE_ARRAY
SELECT ID_, CAST(NESTED_COL AS ARRAY_T) FROM PARTITIONED_TABLENaturally since there is no more nested table storage you can truncate or drop partitions in the above table
alter table partitioned_table_array truncate partition p1
alter table partitioned_table_array drop partition p1 -
Fill internal table with mutliple entries for nested structure
Dear ABAP Experts,
I have a question related to fill internal tables with nested structures.
I have a structure like this:
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
BEGIN OF kons,
kon TYPE YKONSEINHEIT,
END OF kons,
jahr TYPE CHAR04,
END OF proto.
Now I need to fill this structure with values (over an internal table), but how can I achieve that I save multiple datas für element "kon" für one single entry of structure "proto"?
An example could be:
sicht = '01'
version = '100'
kon = 1001 (first entry)
kon = 1002 (second entry)
usw... (n entry)
jahr = '2008'
Thanks in advance for every helpful answer.
Regards
ThomasBEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
jahr TYPE CHAR04,
END OF proto.
DATA: ls_proto TYPE proto,
lt_proto TYPE STANDARD TABLE OF proto,
ls_kon
ls_proto-sicht = '01'.
ls_proto-version = '100'
INSERT '1001' INTO TABLE ls_proto-kons.
INSERT '1002' INTO TABLE ls_proto-kons.
ls_proto-jahr = '2008'.
INSERT ls_proto INTO TABLE lt_proto
If you're going to use a more complicated inner table with several components, then you need to define a type for those components.
matt -
Table in nested Iterators-Tree Level Rules for ViewInstances using same VL
Hi All ,
Jdev 11.1.1.6 , ADF BC , WLS 10.3.5.
I have a use case wherein I need to show a table nested at 3rd level within 2 af:iterators like -
<af:iterator id="i1" value="#{bindings.Location.collectionModel}"
var="locRow" varStatus="varStatus">
<af:iterator id="i2" var="deptRow" value="#{locRow.children}"
varStatus="varStat">
<af:table value="#{deptRow.Employees}" //using child View Link accessor Attribute directly can use deptrow.children too
var="row">
<af:column>
<af:inputText value="#{row.EmployeeName}">
</af:column>
</af:table>
</af:iterator>
</af:iterator>I need to display a table of Employees for each manager ... like ManagerId=100 in one table and others in a separate one (I know weird requirement but thats how it is :( )
So basically in my AM Data Model I have shuttled two view instances of Employee and filtered them using ViewCriterias accordingly like ->
OrgAM
-Location
Department
---Employees //(WithManager100)
---EmployeesWithManageNot100
Now since there is just one ViewLink between Department & Employees .. I am able to add "*EmployeesWithManageNot100*" as a child ViewLink accessor attribute , only Employees is available.
Is there any way we can show separate child ViewInstances in a treeModel with only one ViewLink ?Thanks for your reply Frank.
important: 11.1.1.6 , ADF BC , WLS 10.3.5. is not correct - it should be WLS 10.3.6AFAIK , 11.1.1.6 is compatible with both WLS 10.3.5 and 10.3.6 WLS and comes out of the box with WLS 10.3..5 which I am using for the Integrated Server.
So while there is a way to have two child node collections, its not from view object instances you define and configure using view criteriaThe link you posted above is simialr to another link I bumped into yesterday -
"How to filter tree node child data" , Pg 12 @ http://www.oracle.com/technetwork/developer-tools/adf/learnmore/feb2011-otn-harvest-328207.pdf written by you.
But my requirement is showing instances of the same EmployeeVO as two tables inside the Department Iterator. But I am not able to do that since there is only one ViewLink accessor for the EmployeeView.
Is that even possible without using 2 explicit physical View Links ? -
Adding nested table to object table
if I alter an object type and add a nested table to it, there seem to be no syntax to add "STORE AS" clause for that nested table in the object table containing the altered object type. E.G.:
ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
where Own_Name_ntt is a nested table type, then
ALTER TABLE FD_DOT NESTED TABLE Own_Name STORE AS Own_Name_ntab;
does not work but the table FD_DOT can not be used since it lacks the storage for the newly added nested table.Check your syntax.
CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
CREATE TYPE fd_dao AS OBJECT
(col1 date
,col2 number);
CREATE TABLE fd_dot(cola varchar2(10)
,colb date);
ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
NESTED TABLE Own_Name STORE AS Own_Name_ntab;
SQL> CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
2 /
Type created.
SQL>
SQL> CREATE TYPE fd_dao AS OBJECT
2 (col1 date
3 ,col2 number);
4 /
Type created.
SQL>
SQL> CREATE TABLE fd_dot(cola varchar2(10)
2 ,colb date);
Table created.
SQL>
SQL> ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
Type altered.
SQL>
SQL> ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
2 NESTED TABLE Own_Name STORE AS Own_Name_ntab;
Table altered.
SQL> desc fd_dot
Name Null? Type
COLA VARCHAR2(10)
COLB DATE
OWN_NAME OWN_NAME_NTT
SQL> desc fd_dao
Name Null? Type
COL1 DATE
COL2 NUMBER
OWN_NAME OWN_NAME_NTT
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options
SQL> CREATE TYPE Own_Name_ntt AS TABLE OF VARCHAR2(25);
2 /
Type created.
SQL>
SQL> CREATE TYPE fd_dao AS OBJECT
2 (col1 date
3 ,col2 number);
4 /
Type created.
SQL>
SQL> CREATE TABLE fd_dot(cola varchar2(10)
2 ,colb date);
Table created.
SQL>
SQL> ALTER TYPE fd_dao ADD ATTRIBUTE Own_Name Own_Name_ntt;
Type altered.
SQL>
SQL> ALTER TABLE FD_DOT ADD (Own_Name Own_Name_ntt)
2 NESTED TABLE Own_Name STORE AS Own_Name_ntab;
Table altered.
SQL> desc fd_dao
Name Null? Type
COL1 DATE
COL2 NUMBER
OWN_NAME OWN_NAME_NTT
SQL> desc fd_dot
Name Null? Type
COLA VARCHAR2(10)
COLB DATE
OWN_NAME OWN_NAME_NTT
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.3.0 - Production -
Grant on table with Nested Column.
Hi,
I looked for an answer to this issue, but I couldn't find it. So, here it is. I am trying to grant select on a table with nested column to a different user and still the select won't work. Here is an example.
FIRST_USER@TST > create type test_object as object(ref01 varchar2(3));
2 /
Type created.
FIRST_USER@TST > create type test_type is table of test_object;
2 /
Type created.
"afiedt.buf" 3 lines, 100 characters
1 create table table1 (x varchar2(1), y test_type)
2* nested table y store as type1_nt return as value
FIRST_USER@TST > /
Table created.
FIRST_USER@TST > grant select on table1 to SECOND_USER;
Grant succeeded.
SECOND_USER @TST > select * from FIRST_USER.table1;
select * from FIRST_USER.table1
ERROR at line 1:
ORA-01031: insufficient privileges
I am sure I am missing something. I may have to give the grant a different way maybe? Please help.
Thank you.See http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14260/adobjmng.htm#sthref786.
You need to grant execute to the appropriate user on the underlying type. -
Help in joining nested table with regular table
Im creating a nested table codelist as object prtcnpt_info. In a anonymous block im declaring t_code as nested table type codelist.
Now when i try to join the nested table with the regular oracle DB table and i get error: PL/SQL: ORA-00904: "COLUMN_VALUE": invalid identifier.
Please help me on this and provide tutorial link pertaining to this concepts..Below is the code i wrote
--Code Start;
create or replace type prtcnpt_info as object ( id number
,name varchar2(200)
,code varchar2(30));
create type codelist is table of prtcnpt_info;
declare
t_code codelist;
begin
select prtcnpt_info(b.pid ,b.name ,pt.code) bulk collect into t_code
from part pt
,mc_code b
where pt.cd in ('AAA','BBB')
and pt.ptype_id=b.pt_type_id;
INSERT INTO table ( ID
,RUN_ID
,DATA
,P_ID
SELECT id
,run_id
,data
,prtct.id ----> 1
FROM table_2 t2
,(select column_value from table(t_code)) prtct
WHERE prtct.id=t2.P_ID; ------> 2
end;
--Code End;
also from the anonymous block
1 => is this correct way to get value of id (b.pid) from the nested tablet_code aliased as prtct ?
2 => is this correct way to join the nested table with regular table? i want to join the column id's in both the tables.
Edited by: 914912 on Apr 30, 2012 2:11 AMWhen you create a table type without an object, i.e. a single column type like this you will get the column name as COLUMN_VALUE.
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Apr 30 07:38:32 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create or replace type mytbl as table of varchar2(10)
2 /
Type created.
SQL> var rc refcursor
"afiedt.buf" 11 lines, 162 characters
1 declare
2 ltbl mytbl;
3 begin
4 select to_char(level) bulk collect into ltbl
5 from dual
6 connect by level <= 10;
7 open :rc for
8 select * from table(ltbl);
9* end;
10 /
PL/SQL procedure successfully completed.
SQL> print rc
COLUMN_VAL
1
2
3
4
5
6
7
8
9
10
10 rows selected.And when you create a table type with object you will get the object column name.
SQL> drop type mytbl
2 /
Type dropped.
SQL> create type myobj as object (id varchar2(10))
2 /
Type created.
SQL> create type mytbl as table of myobj
2 /
Type created.
SQL> declare
2 ltbl mytbl;
3 begin
4 select myobj(to_char(level)) bulk collect into ltbl
5 from dual
6 connect by level <= 10;
7 open :rc for
8 select * from table(ltbl);
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> print rc
ID
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> -
Null value in detail table's primary key
I use Business Components Data Form to define a master-detail java panel.
I don't display the primary key column in the detail grid control.
Then I click on "+" to add a row, enter a value (the 2nd part of the detail table's primary key) and click commit.
I get an error saying that the primary key column that's not displayed is null and the row cann't be committed.
How do I fix this error?My fields are varchar2's.
-- simplified to protect the guilty:
-- (made up from memory, so sql keywords may --be misspelled, but you get the idea)
create table proj (
proj varchar2(10) not null,
constraint proj_pk
primary key(proj)
insert into proj values ('abc');
commit;
-- this table has legal values for -- the master.legal field.
-- in master, legal was changed to a -- ComboBoxControl control from -- TextFieldControl that the wizard -- generated.
create table legal_values (
proj varchar2(10) not null,
legal varchar2(10) not null,
display_order integer not null,
constraint legal_values_pk
primary key (proj, legal)
insert into legal_values
values ('abc', 'one', 1);
insert into legal_values
values ('abc', 'two', 2);
insert into legal_values
values ('abc', 'three', 3);
commit;
create table master (
proj varchar2(10) not null,
masterKey varchar2(15) not null,
legal varchar2(10) not null,
constraint master_pk
primary key (proj, masterKey)
create table detail (
proj varchar(10) not null,
masterKey varchar(15) not null,
detailkey varchar(10) not null,
display_order integer not null,
status varchar2(12) not null, -- user can only update this field
constraint detail_pk
primary key(proj, masterkey, detailkey)
-- legal rows for detail table
create table detail_values (
proj varchar2(10) not null,
detailkey varchar2(10) not null,
display_order integer not null,
constraint detail_values_pk
primary key(proj, detailkey)
insert into detail_values values
('abc', 'status a', 1);
insert into detail_values values
('abc', 'status b', 2);
commit;
-- if their is a foriegn key on details back
-- to master, then you get the
-- "mutating table" error when trigger
-- occurs.
create or replace trigger master_tr
after insert on master
for each row
begin
insert into detail
(masterKey, detailKey, status, display_order, status)
select :new.masterkey, detail_key, display_order, ' '
from detail_values;
end;
-- detail.status is a comboboxControl getting --its values of of another db table too.
-- there's also "after update" triggers on master and detail tables that copy the record to master_history and "detail_history" tables if the corresponding table is modified. Thus we have a history of the changes made to the records. The 2 history tables have 2 additional fields than their parents, "modified_date date default sysdate not null" and "modified_by varchar2(30) default user not null" that record when and who made the change. There's also a change type field that records where the change is an insert, delete or update (there 3 triggers per table , so we can correctly record change type as being insert, delete or update into the change_type field).
If you want to make it more real to life, the status value is initially blank, then can be changed to a legal status value (complete or not complete), but can not be changed back to blank.
***P.S. I have to have this ready for production by monday.****
P.P.S After you reply and change to ComboBoxControls in 2 places, try changing the table names and/or the column names (say to follow the DBA's naming convention) or add another field to the composite primary key (and unstated foriegn key) (using drop table/create table). Now try getting the existing code to run. No writing down the old/new table (or column) name pair names. Just run the code and try to fix the code based on the error messages. Are the error messages giving you adequate information to find the problem?
Maybe you are looking for
-
Whenever I made calls or someone called me and I picked up, the line cuts off and then give me this message "problem with recording device." How do I solve that problem so that I can talk with my friends.
-
I have reset my icloud but still cant sign in , so what should i do?
i have reset my icloud but still cant sign in , so what should i do? my iOS is 8.1.2 tq
-
I have created a labview project that contains about 40 vi. Each vi has a control panel in common that is a group of ip address, or port address, and settings that are passed from high level vi to low level vi for the purposes of controlling and acc
-
Dynamic Dashboard with Filters (Cascading )
I have a static dashboard with 3 filters (Cascading) -. Country , State and City . "All" functionality( for all filters) works fine in static mode. I am using Filter summary add on component for Cascading technique. 1) Right now , I am planning to m
-
I am unable to do video chat using Gtalk either with ichat or Browser. i tryed to use Firefox with Viedo chat plugin but this also doesn't help. My Voice and Picture is going but i am unable to receive. I am using Mac OS X10.7 Lion.