Oracle 10g - Insert value into a self-created table in stored proc
Hi all,
Say I'm creating a table using the following logic,
pc_create_table := 'create global temporary table revs(var1 number(5,0), ..., ...,) on commit preserve rows';
execute immediate pc_create_table;
When I'm attempting to insert value into this table (v_var1 is a pre-defined variable),
pc_insert_value := 'insert into revs(var1, ..., ...,) values (v_var1, ...)'
execute immediate pc_insert_value;
I got the following error: "ORA-00984: column not allowed here"
Any advise on this issue? Thanks a lot
isaacniu wrote:
However I got two errors in that line,
Error(68,6): PL/SQL: SQL Statement ignored
Error(68,18): PL/SQL: ORA-00942: table or view does not existAnd why do you want your PL/SQL code to run DDLs??
Its not designed that way, is not a good practice and is strictly not recommended. You can read <a href ="https://forums.oracle.com/forums/profile.jspa?userID=287238">Billy Verreynne's</a> take on this :
{message:id=10040770}
To my suprise it's saying the table or view does not exist. According to my logic, the table "revs" created by executing pc_create_table, however it's NOT explicitly declared in other parts of this script, is this where the problem is?The Problem is, SQLs fired using Execute Immediate are evaluated, compiled, parsed and executed at run time. So when you compile procedure pc_create_table, table revs is still not created. Hence you get error when you try inserting rows in it.
Any advises are appreciated.Get the table created by your DBA, and use insert statement without execute immediate in your procedure.
Similar Messages
-
Inserting values into multiple tables in one jsf page with single commit op
hi all,
i have two tables ,
one is parent table and other is child record.
record details:
table1:(parent table)
emplid (primary key)
empl_name
table 2:(child table)
empl id ( Foreign key)
empl_name ( Foreign key)
contact_no (primary key)
my senario is , i need insert values into both parent and child table in one save option.
and both the tables will be in one jsf page.
is this possible to do?
thanks all,
regards,
M vijayalakshmihi,
i feel my question is not clear.
let me explain my question clearly.
1. i have two records
*1. emp_names*
attributes of this table is 1.emplid
2.emp_name.
emplid is a primary key.
2. emp_contact
attributes of this table is 1.emplid
2. contact_no
In this table emplid is forigen key from emp_name table
contact_no is primary key.
and my senerio is,
for one emplid there are many contact no.
in database diagram i have created these two entities. and from that i have generated two views objects.
now in jsf page ,
i shd have all fields from both the records.
wn ever i click on add button , i shd be able to insert one complete row of data to both the tables.
means,
emplid
empl_name
contact_no.
and if i click on commit button data shd be insert in both the tables.
so how to achive this?
am very beginner to the jdeveloper tool.
regards,
m vijayalakshmi. -
How to insert values into an array of class
Hello everyone,
I need help in inserting values into an array of class, which i have read from a file.
Length of the array is 5. I should insert values one by one into that array.
If the array is full (if count = 5), then I should split the array into 2 arrays
and adjust the values to left and right with median.
I'm getting an ArrayBoundException .. can anybody help me out ?
Thanks in advance
Here is my code..........
import java.util.*;
import java.io.*;
public class Tree
static String second;
static String first;
static int count = 5;
public void insert(int f1,int s1, int c)
if(c!=0)
Record[] rec = new Record[4];
for (int i = 0; i < 5; i++)
rec[i] = new Record();
for(int i = 0; i<=4;i++)
rec.x = f1;
rec[i].y = s1;
else
System.out.println("yes");
public static void main(String[] args)
Tree t = new Tree();
try
FileReader fr = new FileReader("output.txt"); // open file
BufferedReader br = new BufferedReader(fr);
String s;
while((s = br.readLine()) != null)
StringTokenizer st = new StringTokenizer(s);
while(st.hasMoreTokens())
first = st.nextToken();
second = st.nextToken();
// System.out.println("First-->"+first+" "+"Second-->"+second);
int fir = Integer.parseInt(first);
int sec = Integer.parseInt(second);
t.insert(fir, sec, count);
fr.close(); // close file
catch (IOException e)
System.out.println("Can't read file");
class Record
public int x,y;Hi qwedwe.
Record[] rec = new Record[4];
for (int i = 0; i < 5; i++)
rec[i] = new Record();
}Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
Record[] rec = new Record[c];
for (int i = 0; i < c; i++)
rec[i] = new Record();
}Regards,
Norman -
Oracle 10g BLOB data into Postgresql 8.2
Any Docs on Oracle 10g BLOB importing into Postgresql 8.2.
Thanks in Advance.
Harish Kumar RPostgresql is not an Oracle product. Perhaps you should address your question to the people that make it.
-
Oracle 10g HTMLDB,.. How to EDIT TABLEs
Hi,
I am new to DBs. I am doing a class project on Oracle 10g HTML DB. I have created the ER Diagram but am having problems implementing it in Oracle.
Here are the problems:
1) Editing tables
Currently I am using the wizard the make the tables:
Workspace AMANSOOR>SQL Workshop>Create Table
Now the table is created, the primary key is set, but then lets say that
a) I have to go back and edit the table, perhaps add a cloumn etc, how do i do that.
b) More over if I have to add a new CONSTRAINT, or TRIGGER, where do i do that,..
I would really appreciate any help,..
Thank you,..Never mind,.. i got the answer,..
-
Creating a java stored proc in jdev
Does anyone have a quick ref guide to creating a java stored proc in jdev? I am missing early steps to correctly setup the project.
Thanks in advance.Assuming you are using ADF BC, you can try something like the following on your Application Module:
/* our java method to call a stored procedure to send email */
public void sendEmail(String fromEmailAddress, String toEmailAddress,
String subject, String body1, String body2,
String body3, String body4, String body5) {
Object[] parms =
{ fromEmailAddress, toEmailAddress, subject, body1, body2, body3,
body4, body5 };
callStoredProcedure("MSKCC.proc_send_mail(?,?,?,?,?,?,?,?)", parms);
protected void callStoredProcedure(String stmt, Object[] bindVars) {
PreparedStatement st = null;
try {
// 1. Create a JDBC PreparedStatement for
st =
getDBTransaction().createPreparedStatement("begin " + stmt + ";end;", 0);
if (bindVars != null) {
// 2. Loop over values for the bind variables passed in, if any
for (int z = 0; z < bindVars.length; z++) {
// 3. Set the value of each bind variable in the statement
st.setObject(z + 1, bindVars[z]);
// 4. Execute the statement
st.executeUpdate();
} catch (SQLException e) {
throw new JboException(e);
} finally {
if (st != null) {
try {
// 5. Close the statement
st.close();
} catch (SQLException e) {
} -
Hi all,
In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'MacLochlainnsDB')
DROP DATABASE MacLochlainnsDB
GO
CREATE DATABASE MacLochlainnsDB
GO
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL)
INSERT INTO marvel
(avenger_name)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8)
I got the following error Message:
Msg 110, Level 15, State 1, Line 5
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
How can I correct this problem?
Please kindly help and advise.
Thanks in advance,
Scott Chang
P. S.
The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
DECLARE @x xml;
SET @x = N'<marvel>
<avenger_name>Captain America</avenger_name>
</marvel>';
SELECT @x.query('/*');
You can query the avenger_name elements from the marvel_xml table with the following syntax:
SELECT xml_table.query('/marvel/avenger_name')
FROM marvel_xml;
It returns the following set of avenger_name elements:
<avenger_name>Hulk</avenger_name>
<avenger_name>Iron Man</avenger_name>
<avenger_name>Black Widow</avenger_name>
<avenger_name>Thor</avenger_name>
<avenger_name>Captain America</avenger_name>
<avenger_name>Hawkeye</avenger_name>
<avenger_name>Winter Soldier</avenger_name>
<avenger_name>Iron Patriot</avenger_name>
You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
SELECT xml_table.query('/marvel[4]/avenger_name')
FROM marvel_xml;
It returns the following avenger_name element:
<avenger_name>Thor</avenger_name>Hi Scott,
The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
object within it.
To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
Open SQL Server Management Studio
--> Go to Object explorer(the left panel by default layout)
--> Extend "Security"
--> Extend "Logins"
--> Right click on your login, click "propertites"
--> Choose the "Default database" at the bottom of the pop-up window.
--or simply by T-SQL
Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
Regarding your question, you can reference the below.
SELECT * FROM master.sys.all_objects where name ='Marvel'
--OR
SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
--usually the OBJECT_ID is used if a if statement as below
IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
PRINT ('TABLE EXISTS') --Or some other logic
What is the sys.all_objects? See
here.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Need to insert values into a table from a XML file
Hi,
I'm an Oracle 9i/10g DBA with quite a few years experience, but I'm new to XML and dealing with it in database terms. I've been given a project that entails pulling XML values out of a file (or 100's of them) and storing them in the database so that they are searchable by end-users. The project is classified as secret so I'm unable to upload the specific XML or any info relating to the structire of the XML or the table I will use to insert the values into - sorry!! So, I've created an XML file with a similar structure to help people understand my predicament.
The end-users only need to search on a subset of the total amount of columns from the table I'll insert data into, although the XML file has a lot more, so I dont need to store the other values - but I will need to store the name of the XML file (or a pointer to it so I know what XML file a particular set of values belong to) in another column of the table along with its associated values.
I've been using the XMLTABLE function with some degree of success, although I had better succes using the XMLSEQUENCE function. However, I found out this is deprecated in 10g and replaced with XMLTABLE, so I guess it's better if I use this in case we ever need to upgrade to 11g.
The main problem I've been having is that some elements in the XML files have multiple values for the one record when all the other records are the same. In terms of storing this in the database, I guess it would mean inserting multiple rows in the table for each element where the value differs. Here is a dumbed down XML file similar to what I've got along with the other SQL I've used:
+<?xml version="1.0" encoding="UTF-8"?>+
+<House>+
+<Warehouse>+
+<WarehouseId>1</WarehouseId>+
+<WarehouseName>+
+<Town>Southlake</Town>+
+<State>Texas</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>25000</Area>+
+<Docks>2</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Street</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>2</WarehouseId>+
+<WarehouseName>+
+<Town>Poole</Town>+
+<State>Dorset</State>+
+</WarehouseName>+
+<WarehouseName>+
+<Town>Solihull</Town>+
+<County>West Midlands</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>40000</Area>+
+<Docks>5</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>3</WarehouseId>+
+<WarehouseName>+
+<Town>Fleet</Town>+
+<County>Hampshire</County>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>10000</Area>+
+<Docks>1</Docks>+
+<DockType>Side load</DockType>+
+<WaterAccess>false</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>20</VClearance>+
+</Warehouse>+
+</House>+
CREATE TABLE xmltest OF XMLTYPE;
INSERT INTO xmltest
VALUES(xmltype(bfilename('XML_DIR', 'test.xml'), nls_charset_id('AL32UTF8')));
Consequently, I need to...
1) Retrieve the results from the XML file for all 3 warehouses where multiple values for the same sub-element are shown as 2 rowsthe result set. (I am guessing there will be 4 rows returned as warehouse sub-2 has 2 different elements for <WarehouseName>.
2) Build a case statement into the query so that regardless of the sub-element name (i.e State or County), it is returned into the 1 column, for instance County.
So, if I run a query similar to the following...
select y.WarehouseId, y.Town, y.County, y.Area
from xmltest x, xmltable('/House/Warehouse' .......
I would like to get results back like this...
ID Town County Area
1 Southlake Texas 25000
2 Poole Dorset 40000
2 Solihull West Midlands 40000
3 Fleet hampshire 10000
Sorry for the non-formatting but I hope this all makessense to someone out there with what I'm trying to do.
I appreciate any help whatsoever because, as i said before, I'm totally new to XML and trying to read the vast amount of information there is out there on XML is all a bit daunting.
Many thanks in advance,
Shaun.Hi again,
Thanks for keeping the post open for me. I've had a look at the post illustrating the XFileHandler package, and tried to alter it to make it fit with my XML files. To help explain things, my XML file looks like this:
<?xml version="1.0"?>
<!DOCTYPE CMF_Doc SYSTEM "CMF_Doc.dtd">
<House>
<Warehouse>
<WarehouseId>1</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>House
<WarehouseId>2</WarehouseId>
<WarehouseName>
<Town>Poole</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>3</WarehouseId>
<WarehouseName>
<Town>Fleet</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>4</WarehouseId>
<WarehouseName>
<Town>Dallas</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>5</WarehouseId>
<WarehouseName>
<Town>Dorchester</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>6</WarehouseId>
<WarehouseName>
<Town>Farnborough</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>7</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>8</WarehouseId>
<WarehouseName>
<Town>Bournemouth</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Shirley</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>30000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>9</WarehouseId>
<WarehouseName>
<Town>Clapham</Town>
<County>London</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>And the XFilehandler package looks like this (I'm just trying to do a simple select only on WarehouseId & WaterAccess for the time being to keep things simple):
create or replace package XFileHandler as
TYPE TRECORD IS RECORD (
WID NUMBER(2)
, WACCESS VARCHAR2(5)
type TRecordTable is table of TRecord;
function getRows (p_directory in varchar2, p_filename in varchar2) return TRecordTable pipelined;
end;
create or replace package body XFileHandler is
function getRows (p_directory in varchar2, p_filename in varchar2)
return TRecordTable pipelined
is
nb_rec number := 1;
tmp_xml clob;
tmp_file clob;
rec TRecord;
begin
DBMS_LOB.CREATETEMPORARY(TMP_FILE, TRUE);
tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
LOOP
tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
exit when length(tmp_xml) = 0;
--dbms_output.put_line(tmp_rec);
nb_rec := nb_rec + 1;
select y.WID, y.WACCESS
into rec.WID, rec.WACCESS
from xmltable('/House' passing xmltype(tmp_xml)
columns WID NUMBER(2) PATH 'Warehouse/WarehouseId',
WACCESS VARCHAR2(5) PATH 'WaterAccess') y;
pipe row ( rec );
end loop;
dbms_lob.freetemporary(tmp_file);
return;
end;
end;Now, when I run the query:
select * from table(XFileHandler.getRows('XML_DIR', 'XFileHandler_test.xml'));I get the error: ORA-00600: internal error code, arguments: [17285], [0x5CFE8DC8], [4], [0x45ABE1C8], [], [], [], []
I had a look in the dump file for anything obvious, but nothing really stands out. Is there anything obvious in my code that I'm missing or something else which you may think could be causing this error, e.g in the regular expression regexp_substr?
Many thanks,
Shaun. -
XML Parser to insert values into a Table??
Hi All,
Bare with me I am new to xml technology, but apparently there's request to parse a xml file and store data in a oracle table.
Appreciate if someone can help me to resolve this please??
I am using Oracle 10g.
This is the xml file which I need to parse.
<?xml version = '1.0' encoding = 'UTF-8'?>
<PBOOKS>
<BOOK>
<KEY>0061319821</KEY>
<ISBN>0-061-31982-1</ISBN>
<![CDATA[<TTL>All Our Kin</TTL>]]>
<![CDATA[<SUBTTL>Strategies For Survival In A Black Community</SUBTTL>]]>
<![CDATA[<PAGES>192</PAGES>]]>
</BOOK>
</PBOOKS>
I have a Oracle Table ( table name: Perseu ) to hold the values of this file:
These are the fields:
Key, ISBN, TTL, SUBTTL, PagesDue to the somewhat strange structure of the XML (Elements embedded inside the CDATA sections, do you have any idea why this is being done ?) the best I can come up with is
SQL> drop table test
2 /
Table dropped.
SQL> create table test of XMLType
2 /
Table created.
SQL> insert into test values ( XMLTYPE(
2 '<PBOOKS>
3 <BOOK>
4 <KEY>0061319821</KEY>
5 <ISBN>0-061-31982-1</ISBN><![CDATA[<TTL>All Our Kin</TTL>]]><![CDATA[<SUBTTL>Strategies For Survival In A Black Community</S
UBTTL>]]><![CDATA[<PAGES>192</PAGES>]]></BOOK>
6 </PBOOKS>'))
7 /
1 row created.
SQL> select BOOK, ISBN,
2 extractValue(CDATA,'/CDATA/TTL') TTL,
3 extractValue(CDATA,'/CDATA/SUBTTL') SUBTL,
4 extractValue(CDATA,'/CDATA/PAGES') PAGES
5 from (
6 select extractValue(value(BOOK),'/BOOK/KEY') BOOK,
7 extractValue(value(BOOK),'/BOOK/ISBN') ISBN,
8 xmlType('<CDATA>' || extractValue(value(BOOK),'BOOK/text()') || '</CDATA>') CDATA
9 from test,
10 table(xmlsequence(extract(object_value,'/PBOOKS/BOOK'))) book
11 )
12 /
BOOK
ISBN
TTL
SUBTL
PAGES
0061319821
0-061-31982-1
All Our Kin
BOOK
ISBN
TTL
SUBTL
PAGES
Strategies For Survival In A Black Community
192
SQL>
SQL>
SQL> -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM -
Oracle 10g Insert query performs inconsistent as a query vs procedure and p
Database Version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
No error messages....
I am facing a very weird issue that I have a insert statement in a procedure... pretty much
inert
into oracle_Table
SELECT cr.a AS a,
cr.b AS b,
cr.c AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
@Pmo.World is a database link to a MSSQL...
The problem I am having right now is, every time I run this insert as a query. Everything works as what it should be... However, when I put this insert into a procedure, it inserts nothing...
Simple test Proceudre:
declare
-- Local variables here
i integer;
begin
inert
into oracle_Table
SELECT cr.a AS a,
cr.b AS b,
cr.c AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
end;
Thinking about character conversion issue I changed the procedure to
inert
into oracle_Table
SELECT to_char(cr.a) AS a,
to_char(cr.b) AS b,
to_char(cr.c) AS c,
max(d.column_name) as d
FROM "table 1"@Pmo.World Cr,
[email protected] d
WHERE d."a" = cr."column name"
GROUP BY cr.a,
cr.b,
cr.c
Then this Inser works in the procedure... however when I revert it back with the original version that doesnt have to_char... it is working still... then I kept it running for few days... since it runs once per day, it was working for the first 2 days and then stopped working the third day... I verified the source table and every time this procedure runs, source tables were not empty...
It is so confusing because if I manually run the insert as a query, it worked every time I ran it... however if I put that into a procedure, it works from time to time..
Any help is highly apprecaited
Edited by: 986006 on Feb 4, 2013 8:51 AM986006 wrote:
Thanks for the hints up... I have updated my post... As I post the test procedure...it is about the exact the same as the insert query... Every time, the insert would actually insert data into the table but every time I run the test procedure, nothing gets inserted in... It sounds unbelievable but it happens... ThanksYou obviously haven't read the FAQ, or at least you haven't bothered doing what it asks. Help us to help you.
Can you recreate the problem with simpler data on your local machine? If so provide create table and insert statements for test data.
Format your code and place between tags.
At the very least post the *exact* SQL or PL/SQL you are trying to run: what you've posted isn't even valid SQL. -
Hi,
I want to migrate data from one table in ABC schema to XYZ other schema.
for e.g
create table abc.book( col1 number, col2 sys.xmltype) is there in abc schema.
now in other schema i've created the following table
create table xyz.book (col1 number, col2 sys.xmltype);
the next step is to populate data in xyz.book.
I'm not able to do so since it has got one column as xml datatype.
How do i do the migration in xyz schema for book table?
There is grant select on book to xyz schema from abc schema.
Oracle (8i).
Regards,Hi,
17:26:56 topgun>CREATE TABLE tab1 (
17:26:57 2 col1 SYS.XMLTYPE
17:26:57 3 );
Table created.
17:27:02 topgun>INSERT INTO tab1 (col1) VALUES
17:27:32 2 ('<?xml version="1.0"?>' || Chr(10) || ' <TABLE_NAME>MY_TABLE</TAB
LE_NAME>');
1 row created.
17:27:33 topgun>select * from tab1l
17:27:39 2 ;
select * from tab1l
ERROR at line 1:
ORA-00942: table or view does not exist
17:27:41 topgun>select * from tab1;
COL1
<TABLE_NAME>MY_TABLE</TABLE_NAME>You should follow
INSERT INTO SOURCE TABBLE
SELECT COLUMNS FROM DESTINATION TABLE;
- Pavan Kumar N -
How to create materlised view in oracle 10g what are the step to create it
hi,
this hafeez i have a database in oracle 10g now i want to create materlised view to the database what arre the step required for it.You should refer to documentation for more information:
[Overview of Materialized Views|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#CNCPT411]
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/] -
Insert value into a column based on value of another column
Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance.Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
record, but if you are setting a value in a column of the same
record using a trigger, then it's easy.
:new.COL2 := ....:new.COL4...
:new.COL3 := ....:new.COL4...
The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
If you are setting a different record in the same table, the
solution is much more difficult. -
I have Adobe Pro 9 and I can't insert pages into a PDF created by Adobe Pro 8
I've looked at the other discussions about not being able to insert pages into a PDF, and tried all the suggestions, but to no avail. I think the problem is that the original PDF was created in Adobe 8, and I have Adobe 9. When I open the PDF in Adobe Pro 9, the security screen says that editing is not allowed, and the screen is greyed out so that I can't change the settings. When I open the same PDF in Adobe Pro 8, the security screen says "No Security".
I also checked the "Documents" screen in Edit -> Preferences, and changing the "View Documents in PDF/A" to Never doesn't help.
Does anyone have any suggestions?That would be a question for Adobe support. Firefox does advise users when their Acrobat plugin is out of date, but the actual update is done by Adobe.
Maybe you are looking for
-
Format Payments check printing program completes in warning APP-FND-00500:
Hi All, I'm in process of converting Oracle Payables check printing from reports 6i to XML publisher. I created template, data definition and changed the output for concurrent program to XML. I tried printing check and 'Format Payments (Evergreen)' c
-
Yosemite filevault stuck, battery drain
Hello i enabled filevault after the yosemite update last week and its been stuck encrypting ever since. the estimated time jumps from 60 days to 1.800 days and so on. Corestoragd uses a lot of CPU, can I delete it to solve this? Thanks Best regards
-
Load_systab ERR_EXECUTE during MAXDB upgrade
Hello, I performed MAXDB upgrade from 7.7.04.028 to 7.8.01.014. During the upgrade I received the following message: load_systab -24964,ERR_EXECUTE: error in program execution 768,/sapdb/EFL/db/bin/sdbsysload -R /sapdb/EFL/db -d EFL -u superdba,* Ins
-
This is on a an Acer Veriton DuoCore with 1 GB RAM. I've never had PSCS2 or any beta versions. I ran the CS3CleanUp [level 2] because I failed to install PSCS3 months ago and gave up. I downloaded a new copy of PSCS3. Installer runs smoothly but ends
-
When is the 64-bit version due out?
I can see unofficial binaries are out, but when are Mozilla expecting to launch the official 64-bit version? Working as a web developer my next project will require compatibility with 64-bit browsers as well as 32. In Internet Explorer there are diff