Querying EBS data from APEX through PL/SQL process
Hi all,
I have read through http://www.oracle.com/technetwork/developer-tools/apex/apex-ebs-wp-cabot-consulting-169064.pdf
and http://www.oracle.com/technetwork/developer-tools/apex/learnmore/apex-ebs-extension-white-paper-345780.pdf
But I still do not have much idea on how do I query for data from ebs. What I am trying to achieve is to query for a table in EBS and put the data as a httpresponse
then parse the data using javascript by creating a html region in APEX.
Previously, I was creating an application process in the following manner
declare
element_List varchar2(4000) := '';
begin
begin
for i in (select END_MEASURE from SCS_ELEMENT_DATA where ATTRIBUTE10 = :P9_ASSET_ID) loop
element_List := element_List || i.END_MEASURE || ' ';
end loop;
exception when no_data_found then null;
end;
htp.prn(element_List);
end;
My table structure in EBS is something like this:
XXEAM_LAM_ELEMENTS (lam_element_id, csi_instance_id, element_name, element_desc, label, type, continuous, reference, shared, start_measure, end_measure, lat_long)
Would appreciate any advice as I'm new to both APEX and EBS.
Hi Scott and Tom,
Sorry about this.
My Apex is installed in the same instance as my EBS. I assume this means they are in the same DB? So if this is the case, can I just query with the EBS table name and the APEX application will know its EBS table and not APEX table?
Because previously my query was based on APEX tables and now I have query based on my EBS table using an APEX application process. I couldn't really understand what's needed even after looking through the whitepaper. I do not need to create a view/report based on the queried data because my APEX page only has a HTML region where I put all my javascript code in.
Hope this is clearer. Sorry for not being clear on my issue.
Regards,
CS
Similar Messages
-
How to retrive the blob data from a table using sql query
Hi gurus,
I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
Regards,
vardhani.You can use data templates.
See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
Thanks,
Bipuser -
Query xml data from a CLOB datatye
All,
I read in an oracle white paper that is is possible to query XML data from CLOB datatype using oracle text index using operators HASPATH() and INPATH(). I am not able to find any example on how to do this. Can someone please post a simple example here.
Thank You very much!SCOTT@10gXE> CREATE TABLE your_table (id NUMBER, xml_data CLOB)
2 /
Table created.
SCOTT@10gXE> INSERT INTO your_table (id, xml_data)
2 SELECT t.deptno,
3 DBMS_XMLGEN.GETXML
4 ('SELECT d.dname,
5 CURSOR (SELECT e.ename, e.job
6 FROM emp e
7 WHERE e.deptno = d.deptno) emp_data
8 FROM dept d
9 WHERE d.deptno = ' || t.deptno)
10 FROM dept t
11 /
5 rows created.
SCOTT@10gXE> COMMIT
2 /
Commit complete.
SCOTT@10gXE> begin
2 ctx_ddl.create_section_group('xmlpathgroup', 'PATH_SECTION_GROUP');
3 end;
4 /
PL/SQL procedure successfully completed.
SCOTT@10gXE> CREATE INDEX myindex
2 ON your_table(xml_data)
3 INDEXTYPE IS ctxsys.context
4 PARAMETERS ('datastore ctxsys.default_datastore
5 filter ctxsys.null_filter
6 section group xmlpathgroup'
7 )
8 /
Index created.
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (xml_data, 'PERSONNEL INPATH (//DNAME)') > 0
3 /
ID XML_DATA
50 <?xml version="1.0"?>
<ROWSET>
<ROW>
<DNAME>PERSONNEL</DNAME>
<EMP_DATA>
</EMP_DATA>
</ROW>
</ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (xml_data, 'HASPATH (//DNAME="PERSONNEL")') > 0
3 /
ID XML_DATA
50 <?xml version="1.0"?>
<ROWSET>
<ROW>
<DNAME>PERSONNEL</DNAME>
<EMP_DATA>
</EMP_DATA>
</ROW>
</ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (xml_data, 'CLARK INPATH (//ENAME)') > 0
3 /
ID XML_DATA
10 <?xml version="1.0"?>
<ROWSET>
<ROW>
<DNAME>ACCOUNTING</DNAME>
<EMP_DATA>
<EMP_DATA_ROW>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
</EMP_DATA_ROW>
<EMP_DATA_ROW>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
</EMP_DATA_ROW>
<EMP_DATA_ROW>
<ENAME>MILLER</ENAME>
<JOB>CLERK</JOB>
</EMP_DATA_ROW>
</EMP_DATA>
</ROW>
</ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (xml_data, 'HASPATH (//ENAME="CLARK")') > 0
3 /
ID XML_DATA
10 <?xml version="1.0"?>
<ROWSET>
<ROW>
<DNAME>ACCOUNTING</DNAME>
<EMP_DATA>
<EMP_DATA_ROW>
<ENAME>CLARK</ENAME>
<JOB>MANAGER</JOB>
</EMP_DATA_ROW>
<EMP_DATA_ROW>
<ENAME>KING</ENAME>
<JOB>PRESIDENT</JOB>
</EMP_DATA_ROW>
<EMP_DATA_ROW>
<ENAME>MILLER</ENAME>
<JOB>CLERK</JOB>
</EMP_DATA_ROW>
</EMP_DATA>
</ROW>
</ROWSET>
SCOTT@10gXE> -
What is the easiest way to export all tables data from Oracle to MS SQL Server?
Hello MS,
I would like to export all tables from Oracle 11.2 to MS SQL Server 2012 R1.
Using the tool "Microsoft SQL Server Migration Assistant v6.0 for Oracle" did not work for me because there are too many warnings and errors regarding the schema creation (MS cannot know it because they are not the schema designer). My idea is
to leave/skip the schema creation to the application designer/supplier and instead concentrate on the Oracle data export and MS SQL data import.
What is the easiest way to export all tables data from Oracle to MS SQL Server quickly?
Is it:
- the „MS SQL Import and Export Data“ Tool
- the “MS SQL Integration Services” Tool
- not Oracle dump *.dmp format because it is a propritery binary format
- flat file *.csv (delimited format)
Thanks!Hi lingodingo,
If you want to directly export all tables from Oracle database to SQL Server, I suggest you use SQL Server Import and Export Wizard. Because you just need to follow the wizard with GUI, this is the easiest way.
If you want to make some modification for the tables‘ data before loading to SQL Server, I suggest you use SQL Server Integration Services package. For more details, please refer to the following similar thread:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/38b2bed2-9d4e-48d4-a33f-1d9eed1c062d/flat-file-to-sql-server?forum=sqldatamining
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to retrieve Data from SAP BW to SQL
Hi All,
i am looking for way to retrieve Data from SAP BW to SQL.
Could you please give me some indcations or a document on how to implement it?
Thanks in advance
Cheers
GiloHi,
You need to use open hub destination. third party tool destination for SQL
SAP BW TO SQL -- Extraction to the third-party tool can be executed as follows:
1. You define an open hub destination with Third-Party Tool as the destination type.
2. You create an RFC destination for your third-party tool and enter it in the definition of the open hub destination.
3. You use API RSB_API_OHS_DEST_SETPARAMS to define the parameters for the third-party tool that are required for the extraction.
4. You either start extraction immediately or include it in a process chain. You can also start this process chain from the third-party tool using process chain API RSPC_API_CHAIN_START. The extraction process then writes the data to a database table in the BI system.
5. When the extraction process is finished, the system sends a notification to the third-party tool using API RSB_API_OHS_3RDPARTY_NOTIFY.
6. The extracted data is read by API RSB_API_OHS_DEST_READ_DATA.
7. The status of the extraction is transferred to the monitor by API RSB_API_OHS_REQUEST_SETSTATUS. -
Extracting SAP Query,Infoset Data from VB Application
Hi,
I need to get all SAP Queries,Infosets and SAP Query Group data from a VB application.
I have found a Remote Enabled Function called IQAPI_READ_QUERY_CATALOG.
But when I call the Function from a VB application ,the call is not successful and even I am not getting any exception.
The call is getting false with null exception .
Can anyone please guide me.
Or is there any other function module /procedure / table to extract SAP Query ,Infoset,SAP Query Group data??
Thanks in Advance.http://stackoverflow.com/questions/3765373/how-do-i-do-a-select-distinct-using-a-sap-infoset-query
-
Propagate Data from User Profile to Resource Process Form doesn't work
Hi,
i've created a new custom task for Propagate Data from User Profile to Resource Process Form with a gtc connector but the task is never triggered!!!
i need clues to resolve this .
thnks.!!
oim 11g 11.1.1.5 bp4. high availability with 2 nodes and a balancer.Hi Rajiv:
->Did you make that entry in Lookup as mentioned in that thread/post ?
ANSW: yes.
->Did you use exact naming convention for your tasks ?
ANSW: yes i put the same name that i put in the lookup into my process from.
In which process definition have you created your task. Make sure it should be other than "Xellerate User" process definition.
ANSW: PROCESS DEFINITION: * iPlanet User
*TB_BAN1_AUR_GTC
*TB_BAN5_AUR_GTC
*TB_BAN3_AUR_GTC
etc.. GTC conector.
i have a test environment where this functionality works succesfully and i put the same in my production environmnet and the task never is triggered. -
ABAP SQL Query (Select data from intervals)
Hi All,
From To Temp
101 200 1111
201 300 2222
301 400 3333
401 500 4444
501 600 5555
From, To & Temp are three Fields.
Consider the above table, if i enter input as 150, need to pick 1111.
If the input is inbetween of From & To values means I want to pick the exact
Data from temp field.
Thanks
Hema
Edited by: hema prabakaran on Jan 19, 2009 7:54 AM
Edited by: hema prabakaran on Jan 19, 2009 8:30 AMHi
Data: itab type table of tbl with header line.
select * from tbl into table itab.
if sy-subrc eq 4.
Message E000(YJK).
else.
loop at itab.
if v_temp between itab-from and itab-to.
write itab-temp.
exit.
else.
continue.
endif.
endloop.
endif.
You can use the above code.
It is not possible to use select stmt with your i/p variable in the where clause as that field is not present in table.
hope this helps
Regards,
Jayanthi.K -
Is it possible to start planning manager programatically from backend through PL/SQL?
I need to activate and run Planning manager concurrent program from back end through PL/SQL.Actually i am working on MRP Open Forecast Interface and I want to run this program after inserting data in the interface table mrp_forecast_interface.Please guide me.
Oracle EBS forum is the best place for your question. This place is more towards general SQL, PL/SQL questions.
https://community.oracle.com/community/oracle-applications/e-business_suite/e-business-suite-technology/general_ebs_discussion -
Import data from Informix DB to SQL Server 2012
I am trying to use the SSIS Import and Export Wizard in SQL Server Data Tools to migrate an Informix database to SQL Server 2012. I go through the steps & when I hit Finish I get an error message that says:
TITLE: SQL Server Import and Export Wizard
Could not connect source component.
Error 0xc0047062: Source - material [1]: System.Data.Odbc.OdbcException (0x80131937): ERROR [42000] [Informix][Informix ODBC Driver][Informix]A syntax error has occurred.
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Odbc.OdbcCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.ReinitializeMetaData()
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostReinitializeMetaData(IDTSManagedComponentWrapper100 wrapper)
ADDITIONAL INFORMATION:
ERROR [42000] [Informix][Informix ODBC Driver][Informix]A syntax error has occurred. (iclit09b.dll)
BUTTONS:
OK
I am getting this error when I use the "Copy data from one or more tables or views" option. I am able to migrate a single table with no problem when I use the "Write a query to specify the data to transfer"
option. This is my first time using SSIS so I am not sure what to do. Can anyone help me out? Thanks...The following link explains the steps/processes requires to perform this in SSIS:
http://davidbridge.wordpress.com/2012/05/30/extraction-from-informix-database-using-ssis-data-warehouse-etl/
Thanks, hsbal -
Not able to retrieve data from database through servlet
Hi friends,
I am trying to open a excel sheet through servlet. In this servlet i am retriving data from mssql database.I am not getting any error but no data is retrived
i m also pasting the code here
// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: EmployeeData.java
import java.io.*;
import java.sql.*;
import javax.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
public class EmployeeData extends HttpServlet
public EmployeeData()
public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
httpservletresponse.setContentType("text/html");
httpservletresponse.setHeader("Content-Type", "application/excel");
httpservletresponse.setHeader("Content-Disposition", "filename=reports.xls");
PrintWriter printwriter = httpservletresponse.getWriter();
try
javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
int i = 0;
/* Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=newreportsodbc", "reportuser", "cisco");*/
String url="jdbc:odbc:newreportsodbc";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:odbc:newreportsodbc","reportuser","cisco");
Statement statement = connection.createStatement();
printwriter.println("<b><center><u> Search Results </u></center></b>");
printwriter.print("<table><tr><th color=brown background-color=#fff000> No. </th>");
printwriter.print("<th> DateTime </th></tr></table>");
ResultSet resultset = statement.executeQuery("SELECT * FROM t_Call_Type_Half_Hour");
boolean flag;
for(flag = false; resultset.next(); flag = true)
i++;
SerialNo = resultset.getString(2);
printwriter.print((new StringBuilder()).append("<table><tr><td> ").append(i).append("</td>").toString());
printwriter.print((new StringBuilder()).append("<td> ").append(SerialNo).append("</td></tr></table>").toString());
if(!flag)
printwriter.println("<h1> No records selected </h1>");
catch(Exception exception)
System.out.println((new StringBuilder()).append("SQLException: ").append(exception).toString());
static String empid1;
static String empid;
static String SerialNo;
static String designation;
}thanks in advance. i just feel there is something to be done with connection string.post the table format in SQL
-
Displaying the data from a "LINQ to SQL database"
I have created a LINQ to SQL database with a simple table/class with the following properties:
Counter
Subject
Description
About the Counter, how do I set the properties so it behaves like a "Counter". For each row I want it to automatically add new numbers like this:
1 Subject1 Decsription1
2 Subject2 Description2
3 Subject3 Description3...and so on for every new data inserted.
For now I have "Auto Generated Value=True" and "Primary Key=True". Is that the right way to go? What do I set for "Auto-Sync"? There are options like "Never, OnInsert, OnUpdate, Always".
I believe I've manage to do the coding for the insert part:
private void btnAddReminder_Click(object sender, RoutedEventArgs e)
DataClasses1DataContext db = new DataClasses1DataContext("db");
Reminders reminder = new Reminders();
reminder.Subject = txtSubject.Text;
reminder.Description = txtDescription.Text;
db.Reminders.InsertOnSubmit(reminder);
MessageBox.Show("Content added!");
Now first of all, is there a way I can display the database content directly in Visual Studio so I can see if I've manage to add any content in the table? I haven't yet find a way so far.
Second how do I get the content from the datatable row by row and display it in MainWindow.xaml? What would the code look like? For every row I would like it to be displayed like this:
1. Subject1
Description1
2. Subject2
Description2
3. Subject3
Description3
Is it possible to display "1. Subject1" in a Label. It should be sort of a headline.
Then would it be possible to display "Description1" in a TextBlock?
The idea is that Subject along with the number should have a larger font size, and the Description shoud be a bit smaller font size.
>>For now I have "Auto Generated Value=True" and "Primary Key=True". Is that the right way to go?
Yes, this means that the database takes care of the actual incrementation for you which is perfectly fine and probably what you want.
>>how do I get the content from the datatable row by row and display it in MainWindow.xaml
You need to an ItemsControl that can render all items in a collection somewhere in the MainWindow, e.g.:
<ItemsControl x:Name="ic">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 0 0 10">
<TextBlock Text="{Binding Counter}"/>
<TextBlock Text=". "/>
<TextBlock Text="{Binding Subject}"/>
</StackPanel>
<TextBlock Text="{Binding Description}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
The ItemTemplate (DataTemplate) of the ItemsControl defines the appearance of each item in its ItemsSource collection, i.e. a Reminders object in your case.
You then simply set the ItemsSource of the ItemsControl to the collection of Reminders object that you want to display in it in your code:
private void btnAddReminder_Click(object sender, RoutedEventArgs e)
DataClasses1DataContext db = new DataClasses1DataContext("db");
Reminders reminder = new Reminders();
reminder.Subject = txtSubject.Text;
reminder.Description = txtDescription.Text;
db.Reminders.InsertOnSubmit(reminder);
MessageBox.Show("Content added!");
ic.ItemsSource = db.Reminders;
>>is there a way I can display the database content directly in Visual Studio so I can see if I've manage to add any content in the table?
First of all, please don't ask several questions in the same thread. Second, this is not a WPF question. If you are using a service-based database, you could select data from it from the Server Explorer in Visual Studio:
http://msdn.microsoft.com/en-us/library/vstudio/ms233763(v=vs.120).aspx. Otherwise you typically use SQL Sever Management Studio to query a database. For Visual Studio specific questions, please use the Visual Studio forums:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio%2Cvsarch%2Cvsdbg%2Cvstest%2Cvstfs%2Cvsdata%2Cvsappdev%2Cvisualbasic%2Cvisualcsharp%2Cvisualc
Please remember to mark helpful posts as answer and/or helpful. -
Retrieving data from different node in SQL
Hi friends,
First of all:
BANNER
1 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
2 PL/SQL Release 11.2.0.3.0 - Production
3 CORE 11.2.0.3.0 Production
4 TNS for Linux: Version 11.2.0.3.0 - Production
5 NLSRTL Version 11.2.0.3.0 - ProductionI have a small but annoying problem. I have to build a bank application which must take data from an input file, and, based on those information, to execute some stored procedures (create a new customer, create a new account, create a transaction for an account).
For example: the input file contain few new customers (FirstName, LastName, SocialSecurityNumber, BirthDay, Address and PhoneNo), for each customer at least 1 account to be created, for each account 1 or more transactions (the amount of transaction).
Let me be more specific. This is an XML as a input file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<doc>
<PERS_INFO>
<lastname>John</lastname>
<firstname>Doe</firstname>
<social_security_no>1800325171545</social_security_no>
<birthday>25/03/1980</birthday>
<address>Principal, 15</address>
<phoneno>0040722222222</phoneno>
<acc>
<transaction>200</transaction>
<transaction>150</transaction>
<transaction>-23</transaction>
</acc>
<acc>
<transaction>450</transaction>
</acc>
<acc>
<transaction>800</transaction>
<transaction>320</transaction>
<transaction>-125</transaction>
</acc>
</PERS_INFO>
<PERS_INFO>
<lastname>Smith</lastname>
<firstname>Pop</firstname>
<social_security_no>2851211173377</social_security_no>
<birthday>11/12/1985</birthday>
<address>FirstAvenue, 20</address>
<phoneno>0040744444444</phoneno>
<acc>
<transaction>444</transaction>
<transaction>550</transaction>
</acc>
<acc>
<transaction>113</transaction>
<transaction>-50</transaction>
<transaction>89</transaction>
</acc>
<acc>
<transaction>300</transaction>
</acc>
</PERS_INFO>
</doc>This input file should start the following:
- create 2 new customers (using a stored procedure Pr_Add_New_Cust):
1. John Doe / 1800325171545 / 25.03.1980 / Principal, 15 / 0040722222222
2. Smith Pop / 2851211173377 / 11.12.1985 / FirstAvenue, 20 / 0040744444444
- for John Doe I have to create 3 new account (using a stored procedure Pr_Add_New_Account):
- account 1 - for this account I have to create 3 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 200$, DEPOSIT 150$, WITHDRAW 23$
- account 2 - for this account I have to create 1 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 450$
- account 3 - for this account I have to create 3 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 800$, DEPOSIT 320$, WITHDRAW 125$
- for Smith Pop I have to create 3 new account (using a stored procedure Pr_Add_New_Account):
- account 1 - for this account I have to create 2 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 444$, DEPOSIT 550$
- account 2 - for this account I have to create 3 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 113$, WITHDRAW 50$, DEPOSIT 89$
- account 3 - for this account I have to create 1 new transactions (using a stored procedure Pr_Create_New_Trans): DEPOSIT 300$
Well, I'm thinking to do that by loading that XML into a pre-staging table - INS_STG1 - (the loading part is not an issue for the moment) and by parsing the XML in order to get my necessary information (inserting into the second staging table INS_STG2) to launch those procedures.
Something like this (for the moment I insert only the customer information since I don't know how to get to the second level):
DECLARE
TYPE ty_rec_1 IS RECORD (v_cust_firstname VARCHAR2(32),
v_cust_lastname VARCHAR2(32),
v_cust_persnumcode VARCHAR2(32),
v_cust_birthday VARCHAR2(32),
v_cust_address VARCHAR2(32),
v_cust_phoneno VARCHAR2(32));
TYPE ty_cur_1 IS REF CURSOR RETURN ty_rec_1;
TYPE ty_arr_rec_1 IS TABLE OF ty_rec_1 INDEX BY PLS_INTEGER;
cur_1 ty_cur_1;
arr_rec_1 ty_arr_rec_1;
my_xml xmltype;
N_BULK_SIZE NUMBER := 1000;
BEGIN
SELECT xml_column INTO my_xml FROM INS_STG1;
OPEN cur_1 FOR
SELECT extractvalue(column_value, '/PERS_INFO/firstname') "v_cust_firstname",
extractvalue(column_value, '/PERS_INFO/lastname') "v_cust_lastname",
extractvalue(column_value, '/PERS_INFO/social_security_no') "v_cust_persnumcode",
extractvalue(column_value, '/PERS_INFO/birthday') "v_cust_birthday",
extractvalue(column_value, '/PERS_INFO/address') "v_cust_address",
extractvalue(column_value, '/PERS_INFO/phoneno') "v_cust_phoneno"
FROM TABLE(XMLSequence(my_xml.extract('/doc/PERS_INFO'))) t;
LOOP
FETCH cur_1 BULK COLLECT INTO arr_rec_1 LIMIT N_BULK_SIZE;
EXIT WHEN arr_rec_1.COUNT() = 0;
FORALL n_idx1 IN 1..arr_rec_1.COUNT()
INSERT INTO INS_STG2
(cust_firstname, cust_lastname, cust_persnumcode, cust_birthday, cust_address, cust_phoneno)
VALUES
(arr_rec_1(n_idx1).v_cust_firstname, arr_rec_1(n_idx1).v_cust_lastname,
arr_rec_1(n_idx1).v_cust_persnumcode, arr_rec_1(n_idx1).v_cust_birthday,
arr_rec_1(n_idx1).v_cust_address, arr_rec_1(n_idx1).v_cust_phoneno);
END LOOP;
CLOSE cur_1;
COMMIT;
END;That procedure is based on the SQL query that I start to ply with in order to understand how to get the information from XML using SQL (the XML is hard-coded)
SELECT extractvalue(column_value, '/PERS_INFO/firstname') "First Name",
extractvalue(column_value, '/PERS_INFO/lastname') "Last Name",
extractvalue(column_value, '/PERS_INFO/social_security_no') "Social Security No",
extractvalue(column_value, '/PERS_INFO/birthday') "Birth-day",
extractvalue(column_value, '/PERS_INFO/address') "Address",
extractvalue(column_value, '/PERS_INFO/phoneno') "Phone No"
FROM TABLE(XMLSequence(
XMLTYPE(
'<?xml version="1.0" encoding="ISO-8859-1"?>
<doc>
<PERS_INFO>
<lastname>John</lastname>
<firstname>Doe</firstname>
<social_security_no>1800325171545</social_security_no>
<birthday>25/03/1980</birthday>
<address>Principal, 15</address>
<phoneno>0040722222222</phoneno>
<acc>
<transaction>200</transaction>
<transaction>150</transaction>
<transaction>-23</transaction>
</acc>
<acc>
<transaction>450</transaction>
</acc>
<acc>
<transaction>800</transaction>
<transaction>320</transaction>
<transaction>-125</transaction>
</acc>
</PERS_INFO>
<PERS_INFO>
<lastname>Smith</lastname>
<firstname>Pop</firstname>
<social_security_no>2851211173377</social_security_no>
<birthday>11/12/1985</birthday>
<address>FirstAvenue, 20</address>
<phoneno>0040744444444</phoneno>
<acc>
<transaction>444</transaction>
<transaction>550</transaction>
</acc>
<acc>
<transaction>113</transaction>
<transaction>-50</transaction>
<transaction>89</transaction>
</acc>
<acc>
<transaction>300</transaction>
</acc>
</PERS_INFO>
</doc>').extract('/doc/PERS_INFO'))) t;My problem is that query goes only at the first level (the customer level). I don't know how to get to the second/third level (account/transactions level).
Now, that query return:
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444and I want it to return like this:
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 1 200
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 1 150
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 1 -23
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 2 450
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 3 800
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 3 320
Doe John 1800325171545 25/03/1980 Principal, 15 0040722222222 3 -125
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 1 444
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 1 550
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 2 113
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 2 -50
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 2 89
Pop Smith 2851211173377 11/12/1985 FirstAvenue, 20 0040744444444 3 300What I have to do to that SQL query to get the result at the transaction level (as in the second table)? That XML can be subject of improvement as well. If another structure serve better for my purpose, please let me know.
Thanks!As [url http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions061.htm#SQLRF06173]extractvalue is deprecated in your version, you need to switch to another method as the documentation suggests.
Going forward with that, here is a starter SQL that gives you the desired output
WITH INS_STG1 AS
(SELECT XMLTYPE('<?xml version="1.0" encoding="ISO-8859-1"?>
<doc>
<PERS_INFO>
<lastname>John</lastname>
<firstname>Doe</firstname>
<social_security_no>1800325171545</social_security_no>
<birthday>25/03/1980</birthday>
<address>Principal, 15</address>
<phoneno>0040722222222</phoneno>
<acc>
<transaction>200</transaction>
<transaction>150</transaction>
<transaction>-23</transaction>
</acc>
<acc>
<transaction>450</transaction>
</acc>
<acc>
<transaction>800</transaction>
<transaction>320</transaction>
<transaction>-125</transaction>
</acc>
</PERS_INFO>
<PERS_INFO>
<lastname>Smith</lastname>
<firstname>Pop</firstname>
<social_security_no>2851211173377</social_security_no>
<birthday>11/12/1985</birthday>
<address>FirstAvenue, 20</address>
<phoneno>0040744444444</phoneno>
<acc>
<transaction>444</transaction>
<transaction>550</transaction>
</acc>
<acc>
<transaction>113</transaction>
<transaction>-50</transaction>
<transaction>89</transaction>
</acc>
<acc>
<transaction>300</transaction>
</acc>
</PERS_INFO>
</doc>') xml_column FROM DUAL
-- The above simulates your table. Only the below matters.
SELECT xt.First_Name, xt.birth_day, xt2.acc_rn, xt3.trans
FROM INS_STG1,
XMLTable('/doc/PERS_INFO'
PASSING INS_STG1.xml_column
COLUMNS
First_Name VARCHAR2(20) PATH 'firstname',
Birth_day VARCHAR2(10) PATH 'birthday',
acc_xml XMLType PATH 'acc') xt,
XMLTable('/acc'
PASSING xt.acc_xml
COLUMNS
acc_rn FOR ORDINALITY,
tran_xml XMLTYPE PATH 'transaction') xt2,
XMLTable('/transaction'
PASSING xt2.tran_xml
COLUMNS
trans NUMBER PATH '.') xt3;producesFIRST_NAME BIRTH_DAY ACC_RN TRANS
Doe 25/03/1980 1 200
Doe 25/03/1980 1 150
Doe 25/03/1980 1 -23
Doe 25/03/1980 2 450
Doe 25/03/1980 3 800
Doe 25/03/1980 3 320
Doe 25/03/1980 3 -125
Pop 11/12/1985 1 444
Pop 11/12/1985 1 550
Pop 11/12/1985 2 113
Pop 11/12/1985 2 -50
Pop 11/12/1985 2 89
Pop 11/12/1985 3 300Now ... there is probably a better XQuery way to pull that off, but I'll save that example for someone better at XQuery than myself.
I will also include that it is possible all this work could be done in a single SQL statement as shown by
[url http://odieweblog.wordpress.com/2012/05/10/how-to-load-xml-data-into-multiple-tables/]How To : Load XML data into multiple tables -
Problems in Retrieve Server's Data from Client through RMI
//I feel that this question quite challenging for me. maybe it is easy for you all. anyway, so anybody if know it, pls point out my mistake and give some opinion on my programs.thanks....
/*I have written one retrieve method in my server that is going to
be called by the client�s pc. But I am facing the error when
running
it. The error is � SQL Error in retrieve statemet:
[Microsoft][ODBC
Microsoft Access
Driver] Data type mismatch in criteria expression.� So anybody
know
where is my mistakes? Is it my server retrieveData method wrong? Or
my client is calling not properly? Thanks.
Actually my expected result is when client pc input the particular
staff id , then the client textfield will show all the information
of that particular staff according to the input id to the client
interface text field. */
******************* Interface *****************************
public interface RemoteDBServer extends
java.rmi.Remote //RemoteDBServer interface
public String retrieveData(String idd, String ln, String
fn, String op, String oe, String hp, String ps, String ss) throws
java.rmi.RemoteException;
*************** Server Program ***********************************
//id, last_name, first_name, office_phone, office_ext��..is a
table�s attribute name
//the jdbc and odbc path already been set in control panel �
administrative tools.
public String retrieveData(String idd) throws
java.rmi.RemoteException
String result=" ";
try
//create a statement
Statement statement = connection.createStatement();
String sql="SELECT * FROM emp_overview WHERE id ='"+idd+"'";
//execute quury and capture results
ResultSet rs = statement.executeQuery(sql);
rs.next();
String ln = rs.getString("last_name");
String fn = rs.getString("first_name");
String op = rs.getString("office_phone");
String oe = rs.getString("office_ext");
String hp = rs.getString("home_phone");
String ps = rs.getString("primary_skill");
String ss = rs.getString("secondary_skill");
statement.close();
catch (SQLException sqlex)
System.out.println("SQL Error in retrieve statement: "
+sqlex);
sqlex.printStackTrace();
return result;
****************************Client Program ************************
..............����
//findName already declared in JButton
//tln, tfn, top, toe�..already declared in JTextField
else if (event.getSource() == findName)
try
db.retrieveData(tid.getText());
tln.setText("");
tfn.setText("");
top.setText("");
toe.setText("");
thp.setText("");
tps.setText("");
tss.setText("");
catch(Exception e)
System.out.println ("Cant delete to server " + e);Hi Kevin,
It looks like your id field is of Numeric datatype and you are wrapping it with single quotes in your query, which is not correct.
Your wrote :
String sql="SELECT * FROM emp_overview WHERE id ='"+idd+"'";
If id is of type numeric data type then, use:
String sql="SELECT * FROM emp_overview WHERE id ="+idd;
regards,
Humayun -
How to insert data from APEX form into two tables
Hi,
I'm running APEX 4.1 with Oracle XE 11g, having two tables CERTIFICATES and USER_FILES. Some of the (useless) fields are cut to reduce information:
CREATE TABLE CERTIFICATES
CERT_ID NUMBER NOT NULL ,
CERT_OWNER NUMBER NOT NULL ,
CERT_VENDOR NUMBER NOT NULL ,
CERT_NAME VARCHAR2 (128) ,
CERT_FILE NUMBER NOT NULL ,
) TABLESPACE CP_DATA
LOGGING;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_PK PRIMARY KEY ( CERT_ID ) ;
CREATE TABLE USER_FILES
FILE_ID NUMBER NOT NULL ,
FILENAME VARCHAR2 (128) ,
BLOB_CONTENT BLOB ,
MIMETYPE VARCHAR2 (32) ,
LAST_UPDATE_DATE DATE
) TABLESPACE CP_FILES
LOGGING
LOB ( BLOB_CONTENT ) STORE AS SECUREFILE
TABLESPACE CP_FILES
STORAGE (
PCTINCREASE 0
MINEXTENTS 1
MAXEXTENTS UNLIMITED
FREELISTS 1
BUFFER_POOL DEFAULT
RETENTION
ENABLE STORAGE IN ROW
NOCACHE
ALTER TABLE USER_FILES
ADD CONSTRAINT CERT_FILES_PK PRIMARY KEY ( FILE_ID ) ;
ALTER TABLE CERTIFICATES
ADD CONSTRAINT CERTIFICATES_USER_FILES_FK FOREIGN KEY
CERT_FILE
REFERENCES USER_FILES
FILE_ID
NOT DEFERRABLE
What I'm trying to do is to allow users to fill out all the certificate data and upload a file in an APEX form. Once submitted the file should be uploaded in the USER_FILES table and all the fields along with CERT_ID, which is the foreign key pointing to the file in the USER_FILES table to be populated to the CERTIFICATES table. APEX wizard forms are based on one table and I'm unable to build form on both tables.
That's why I've created a view (V_CERT_FILES) on both tables and using INSTEAD OF trigger to insert/update both tables. I've done this before and updating this kind of views works perfect. Here is where the problem comes, if I'm updating the view all the data is updated correctly, but if I'm inserting into the view all the fields are populated at CERTIFICATES table, but for USER_FILES only the fields FILE_ID and LAST_UPDATE_DATE are populated. The rest three regarding the LOB are missing: BLOB_CONTENT, FILENAME, MIMETYPE. There are no errors when running this from APEX, but If I try to insert into the view from SQLDeveloper, I got this error:
ORA-22816: unsupported feature with RETURNING clause
ORA-06512: at line 1
As far as I know RETURNING clause in not supported in INSTEAD of triggers, although I didn't have any RETURNING clauses in my trigger (body is below).
Now the interesting stuff, after long tracing I found why this is happening:
First, insert is executed and the BLOB along with all its properties are uploaded to wwv_flow_file_objects$.
Then the following insert is executed to populate all the fields except the BLOB and it's properties, rowid is RETURNED, but as we know RETURNING clause is not supported in INSTEAD OF triggers, that's why I got error:
PARSE ERROR #1918608720:len=266 dep=3 uid=48 oct=2 lid=48 tim=1324569863593494 err=22816
INSERT INTO "SVE". "V_CERT_FILES" ( "CERT_ID", "CERT_OWNER", "CERT_VENDOR", "CERT_NAME", "BLOB_CONTENT") VALUES (:B1 ,:B2 ,:B3 ,:B4, ,EMPTY_BLOB()) RETURNING ROWID INTO :O0
CLOSE #1918608720:c=0,e=11,dep=3,type=0,tim=1324569863593909
EXEC #1820672032:c=3000,e=3168,p=0,cr=2,cu=4,mis=0,r=0,dep=2,og=1,plh=0,tim=1324569863593969
ERROR #43:err=22816 tim=1324569863593993
CLOSE #1820672032:c=0,e=43,dep=2,type=1,tim=1324569863594167
Next my trigger gets in action, sequences are generated, CERTIFICATES table is populated and then USER_FILES, but only the FILE_ID and LAST_UPDATE_DATE.
Finally update is fired against my view (V_CERT_FILES), reading data from wwv_flow_files it populates BLOB_CONTENT, MIMETYPE and FILENAME fields at the specific rowid in V_CERT_FILES, the one returned from the insert at the beginning. Last, file is deleted from wwv_flow_files.
I'm using sequences for the primary keys, this is only the body of the INSTEAD OF trigger:
select user_files_seq.nextval into l_file_id from dual;
select certificates_seq.nextval into l_cert_id from dual;
insert into user_files (file_id, filename, blob_content, mimetype, last_update_date) values (l_file_id, :n.filename, :n.blob_content, :n.mimetype, sysdate);
insert into certificates (cert_id, cert_owner, cert_vendor, cert_name, cert_file) values (l_cert_id, :n.cert_owner, :n.cert_vendor, :n.cert_name, l_file_id);
I'm surprised that I wasn't able to find a valuable source of information regarding this problem, only MOS note about running SQLoader against view with CLOB column and INSTEAD OF trigger. The solution would be to ran it against base table, MOS ID 795956.1.
Maybe I'm missing something and that's why I decided to share my problem here. So my question is how do you create this kind of architecture, insert into two tables with a relation between them in APEX ? I read a lot in the Internet, some advices were for creating custom form with APEX API, create a custom ARP, create two ARP or create a PL/SQL procedure for handing the DML?
Thanks in advance.
Regards,
SveThank you however I was wondering if there was an example available which uses EJB and persistence.
Maybe you are looking for
-
Not very user friendly! Where is the place to report a problem!? I have been billed for an in-app purchase but not had the goods - I received an error message telling my I hadn't been charged at the time and now it is on my bill! What can I do?
-
It's not backing up all my data
Yesterday I started backing up on Time Capsule. I used an ethernet cable to my iMac and followed the directions in the Setup Guide. When it began it said that 112 GB would be backed up but my sparse bundle is only 26 GB. It seems to be doing hourly b
-
Getting current(small shock) while charging from new ipod touch 4!!
i got a new ipod touch 4 today.when i use it while charging i am feeling a small current flow through the back cover.some body please help me out..........is it normal or something wrong with the ipod?
-
How to check whether a field contains at least one numeric value
how to check whether a field contains at least one numeric value..
-
hi, Hi, In a custom trasaction , I have text element . When I transport that text upper regions , I am not able to see in transaction. But I can see that text in the Text-symbols( Program->GOTO--> text-symbols) let me know any suggestions. thnks.