RFC to insert values to a table.
Hello ABAP Experts-
I am pretty new to ABAP devlopment. Recently, I got access where I can develop ABAP program.
Can any one give me steps in writing a program to insert values to Ztable. I want to use this ABAP program in File to RFC scenarion in XI.
I really appreciate your help.
Thanks,
Raj.
Hi...
check this code.
DATA : wa1 type Ztable.
Here it_tab and wa_tab are your internal table and work area.
loop at it_tab into wa_tab.
move wa_tab-vbeln to wa1-vbeln.
insert Ztable from wa1.
Please get back to me if you have any concerns.
Thank you.
Regards,
Lokeswari.
Similar Messages
-
I have a table "xyz" with two columns.
code id
1
1
2
3
4
5
6
The columns id is null and has no constraints.
I need now to insert values in id just like
code id
1 1
1 2
2 3
3 4
4 5
5 6
6 7How to do that?
ThanksHey guys,
Thanks for the reply.
I create a cursor as
declare
j number :=1;
begin
for i in (select code from a order by code) loop
insert into a (id) values(j);
j:=j+1;
end loop;
end;but this insert values as:
SQL> select * from a;
CODE ID
1
1
2
3
4
5
6
1
2
3
4
CODE ID
5
6
714 rows selected. -
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. -
Insert value in WWWDATA table for sending picture in body of email
Hi
.Requrement: Send image in the body of the email.
I am using cl class to sending email and Function module WWW_GET_MIME_OBJECT requre values from table WWWDATA and WWWPARAMS.
I have image file need to be used in email body for the same i want to entry in the table wwwdata and wwwparams so that they can be used to fetch url detail.
I am not able to insert value in wwwdata. Anybody having idea about it.
Thanks & Regards,
Ravi Grover
Edited by: Ravi Grover on Jul 27, 2011 12:34 PMTo display the image in other systems you will have to store the image in SMWO(SAP Web Repository)
Then call the function WWW_GET_MIME_OBJECT .
Please check this link to [Upload|http://abap-explorer.blogspot.com/2008/10/how-to-display-picture-in-screen.html] data in SMWO.
Regards
Mishra -
Insert values to one table based on a value inserted into another table
Hi,
I've got a form based off a report which creates a new project. I've added an additional process to this form to insert four new values into another table as soon as the new project is created and the PK for that project is generated. This was working last week (of course!) and now seems to not work at all. It's complaining that the PK I was getting from my first insert was null. Here is one the the statements in my process I'm trying to run:
insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
The complaint I get that it's getting null where :P45_PROJECT_SEQ should be.
Thoughts?
Thanks,
JonHi Andy,
Thanks for the tip. Those two values didn't match and I updated them so they do and I'm still getting a "cannot insert NULL..." error.
When I turn on debug I see that I'm getting the PK and I see the value. Here's my debug output:
0.24: ...Process "Get PK": PLSQL (AFTER_SUBMIT) declare function get_pk return varchar2 is begin for c1 in (select PROJECT_SEQ.nextval next_val from dual) loop return c1.next_val; end loop; end; begin :P45_PROJECT_SEQ := get_pk; end;
0.25: ...Session State: Saved Item "P45_PROJECT_SEQ" New Value="252"
0.25: ...Process "Process Row of PROJECT": DML_PROCESS_ROW (AFTER_SUBMIT) #OWNER#:PROJECT:P45_PROJECT_SEQ:PROJECT_SEQ|IUD
0.26: ...Session State: Save "P45_PROJECT_SEQ" - saving same value: "252"
0.26: ...Process "reset page": CLEAR_CACHE_FOR_PAGES (AFTER_SUBMIT) 45
0.27: Nulling cache for application "120" page: 45
0.27: ...Process "Add Week Groups": PLSQL (AFTER_SUBMIT) insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER); insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY') +
0.28: Encountered unhandled exception in process type PLSQL
0.28: Show ERROR page...
0.28: Performing rollback...
I notice that when it runs my process "Add Week Groups" it's not displaying all of the SQL. But the SQL is fine, it's right here:
insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
Hmmm....what about the "reset page" action in the last of the 0.26 lines?
Thanks,
Jon -
Hi Experts,
We checked in the debugger that the values 105,106 &107 are not added in the virsa_cc_config table.
Where to add the values in the table? In J2ee database or in server database (which is oracle for us)? When we searched in oracle data base this table doesnot exist.
So we believe it has to be inserted in J2EE database. If yes, can somebody help us how to check and insert the values in the respective table in J2ee database
Thanks and Best Regards,
Srihari.KDear Sri,
Yes this table resides in database where GRC is installed.
To insert these lines, you need to login into GRC server-
if it is windows goto -
sqlplus /nolog
connect /as sysdba
run this command
INSERT INTO SAPSR3DB.VIRSA_CC_CONFIG (CNFGPARAM, CNFGSEQ, CNFGVALUE) VALUES
('105', 0, 'http')
INSERT INTO SAPSR3DB.VIRSA_CC_CONFIG VALUES ('106', 0, '<port number>', 'J2EE Engine Port')
INSERT INTO SAPSR3DB.VIRSA_CC_CONFIG VALUES (107, 0,'http://<fully qualified hostname>:<port number>/webdynpro/dispatcher/sap.com/grc~ccappcomp/BgJobStart','BgJobStart URL')
Commit;
Put your hostname and port accordingly and run.
Let me know if it works.
Regards,
Sabita -
Insert value in a table through forms
hello friends,
I have table "log" with following fields.
SQL> desc log;
Name Null? Type
IN_HR NUMBER
IN_MIN NUMBER
OUT_HR NUMBER
OUT_MIN NUMBER
DAYHR NUMBER
DAYMIN NUMBER
LOGUSER VARCHAR2(20)
I created one form "user_activity" with two buttons named "IN" and "OUT"..
when i press "IN" button i want to store follwing in LOG table..
LOGUSER----> This should store the global variable value derived from another form called "login_main"...Actually i called "user_activity" form from "login_main" with global variable..this global variable have the username who is currently logged in...But my problem is i cant insert this value..
NOTE: pls tell me how can i check this global variable is hold value or not...
IN_HR---> This is successfully updated in log table..
in_min--> This is successfully updated in log table..
Pls help me how to store this global variable value into log table... my actual code is follows..I write this code in "when-button-pressed"trigger of "IN" Button..
<code>
declare
name varchar2(30);
begin
name:=:global.username;
insert into log(loguser)values(name);
commit;
:CUSTOMER.IN_TIME:=to_char(sysdate,'hh24:mi:ss');
update log set in_hr=round(to_number(to_char(sysdate,'HH24'))),
in_min=round(to_number(to_char(sysdate,'mi')))
where loguser=name;
commit;
end;
<\code>Hello,
please don't open multiple threads for the same question. It only adds confusion to those willing to help you, and you won't get quicker answers when posting questions more then once.
Also, mostly solutions to problems are version dependend, so the very first thing you should do is to provide the involved versions (database, forms, java, OS; remember that oracle products have 5 digit version numbers; 10g is not a version number, 10.2.0.5 is; also "Windows" has a lot of flavors; "Windows 3.11" is also "Windows", so don't say just "Windows"). Even if you think a solution isn't version dependend provide the involved versions. It isn't much effort on your side and saves us a question roundtrip when it is needed anyway.
after that you didn't give us much to work with except a - sorry but I don't have any other word for this - ill data model where you seem to want to reinvent the date datatype and some code which seem to compile (no I didn't try it). Oh, and the fact that "it didn't work". Did you debug your code? How do you populate your global variable? Did you inspect your global variable before the insert? Also what should be stored in your global? is it the current logged on oracle user? You could simply use user to get this and forget about the global
Oh, and before I forget it:
please, don't reinvent the date datatype, and fix your data model.
loguser varchar2(20)
in_date date
out_date date
insert into log(loguser, in_date) values (user, sysdate);
commit;no muss, no fuss and about 20% of the amount of code you wrote.
cheers -
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 -
To insert values in same table
hi,
based on date difference i want insert the data in same table
eg: if date diff is 2
i want insert 2 rows in a same table
how to resolve this
Edited by: hareeshKR on Oct 1, 2011 9:10 AMHi,
Please explain further what is your goal, what table are trying to add?
Because inserting data in a table is not supported.
Thanks.
Clint -
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 -
Trying to insert values into a table inserts the wrong values
Hi, I'm sure this is quite simple but I don't know why it is happened (Spent about 2 hours debugging my program only to find the error is actually in the SQL insert statement not working properly hehe)
I have a simple Payment table with the following columns:
int - ID (primary key)
int - Amount
int - Paid
varchar - Notes
I try to place a new record into the table as follows:
insert into payment values (1010,50,1,'Hello')
but the ID i choose is not added to the record, rather the database assigns a ID instead automatically (it seems to add 1 to the last ID)
On further inspection this happens for another of my tables too, however for another table, this does not happen and I can assign an ID as I would like.
When creating my tables I thought I set them all up the same, however I guess not
Does anyone know the problem?
ThanksHi,
Are you are using this INSERT statement in any form??? if so, please check your pre-insert trigger.
If not, then you may verify it by inserting it through iSQLPlus. If it doesn't insert your data, then check the database triggers associated with INSERT for your table.
Regards,
Zaaf -
Insert values in multiple tables. One of the tables has complex primary key.
Hello, I am using Jdeveloper version 11.1.2.3.0
I have a table FORM_TYPE and another table Str. The Str table is used to translate strings from the table name which are read from another program from the database and used to generate forms..
The FORM_TYPE table has a relation to the STR table via formtype.title_str_id = str.str_id.
The STR table has a primary key that is depending on mf_language and str_id columns. I generated entity for the STR table but can't insert from the application module new values for some reason... It says the record invalidates its own entity..
I am trying to create a table that will be editable and will have the columns Description, Name, Str in English, Str in French etc...
Want to create a Form_Type and in the same time to insert new values for each language... But can't make the inserts of the new STR work..
Also the FormType.TITLE_STR_ID has many values null already in the database.
SELECT FormType.DESCRIPTION,
FormType.FORM_TYPE_ID,
FormType.NAME,
FormType.PAPER_REPORT_FORMAT,
FormType.PAPER_REPORT_NAME,
FormType.TITLE_STR_ID,
en.str en_str,
en.str_id,
en.object_name en_object_name,
fr.str,
fr.str_id,
fr.object_name,
du.str,
du.str_id,
du.object_name,
bg.str,
bg.str_id,
bg.object_name
FROM FORM_TYPE FormType,
(select str.str_id, str.mf_language_id, str.str, str.object_name
from mf_language ml, str
where ml.mf_language_id = str.mf_language_id
and ml.code ='en') en
, (select str.str_id, str.str, str.object_name
from mf_language ml, str
where ml.mf_language_id = str.mf_language_id
and ml.code ='fr') fr,
(select str.str_id, str.str, str.object_name
from mf_language ml, str
where ml.mf_language_id = str.mf_language_id
and ml.code ='du') du,
(select str.str_id, str.str, str.object_name
from mf_language ml, str
where ml.mf_language_id = str.mf_language_id
and ml.code ='bg') bg
WHERE
formtype.title_str_id = en.str_id and
formtype.title_str_id = fr.str_id and
formtype.title_str_id = du.str_id and
formtype.title_str_id = bg.str_idTried that I made view links and associations but still can't insert in both tables at once... Could be because the tables aren't having relationship between them or because the STR table has a (STR_ID, MF_LANGUAGE_ID) primary key...
-
Inserting values in a table from a view report in Application Express
Hello.
I have several tables with the sql bellow:
Employee
CREATE TABLE "Employee"
( "Employee_ID" NUMBER,
"Name" VARCHAR2(12) CONSTRAINT "NAME_EMPLOYEE_NN" NOT NULL ENABLE,
"Surname" VARCHAR2(10) CONSTRAINT "SURNAME_EMPLOYEE_NN" NOT NULL ENABLE,
"Address" VARCHAR2(50) CONSTRAINT "ADDRESS_EMPLOYEE_NN" NOT NULL ENABLE,
"Telephone" VARCHAR2(10),
"Personal_ID_Number" VARCHAR2(13),
"Date_of_Employment" VARCHAR2(10) CONSTRAINT "DATA_NN" NOT NULL ENABLE,
"Salary" NUMBER(6,0),
CONSTRAINT "Employee_ID_con" PRIMARY KEY ("Employee_ID") ENABLE,
CONSTRAINT "Employee_CON" UNIQUE ("Personal_ID_Number", "Telephone") ENABLE
Patient
CREATE TABLE "PATIENT"
( "Patient_ID" NUMBER,
"Name_Patient" VARCHAR2(13) CONSTRAINT "NAME_PAT_NN" NOT NULL ENABLE,
"Surname_Patient" VARCHAR2(10) CONSTRAINT "SURNAME_PAT_NN" NOT NULL ENABLE,
"ADSRESS_PATIENT" VARCHAR2(50),
"TELEPHONE_PATIENT" VARCHAR2(10) CONSTRAINT "TEL_PAT_NN" NOT NULL ENABLE,
"EMPLOYEE_ID" NUMBER CONSTRAINT "DENTIST_PAT_NN" NOT NULL DISABLE,
CONSTRAINT "PK_PATIENT" PRIMARY KEY ("PATIENT_ID") ENABLE,
CONSTRAINT "PACIENT_CON" UNIQUE ("TELEFON_PACIENT") ENABLE
ALTER TABLE "PATIENT" ADD CONSTRAINT "PATIENT_CON3" FOREIGN KEY ("Employee_ID")
REFERENCES "Dentist" ("Employee_ID") ON DELETE SET NULL ENABLE
Appointment
CREATE TABLE "Appointment"
( "Appointment_ID" NUMBER,
"Employee_ID" NUMBER CONSTRAINT "NN_Dentist_Appointment" NOT NULL ENABLE,
"Patient_ID" NUMBER CONSTRAINT "NN_PATIENT_Appointment" NOT NULL ENABLE,
"Who_Made" NUMBER,
"Who_Changed" NUMBER,
"Who_Canceled" NUMBER,
"Content" VARCHAR2(1000),
"DATE" DATE,
CONSTRAINT "PK_Appointment" PRIMARY KEY ("Appointment_ID") ENABLE
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_CON" FOREIGN KEY ("Patient_ID")
REFERENCES "PATIENT" ("Patient_ID") ENABLE
ALTER TABLE "Appointment" ADD FOREIGN KEY ("Employee_ID")
REFERENCES "Dentist" ("Employee_ID") ENABLE
ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Made")
REFERENCES "Employee" ("Employee_ID") ENABLE
ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Changed")
REFERENCES "Employee" ("Employee_ID") ENABLE
ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Canceled")
REFERENCES "Employee" ("Employee_ID") ENABLE
Dentist
CREATE TABLE "Dentist"
( "Employee_ID" NUMBER,
"Qualifications" VARCHAR2(50),
CONSTRAINT "RB_VRAB_STOMATOLOG_PK" PRIMARY KEY ("Employee_ID") ENABLE
ALTER TABLE "Employee_ID" ADD CONSTRAINT "Dentist_CON" FOREIGN KEY ("Employee_ID")
REFERENCES "Employee" ("Employee_ID") ON DELETE CASCADE ENABLE
I'm trying to make an application in Oracle Application Express and I've tried making an SQL report using the following SQL query:
CREATE OR REPLACE FORCE VIEW "Appointment_REPORT" ("DOCTOR", "PATIENT", "Content", "Date") AS
select concat(concat(v.name,' '),v.surname) as doctor, concat(concat(pa.name_patient,' '),pa.surname_patient) as pactent, p.content, p.date
from Appointment p, Amployee v, Patient pa
where
v.employee_id=p.employee_id
and p.patient_id=pa.patient_id
The SQL works fine and gives me lovely results in my report. However, I don't know how to link the SQL to my actual Appointment table. Deleting, updating or creating new appointments through this view is impossible because I get the following error Unexpected error, unable to find item name at application or page level.
I understand how to make a form on the Appointment table but given how that table contains lots of primary keys (numbers) it's not preferable for the user to have to deal with that.
Can I have some help with linking the two and making it functional?
Thanks in advance.982909 wrote:
Hello.
I have several tables with the sql bellow:You are digging yourself a DEEP hole by using double quote marks & Mixed Case table & column names!
>
CREATE TABLE "Appointment"
( "Appointment_ID" NUMBER,
"Employee_ID" NUMBER CONSTRAINT "NN_Dentist_Appointment" NOT NULL ENABLE,
"Patient_ID" NUMBER CONSTRAINT "NN_PATIENT_Appointment" NOT NULL ENABLE,
"Who_Made" NUMBER,
"Who_Changed" NUMBER,
"Who_Canceled" NUMBER,
"Content" VARCHAR2(1000),
"DATE" DATE,
AVOID using Reserved Words like "DATE" as column or table names!
>
I'm trying to make an application in Oracle Application Express and I've tried making an SQL report using the following SQL query:
CREATE OR REPLACE FORCE VIEW "Appointment_REPORT" ("DOCTOR", "PATIENT", "Content", "Date") AS
select concat(concat(v.name,' '),v.surname) as doctor, concat(concat(pa.name_patient,' '),pa.surname_patient) as pactent, p.content, p.date
from Appointment p, Amployee v, Patient pa
where
v.employee_id=p.employee_id
and p.patient_id=pa.patient_id
The SQL works fine and gives me lovely results in my report. However, I don't know how to link the SQL to my actual Appointment table. Deleting, updating or creating new appointments through this view is impossible because I get the following error Unexpected error, unable to find item name at application or page level.
I understand how to make a form on the Appointment table but given how that table contains lots of primary keys (numbers) it's not preferable for the user to have to deal with that.
Any table can have only ONE Primary Key.
Can I have some help with linking the two and to which "two" do you refer?
making it functional?Since you have told us what functionality is desired or expected,
I don't know what might be a solution.
Maybe you are looking for
-
Confused - whats the difference between K8N Neo4 SLI Platinum and Diamond??
MSI web page says the Diamond has: "Silicon Image's SATA RAID supports another 2 SATA II ports. Transfer rate is up to 300MB/s." http://www.msi.com.tw/program/products/mainboard/mbd/pro_mbd_detail.php?UID=638 their Platinum page doesn't list the Sili
-
Hello, We are encountering a problem with Toplink 11.1.1.0.1 when adding a custom sql statement within a ReadAllQuery on a parent class. The same code with the same descriptor works fine with 10.1.3.3 and 9.0.4.7. ReadAllQuery query = new ReadAl
-
How to check total size of attachment stored in database?
Hello guys, Firstly I'm new to this forum & SAP Basis. Therefore i want to apologize if i'm posting in wrong area. Actually I want to know how to check total size of attachment that have been uploaded in ECC. From the current database size, how can i
-
How to calculate average of step-shaped waveform?
hello, i have analog waveform which looks like an incremental step function... the step increments in fixed time duration of 'x' sec, and stays at a near constant value, but has some noise (ex. attached image) i would like to find out the average of
-
Cant hear ringer tone when calling others nor can hear who im calling
okay so everytime i make a call for the frist time i cant hear the ringer tone nor can hear the person im calling. they say they can hear me perfectly but the only thing i hear is my own voice, i see the call outgoes the iphone because the call timer