PL/SQL :: Referencing Element In Nested Collection

Jun 27, 2013

I have a table called dept table with nested collection as below. Nested Table Collection:

create or replace
type courselist as table of varchar2(64) Table Using Nested Table Collection: 
CREATE TABLE "FCSDWH_STG"."DEPT"
   ( "NAME" VARCHAR2(20 BYTE),
  "DIRECTOR" VARCHAR2(20 BYTE),
  "OFFICE" VARCHAR2(20 BYTE),
  "COURSES" "FCSDWH_STG"."COURSELIST"
   )  Content Of Table:NameDirectorofficecoursesAccountingJames CharlesUNOFCSDWH_STG.COURSELIST('natural science','chemistry','Computer Science','Computer Science') 

I am trying to select and print an element from nested table collection using below plsql block.

MY_COURSE VARCHAR2(64 CHAR);
BEGIN
SELECT courses INTO MY_COURSE FROM TABLE(SELECT COURSES FROM DEPT) where courses='chemistry';
DBMS_OUTPUT.PUT_LINE(MY_COURSE);
END; Error Message:
PL/SQL: ORA-00904: "COURSES": invalid identifier

View 3 Replies


ADVERTISEMENT

SQL & PL/SQL :: Sorting Collection In Nested Table

Sep 11, 2012

I'm trying to sort a collection in a nested table in PL/SQL so these value can be used later for a display and for export to Excel. The sort is failing.

-- PLS-00642: local collection not allowed in SQL statements

-- PL/SQl: ORA-00902: invalid datatype

The error message are also noted below in the code on the line that fails.

A quick overview of this code- Using a nested table MyNestedTable the values from several select queries are combined into MyRecordsetZero using CURSOR, and MULTISET UNION. I'm trying to either sort MyRecordsetZero or populate MyRecordsetSorted with the sorted values for futher use.

IMPORTANT: The code is running in an enviroment that does not have permission to create.

Versions:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Developer: 8.0.0.1480

DECLARE
-- Declare the variable MyTID to be used by select statements and
-- set its data type and max character count
MyTID varchar2(10);
[code]....

View 13 Replies View Related

SQL & PL/SQL :: Sorting Nested Table / Collection

Nov 10, 2011

In test.pks file I declared the following type

TYPE tab_tests is table of NUMBER(15);

In test.pkb, I have the following procedure

PROCEDURE report (
i_cid IN NUMBER
)
IS
test1 tab_tests := tab_tests();
test2 tab_tests;
BEGIN

-- I populate test1 with the data and it works fine. But when I tried to make a sorted nested table with the following command.

I got this error 'ORA-00902: invalid datatype',

a nested table than the following, like a built in Oracle collection method?

execute immediate 'select cast( multiset (select * from table(test1) order by 1) as tab_tests) INTO test2 FROM dual';
END;

View 16 Replies View Related

SQL & PL/SQL :: How To Select From Nested Collection In A Ref Cursor

Aug 19, 2010

I've create two types:

create or replace type VAL_REC as object
(WAARDE number(20,5) ) ;

create or replace type VAL_TAB is VARRAY(200) of VALREC ;

create or replace type WSN_REC as object
( START_DATE date
, END_DATE date
, DATA VAL_TAB) ;

create or replace type WSN_TAB as table of WSN_REC ;

In a PL/SQL table collecton WSN_TAB is filled. Now I want to create a query (ref cursor) that gives the result:

START_DATE END_DATE WAARDE(1) WAARDE(2) WAARDE(3) etc.
2010-08-15 2010-08-16 20 20 40
2010-08-16 2010-08-17 23 45 40

View 16 Replies View Related

Triggers / Referencing Non-updated Fields?

Jan 11, 2011

I'm having a bit of a problem getting the syntax of a trigger right. Unfortunately, I have no DBAs locally, I use some third party software, and for reasons beyond my understanding, I have been told to use triggers, and not stored procedures, so I'm running with it.

The set up:

STRUCTURES table: contains several columns, one of which is the unique ID column.
ASSAY table: contains several rows, also with the same ID column, but can have more than one row per ID (several assays per compound). One column is XC_ASSAYS.

The idea of the trigger is basically: When a row in the ASSAYS table is updated, pull out the ID of the row, then calculate the average of the XC_ASSAYS columns for those rows, and report it to the STRUCTURES.XC_ASSAY column for that row ID.

My best attempt thus far results in compilation errors.

CREATE TRIGGER INHIB_W_ALA_TR
AFTER INSERT OR UPDATE ON ASSAYS
FOR EACH ROW
BEGIN
UPDATE STRUCTURES SET XC_ASSAY = (SELECT AVG(XC_ASSAY) FROM ASSAYS WHERE ASSAYS.ID = :NEW.ID) WHERE STRUCTURES.ID = :NEW.ID
END;
/

The resulting errors are:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1 PL/SQL: SQL Statement ignored
2/190 PL/SQL: ORA-00933: SQL command not properly ended
12/0 PLS-00103: Encountered the symbol "end-of-file" when expecting

[code]...

I don't understand some of the errors, such as why line 2 SQL is ignored (it seems correct?), or I'm supposed to properly terminate the trigger (I've read ; and /, but I'm getting the end-of-file errors when I do so). Tried shuffling syntax and ' or " around - and I can't get it.The body SQL works when I replace :NEW.ID with an actual variable (such as 'NMP12'), but I'm not sure how to pass the ID variable from the updated row into the body. The ID is not updated, but other columns are.

View 3 Replies View Related

PL/SQL :: Referencing Remote Object Type

Aug 5, 2013

How can I reference an Object Type created on a remote database?This is the escenario:   

In DATABASE A:   CREATE OR REPLACETYPE  USERA.EXPO_EXPEDIENTES_RECAUDOS OID 'DCADCB2EA2344DFAB1D205C03D708359' AS OBJECT (   exer_cd_expediente  VARCHAR2 (50),   exer_id_ident_expediente   VARCHAR2 (30),   exer_cd_sucursal   NUMBER (3),   exer_cd_ramo NUMBER (2),   exer_nu_poliza   NUMBER (7),   exer_nu_certificado  NUMBER (9),   exer_nu_contrato  NUMBER (7),   exer_cd_nacionalidad  VARCHAR2 (1),   exer_nu_cedula_rif   NUMBER (9),   exer_nm_titular   VARCHAR2 (70),   exer_st_expediente  VARCHAR2 (2),   exer_de_status_exp   VARCHAR2 (240),   exer_fe_status_exp   DATE,   exer_cd_productor   NUMBER (5),   exer_nm_productor  VARCHAR2 (60),   exer_cd_mail_productor  VARCHAR2 (50),   exer_in_habilitado   VARCHAR2 (1),   exer_in_permite_habilitar  VARCHAR2 (1),   exer_in_carga_consulta  VARCHAR2 (1),   exer_cd_ramo_aplicacion    VARCHAR2 (200),   exer_cd_producto  VARCHAR2 (6)  )/ In DATABASE B:   

After creating the public synonym and asigning the required privileges on the object in DATABASE A, I try to execute the following:  

DECLARE x  EXPO_ EXPEDIENTES_RECAUDOS;BEGIN null;END;   

But i got the following error:

ORA-06550: line 2, column 12:PLS-00331: illegal reference to

USERA. EXPC_ EXPEDIENTES_RECAUDOS@DATABASEA   

After investigating a little i found the following, but i dont know how to apply it, "The CREATE TYPE statement has an optional keyword OID, which associates a user-specified object identifier (OID) with the type definition. It should be used by anyone who creates an object type that will be used in more than one database."

View 4 Replies View Related

SQL & PL/SQL :: Referencing To Multiple Tables Simultaneously

Jun 26, 2010

I have a question about referencing simultaneously multiple tables and I have the following tables

CREATE TABLE TEAM(team_id VARCHAR2(20), ...);
CREATE TABLE AGENT(agent_id VARCHAR2(20), ...);

(I put ... because there are a lot of columns which are not interesting for this question.)

Remark: team_id and agent_id are neither primary keys nor UNIQUE.

In a third table I have a column with exactly the same data type, that is, VARCHAR2(20). What I need is to make sure that its value is at least in one of the tables TEAM or AGENT (so the only thing that is important is to check that the specified value exists no matter in which of the two tables, but just to make sure that it exists somewhere).

The solution that I have found so far, is to create a BEFORE INSERT trigger on the table. Within the trigger I create a cursor

CURSOR c IS
SELECT team_id FROM TEAM
UNION
SELECT agent_id FROM AGENT;

And then within a loop I check the value.

View 1 Replies View Related

SQL & PL/SQL :: Add Composite Primary Key To Table That Has Self Referencing Foreign Key

Jan 21, 2012

I have an employee table which has a primary key and a self referencing foreign key, as shown here

create table employee (
id not null,
name not null,
department not null,
supervisor_id not null
,constraint constraint_1 primary key (id)
,constraint constraint_2 foreign key (supervisor_id) references employee (id));

Now if i make the primary key composite, as shown below -

create table employee (
id not null,
name not null,
department not null,
supervisor_id not null
,constraint constraint_1 primary key (id, name)
,constraint constraint_2 foreign key (supervisor_id) references employee (id));

Oracle is throwing the following error -

ORA-02270: no matching unique or primary key for this column-list

How can this error be fixed without changing the composite primary key?

View 10 Replies View Related

SQL & PL/SQL :: Cross Referencing Query From A Single Table

Mar 21, 2012

I have a employee table with the below format

EMP

EMPID DEPID
1A
2A
2B
1B
4A
5B
5A
6C
7A
8D

Now I need to start with the employee 1 . As we can see the emp 1 is mapped to dept A and also with multiple dept. Similarly dept id is mapped to multiple emp.

I need the output as below (many to many I.e. cross referencing)

EMPID DEPIDGroup
1A A1
2A A1
2B A1
1B A1
4A A1
5B A1
5A A1
6C B1 -- new group as the emp and dept are not mapped previously
7A A1
8D C1

View 1 Replies View Related

PL/SQL :: Related Collection Within A Collection

Sep 20, 2012

There is a nested table with in a nested table type and i want to print the value and again assign a new value to the next subscript and i have tried a lot but couldn't find any solution.

declare
type type_name is table of varchar2(10);
type type_name1 is table of type_name;
names type_name1:=type_name1(type_name('hello'));
begin
-----HOW TO PRINT A VALUE--------
-----HOW TO ASSIGN A NEW VALUE TO NEW SUBSCRIPT
null;
end;

1) need to print the values of names(1)
2)Assign a value to names(2)

View 3 Replies View Related

PL/SQL :: How To Create One-column Collection From Another Multi-column Collection

Mar 22, 2013

I am describing a SQL statement to get it's column list:DECLARE

cur     NUMBER;
col_cnt INTEGER;
rec_tab DBMS_SQL.DESC_TAB;

[Code]....

Now I need to get out the columns list from rec_tab.col_name and put it to my_colls collection. Have Oracle any build-in to do that?

View 4 Replies View Related

CLOB In Xml Element

Oct 18, 2011

I have to generate a big xml. Each part of the xml needs data from different tables. So I have created two clob to hold the portion of the big xml. How can i have the concatenated clob values as an argument for xml element.

View 1 Replies View Related

SQL & PL/SQL :: How To Add XML Element In Oracle 10gr1 Without Using XDB

Jun 24, 2013

how to add an xml element in oracle 10gr1 without using Oracle XDB?

View 1 Replies View Related

Reports & Discoverer :: Use Of Xml Element In 6i?

Nov 6, 2012

i want to display values of same column with comma seperation like this

SELECT RTRIM(XMLAGG(XMLELEMENT(e,DESCR_INDI || ',')).EXTRACT('//text()'),',') INTO DESCR FROM
STUDENT_SKILL_PER WHERE GROUP_NAME=:GROUP_NAME
AND SKILL_NAME=:SKILL_NAME AND SUB_SKILL_NAME=:SUB_SKILL_NAME
AND TERM=:TERM AND STUDENT_CODE=:STUDENT_CODE AND YEAR_CD=:YEAR_CD;

but the error shown to me that xmlelement must be declared...but when i deploy same query at sql editor it gives me correct result..how i can use it on oracle report 6i... i am using oracle 9i as database.

View 1 Replies View Related

SQL & PL/SQL :: 70% / 30% From High And Low Priority Element

Oct 27, 2011

I have a priority column(possible values are 1 or 0) in a table where

i need to get 70% of high(1) and 30% of low (0) and max i can fetch for select is 50 records.

Eg1: Total if i have 60 in which 20 high and 40 low then 70% of 20 = 14 and remaining should be taken from Low i.e. 36 from low. so total will be 50 transactions.

Eg2: Total if i have 60 in which 40 high and 20 low then 70% of 40 28 + remaining should be taken from Low i.e. 22 from Low.

Eg 3: If i don't have any high then total should be picked from low vise versa.

I have below query but it is having problem when there is no low priority.

SELECT ID,PRI FROM temp tbl WHERE pri = '1' AND ROWNUM < ((70/100)*50)+1
UNION ALL SELECT * FROM temp WHERE pri = '0'
AND ROWNUM < 50-(SELECT COUNT(*) FROM temp WHERE pri = '1' AND ROWNUM < ((70/100)*50)+1)

View 3 Replies View Related

Forms :: Empty Element In Item_list

Jan 13, 2013

I used a dynamic item_list. This list should contain only the result of the query but I found an empty element in the list. So, how to eliminate this element empty list?

see the picture:

[URL]........

View 4 Replies View Related

SQL & PL/SQL :: ORA-22160 / Element At Index (1) Does Not Exist

Mar 27, 2007

i am trying to update using bulk processing.am facing this ORA-22160: element at index [1] does not exist.

ORA-22160: element at index [string] does not exist

Cause: Collection element at the given index does not exist.

Action: Specify the index of an element which exists.

how to avoid this.

1 create or replace procedure dept_new
2 is
3 type dept_type is table of dept.deptno%type;
4 type tab_type is table of dept%rowtype;
5 --variable declaration
6 dept_t dept_type;
7 tab_t tab_type;

[code]....

my dept and dept1 tables are both of same structure.

View 7 Replies View Related

XML DB :: Un-nest XML With Single Child Element

May 20, 2013

I'm trying to write a generic function for un-nesting child nodes where nesting is deemed unnecessary. Typically when the element only has one child element.

For example, given the following source....
<ROOT>
  <ITEM>
    <DESCRIPTION>TEST1</DESCRIPTION>
  </ITEM>
  <ITEM>
    <DESCRIPTION>TEST2</DESCRIPTION>
  </ITEM>
</ROOT>I actually want.....
<ROOT>
  <DESCRIPTION>TEST1</DESCRIPTION>
  <DESCRIPTION>TEST2</DESCRIPTION>
</ROOT>

because we think ITEM isn't really required before we deliver XML data.I've been trying to achieve this with a function, where I pass in the XPath to the node I want flattening, something like

function UnNest(pXMLData XMLType, pXPath varchar2) return XMLType...Called like the following...
declare
begin
  vXMLData := UnNest(SomeXMLData, '/ROOT/ITEM')
end;I tried using XQuery Update (11gR2), as follows,
[code]....

My destination platform is 11gR2 64 bit but going forward I may need a solution for 10gR2 too. Perhaps there is another way without using XQuery Update?

View 2 Replies View Related

JDeveloper, Java & XML :: Procedure For Reading Xml Element Value

May 25, 2011

In my pl/sql procedure I'm calling a webservice and it is returning me a varchar2 which contains xml tags.I want to pull values for each element. any one can provide me procedure/function to pull data from it.Below is the output from webservice.

<ResponseEnvelope xmlns:xsd="URL....xmlns="URL....> <ResponseHeader xmlns="URL......
[code]....

ResponseId, MessageVersion etc are element name. the value between element names are to be retrived.

View 13 Replies View Related

SQL & PL/SQL :: Check If Element Present In Defined Column Of Cursor?

Apr 29, 2010

i want to produce a function who return XmlType element if she checks that a parameter (that i passed to here is contained in a row in a defined table)

for example

create table sec_form(
form_code VARCHAR2(8)
, sec_code VARCHAR2(5)
) ;
insert into sec_form values ('CSA','section1');
insert into sec_form values ('CSA','section2');
insert into sec_form values ('CSA','section3');

then i got my function

create or replace function checkIfSectionEnabled (elem XmlType,name_section varchar2)
return XmlType
is v XmlType;
CURSOR myCursor IS select * from sec_form where form_code = 'CSA';
begin
open myCursor;
loop

[code]....

now i'm gonna call the function (elem XmlType,name_section varchar2) and pass here "section1" for example ; and she must return me my xmltype element if she find "section1" finds section1 present;

when i try t compile i got:

Error(18,13): PL/SQL: Statement ignored
Error(18,26): PLS-00225: subprogram or cursor 'MYCURSOR' reference is out of scope

View 3 Replies View Related

JDeveloper, Java & XML :: Updating Element Text In Document?

Nov 15, 2012

I have table called shipper with document_xml as CLOB column

The sample content of document_xml is below

<placemark id = "5467">
<name> 415-CI-78492</name>
<description><![CDATA[<//!!!!//15249599]]></description>
<ICON><href>http://localhost:63077/Icons/Markers/pushpin.png</href></Icon>

and there are other attributes continued

Objective: I want to replace "href" element in each of the record with "[URL] ......" value.

After I update the row the data should look as follows

<placemark id = "5467">
<name> 415-CI-78492</name>
<description><![CDATA[<//!!!!//15249599]]></description>
<ICON><href>http://localhost:63077/Icons/Markers/ship.png</href></Icon>.

I have to do this for bunch of records in a table(table_name = shipper).

Is there an oracle function to replace/update the href element in a CLOB column?

View 4 Replies View Related

XML DB :: Insert Element Into Data Stored In CLOB Column?

Dec 14, 2012

My ORACLE DB version is:

('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
('PL/SQL Release 11.2.0.2.0 - Production');
('CORE 11.2.0.2.0 Production');
('TNS for Linux: Version 11.2.0.2.0 - Production');
('NLSRTL Version 11.2.0.2.0 - Production');

I have this XML data stored in a CLOB column:

<Activity>
<Changes>     
</Changes>
<Inserts>     
</Inserts>
<Definition>     

[code]....

I need creating an update that will insert another <Activity>SomeGUID</Activity> into the <Spawned> parent.

View 3 Replies View Related

Application Express :: Button With Pre-element Text Is Given A Container Div?

Aug 8, 2013

Just installed 4.2.2.00.09 and imported a workspace and an application. Worked fine.I noted a page display difference when compared to the exported application (4.1.0.00.32). I have (so far) found this:If I have a button with Pre Element Text set to <div class="dummy"> and Post Element Text set to </div>, Apex generates an extra div around it all.If my button was named P1_SUBMIT I end up with 

<div id="P1_SUBMIT_CONTAINER">
<div class="dummy"> <input type="button" value="Search" id="P1_SUBMIT" /></div>
</div> 

Is it possible for me to turn this extra div off?

View 0 Replies View Related

JDeveloper, Java & XML :: Convert XML Message To CSV And Assign It To (anyType) Element

Mar 28, 2012

I have a requirement that is to convert XML message to CSV format and assign this to a "anyType" element. How would I convert to CSV?

View 1 Replies View Related

XML DB :: Add Attribute Modification_date For Root Element Process For Field Xml_data?

Mar 6, 2013

I'm studying the guide Oracle XML DB Best practices and it is ok to add, modify or delete nodes. Also to change the value of an attribute, but I'm looking for adding an attribute.What is exactly the statement, for example to add the attribute modification_date for the root element process for a field xml_data ?

View 1 Replies View Related

Application Express :: How To Get Unique Element IDs In Manual Tabular Form

Oct 24, 2012

I'm trying to get a unique sequential element id for every field in a manual tabular form. Here is the code to generate the form:

SELECT apex_item.hidden(1, lpad(rownum,4,0)) row_num,
apex_item.hidden(2, skillset_demand_id) sdi,    
apex_item.text(3, domain, 20, 20, null, 'f03_#row_num#') Domain,
apex_item.text(4, target, 20, 20) Specialization,
apex_item.text(5, skill, 20, 20) Skill
FROM RI_SKILLSET_DEMAND
WHERE WORK_ID = :P511_WORK_IDAccording to the APEX API manual I should be able to set the attribute id with p_item_id*, which in the example of a text item, is the sixth parameter. In line 3 of the code above, I set the p_item_id to 'f03_#row_num#' after having created row_num in line 1.

The HTML I get is:
<input id="f03_#row_num#" type="text" value="xxxxxxxxx" maxlength="20" size="20" name="f03">
...
<input id="f03_#row_num#" type="text" value="xxxxxxxxx" maxlength="20" size="20" name="f03">What I want is:
<input id="f03_0001" type="text" value="xxxxxxxxx" maxlength="20" size="20" name="f03">
...
<input id="f03_0002" type="text" value="xxxxxxxxx" maxlength="20" size="20" name="f03">
...
etc.

I've tried a lot of things but I can't seem to get parameter substitution inserted into the id attribute so I can get each element uniquely with javascript later.

View 1 Replies View Related

JDeveloper, Java & XML :: ORA-30951 / Element Or Attribute At Xpath Exceeds Maximum Length

Apr 29, 2013

I am getting the error when trying to run this test block, this is code is to simulate the production error we are getting...

DECLARE
g_xdoc XMLTYPE;
g_trans_type CHAR (20) := NULL;
BEGIN
SELECT xmltype(c) -- column is a clob column
INTO g_xdoc
FROM test_gil

[code]....

View 12 Replies View Related

JDeveloper, Java & XML :: Update Xml Element In Oracle 10gr1 Without Using Oracle XDB

Jun 27, 2013

I would like to update an XML element without using the function APPENDCHILDXML or INSERTCHILDXML because they are not available in Oracle 10GR1.
In my database, Oracle XDB is not installed.

The following query fail with the following error : ORA-00904: "INSERTCHILDXML" : identificateur non valide

update scl_profile
set profile_data =
insertChildXML(profile_data,'/exportImportMarcheCriteria','colonnesExport',
XMLType('<colonnesExport>ENTETE_GESTIONNAIRES_AUTORISES</colonnesExport>'))
where profile_xmltype =
'fr.mipih.marches.marche.criteres.ExportImportMarcheCriteria'
and profile_type =
'eMagh2.MRGS.AccesMarche.ListeMarche.Export.OptionsExportImport';
[code]........

If i try to use the package DBMS_XMLDOM, i have the following error :

ORA-06550: Ligne 3, colonne 11 :
PLS-00201: l'identificateur 'DBMS_XMLDOM.DOMDOCUMENT' doit etre declare
ORA-06550: Ligne 3, colonne 11 :
PL/SQL: Item ignored

I think it's because ORACLE XDB component is not installed in my database.

View 1 Replies View Related

SQL & PL/SQL :: Collection Over Cursor?

Jun 30, 2010

What is the advantage of collections over CURSOR? What is the use for collections and when collections is used?

View 1 Replies View Related

SQL & PL/SQL :: Collection Of Records

Sep 29, 2010

I have been doing some code in collection for testing. I have been doing the below but getting the error.

SQL> desc t_mine;
Name Null? Type
----------------------------------------------------- --------
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)

SQL> ed
Wrote file afiedt.buf

1 declare
2 v_start_time PLS_INTEGER := DBMS_UTILITY.GET_TIME;
3 v_elapsed PLS_INTEGER;
4 type allobjects_record is record
5 (owner varchar2(1000)
[code].......

ERROR at line 15:

ORA-06550: line 15, column 15:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 15, column 3:
PL/SQL: SQL Statement ignored

I followed the below link

[URL].......

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved