Wanted to fetch data from ref cursor to nested pl/sql table getting an erro
create or replace type "DEPT12" as object(dno number(2),dname varchar2(30),loc varchar2(50));
create or replace type dept_tab as table of "DEPT12"
create or replace type "LOC12" as object(locno number,loc_name varchar2(100))
create or replace type loc_tab as table of "LOC12"
create or replace type dept_loc_rec1 as object (dept_dt dept_tab,eno number,loc_dt loc_tab);
create type dept_loc_tb as table of dept_loc_rec1
create table dept_loc_tb_bk1(dept_dt dept_tab,eno number,loc_dt loc_tab)
NESTED TABLE dept_dt
STORE AS dept_tab12,
NESTED TABLE loc_dt
STORE AS loc_tab12
insert into dept_loc_tb_bk1 values(dept_tab(dept12(3,'ABD','LOC')
,dept12(4,'ABD','LOC')
,dept12(5,'ABD','LOC')),3,loc_tab(loc12(21,'AAB'),
loc12(22,'AAB'),
loc12(23,'AAB')));
when I am trying to fetch data from ref cursor to pl/sql table which i am getting an error ora-06504: pl/sql : Return types of result set variables or query do not match.
I have created a nested table of same as the nested pl/sql object table dept_loc_tb and i have declared the lv_dept_loc_tb of same dept_loc_tb but getting an above error when trying to fetch into that variable.
Please any one who can solve my problem.
declare
type cr is ref cursor;
cr_obj cr;
lv_dept_loc_tb dept_loc_tb;
begin
open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
fetch cr_obj bulk collect into lv_dept_loc_tb;
close cr_obj;
end;
Your query selects 3 separate columns therefore requires 3 collections of corresponding types. You want to treat those 3 columns as an object of DEPT_LOC_REC1 type:
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
declare
ERROR at line 1:
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
ORA-06512: at line 9
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select DEPT_LOC_REC1(dept_dt,eno,loc_dt) from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
PL/SQL procedure successfully completed.
SQL> SY.
P.S. Discover sys_refcursor.
Similar Messages
-
How to fetch data from XML and store it in internal table
Hi All,
Can anyone help me out, in fetching data from xml and store it in an internal table. Is there any standard function module is there?
Regards,
Karthickto do this you can either develop a XSLT program and use it with CALL TRNSFORMATION key word to tranform the XML into itab .
(search the ABAP General forum, i have posted few samples)
or simply use the following FM which converts your XML into a itab of name value pair (name would holw the element name and value would hold the value of the element) which you can then loop and read it to your itb.
data: xmldata type xstring .
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xmldata
TABLES
xml_table = result_xml
return = return .
Regards
Raja -
The data from my web page insert in SQL table as question marks
I use Farsi language in my web page for inserting customer data. The data that is inserted in webpage and submitted, showed as ???? in SQL table. A lot of developers say that I should use N' before the Unicode character, but I don't know how I can use it
in my code. I attached the code. Can someone say me where I should insert the N in my code?
protected void cmdInsert_Click(object sender, EventArgs e)
//Checking the validation of required fields
if (cboCustomerType.Text == "" || cboTitle.Text == "" || SearchableName.Text == "" ||
FinalName.Text == "" || NationalID.Text == "" || BusinessID.Text == "" || MobilePhone.Text == "")
lblStatus.Text = "لطفا فیلدهای اجباری را حتما پر کنید";
return;
//define ADO.NET objects.
string insertSQL;
insertSQL = "INSERT INTO Customers(";
insertSQL += "CustomerType,CustomerTitle,CustomerFirstName,CustomerLastName,CompanyType,";
insertSQL += "CompanyName,SearchableName,FinalName,NationalCode,BusinessID,City,Address,PostalCode,";
insertSQL += "Zone,MobileNumber,WorkPhone1,WorkPhone2,HomePhone,FaxNumber,Email,Website,Note)";
insertSQL += "VALUES('";
insertSQL += cboCustomerType.Text + "','";
insertSQL += cboTitle.Text + "','";
insertSQL += CustomerFirstName.Text + "','";
insertSQL += CustomerLastName.Text + "','";
insertSQL += cboCompanyType.Text + "','";
insertSQL += CompanyName.Text + "','";
insertSQL += SearchableName.Text + "','";
insertSQL += FinalName.Text + "','";
insertSQL += NationalID.Text + "','";
insertSQL += BusinessID.Text + "','";
insertSQL += City.Text + "','";
insertSQL += Address.Text + "','";
insertSQL += PostalCode.Text + "','";
insertSQL += Zone.Text + "','";
insertSQL += MobilePhone.Text + "','";
insertSQL += Phone1.Text + "','";
insertSQL += Phone2.Text + "','";
insertSQL += HomePhone.Text + "','";
insertSQL += FaxNumber.Text + "','";
insertSQL += Email.Text + "','";
insertSQL += Website.Text + "','";
insertSQL += Note.Text + "')";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(insertSQL, con);
//try to open the database and execute the insert
int added = 0;
try
con.Open();
added = cmd.ExecuteNonQuery();
lblStatus.Text = added.ToString() + "اضافه شد";
catch (Exception err)
lblStatus.Text = "Error inserting record.";
lblStatus.Text += err.Message;
finally
con.Close();
//If the insert succeed, refresh the customer list.
if (added > 0)
FillCustomerList();
Regards,Because you're composing the SQL statement with string concatenation, you would put the "N" before the single quote,
VALUES(N'";
insertSQL += cboCustomerType.Text + "',N'";
insertSQL += cboTitle.Text + "',N'"; // ...etc
However, composing SQL statements with string concatenation is not a suggested practice because it's open to SQL injection (see:
https://technet.microsoft.com/en-us/library/ms161953(v=sql.105).aspx). A safer way to do this is to use command parameters to represent the values (see SqlCommand.Parameters
property). If you use parameters, you can specify parameter data type as SqlDbType.NVarchar, which will ensure your text values are passed in as Unicode. Also ensure that the columns in question are defined in the database table definition as Unicode (NVARCHAR
rather than VARCHAR).
Hope this helps, Bob -
Want to fetch data from AFVU table with input of order number from AUFK table
Hi,
I have a requrement in report where in the user wil enter the order number from AUFK table and it should display detais like job code condition code (from AFVU table) along with other fields. There is no relation ship between AFVU and AUFK. Can anybody help me in getting the replation ship between 2 tables. What is the table that iam missing and where can i find that relationship and fetch records for that order number?Check if this helps..
AUFK -> AFKO -> AFVU
AUFK-AUFNR = AFKO-AUFNR
AFKO-AUFPL = AFVU-AUFPL
Hope this helps. -
How to fetch data from single database table using 2 internal tables.
Hi friends,
i am a new user of ABAP and also SDN.
i need a help.
i want to fetch data from one database table based on primary keys of 2 internal tables. how to put in where clause.
Thanks in advance.hii
refer to following code ..i hope it will help you
SELECT matnr " Material Number
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
IF i_mara[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
prctr " Profit Center
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND werks IN s_werks.
ENDIF. " IF i_mara[] IS NOT INITIAL
i_output = i_marc.
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
regards
twinkal -
Fetching data from a table and displaying it on the text box
Hi,
I have created a dialog program in which created a container(text box) to enter data upto 1000 characters.
Iam capturing the data and storing it in a custom table. In PBO I want to fetch data from my custom table (if data is already present :1000 characters data) and display it on screen.
Please let me know how do i do it?hii Pavani,
declare this two sttements in Screen
MODULE STATUS_DATA.
MODULE SELECT_DATA.
In PBO, Under SELECT_DATA write Select query like:
(considering the DB field to be text and Screen Field to be SC_TEXT)
select text from <DB Table> into SC_TEXT where <condition>.
*note if u r selecting more than one field than write fields in ( ),eg. (f1....f2) )
Plz let me know for any further queries.
Regards,
Apoorv -
How to fetch data from DataBase using Servlet ?
Hi all,
Till now, i was just sending values from web page and receive the data in excel format using servlets.
But, now, i want to fetch data from data base. I will be giving inputs in the web page(for the query)....ON click of submit button,
Servlet should be called.
Depending on the input, query has to be executed, and response should be sent to the user.
How to do it?
Code
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
/** Simple servlet that reads three parameters from the html
form
public class Fetchdata extends HttpServlet
String query=new String();
String uid="ashvini";
String pwd="******";
try
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
response.setContentType("application/vnd.ms-excel");
ServletOutputStream out=response.getOutputStream();
out.println("<HTML>" +"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" +" <th>ITEM Code</th>");
while(rs.next())
out.println("<tr><td>" rs.getString(1).trim()"</tr></td>");
}//end of while
out.println("</table></BODY></HTML>");
}//end of doGet method
}catch(Exception e)
System.out.println(e);
It is giving error message as:
C:\Program Files\Apache Tomcat 4.0\webapps\general\srvlt>javac Fetchdata.java
Fetchdata.java:17: illegal start of type
try
^
Fetchdata.java:48: <identifier> expected
^
2 errors
Is this format is correct? am i placing this doGet method at the right place? is my program's logic is correct?
Please help me?
Regards
AShviniThere is some mistakes in ur code.....how can try catch exists outside a function???
make use of try catch isde ur doGet method and put
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
isdie doGet method, for the time being,
i think u get me..
regards
shanu -
Fetch data from another mirosoft sql server to sap
Dear all,
I want to fetch data from another mirosoft sql server
to SAP(my sap server IN unix, oracle 10g).
Thanks
Shashi
Moderator Message: Try to do you own research before posting your question. Get back to the forums in case you are stuck with any issue
Edited by: Suhas Saha on Jul 26, 2011 3:21 PMhi,
u should see following documentation:
Oracle9i Heterogeneous Connectivity Administrator's Guide
Release 1 (9.0.1)
Part Number A88789_01
in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
regards
umar -
How to fetch data from database in javafx 2.2 table which is editable.
Dears!
I want to fetch data from database in javafx 2.2 tableformat with jdbc , which is also editable and i can add more records in this table also.
Can anybody help meI can vaguely recall some sort of JavaFX database connectivity feature, I'm not sure if it's valid anymore.The link is based on JavaFX Composer which only applied to NetBeans 6.9 and JavaFX 1.x (both of which are now dead techs).
There is a good chance you will have to write your own. There are several blogs describing other peoples' work. You could probably use them as a reference.Here is Narayan's basic [url http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] tutorial for displaying data from a database in a TableView, you'll need to look elsewhere for the editing portion.
The [url http://docs.oracle.com/javafx/2/ui_controls/table-view.htm]JavaFX TableView tutorial gives info about how to handle edits in a TableView, but you will need to tie the updates back to the database yourself.
It is possible that [url http://www.javafxdata.org/]DataFX may provide some facilities to help support you. -
Fetch data from n tables mdb file
hello,
I am able to fetch data from n no. of columns in a table but i want to fetch data from n no. of tables as well... below is part of the code:
while (res.next())
for(int j=1;j<=tbn;j++) --- tbn no.of tables
System.out.println("table counter");
for (int i = 1; i <= cno; i++) --- cno no. of columns
phno = res.getString(i);
v = new Vector();
v.addElement(phno);
System.out.println(v);
}wow thanks for quick reply,,, i would like to fetch data from atleast 2 tables ...below is my code.... its printing the last row of the second table
public Vector msdata(String filepath)
String databaseFolder=filepath;
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+filepath;
String userNameFromDB = "", pwdFromDB = "";
try
Class.forName(driver);
conn = DriverManager.getConnection(url,"","");
stmt = conn.createStatement();
DatabaseMetaData dbmd = conn.getMetaData();
String[] types = {"TABLE"};
String colnum = null;
ResultSet tables = dbmd.getTables(null, null,"%", types);
// Get the table names
while (tables.next())
// Get the table name
tableName = tables.getString(3);
tbn++;
System.out.println("Table Name: " + tableName);
res = stmt.executeQuery("select * from "+tableName);
ResultSetMetaData resultsMD = res.getMetaData();
cno = resultsMD.getColumnCount() ;
System.out.println("number of columns: " + cno);
System.out.println("number of tables: " +tbn);
while (res.next())
for(int j=1;j<=tbn;j++)
while (res.next())
//System.out.println(tbn);
for (int i=1; i<= cno;i++)
phno = res.getString(i);
System.out.println(phno);
v = new Vector();
v.addElement(phno);
System.out.println(v);
res.close();
tables.close();
stmt.close();
conn.close();
catch(Exception ee)
System.out.println("driver error............");
ee.printStackTrace();
return v;
} -
How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
AnwarSELECT * FROM emp SUBPARTITION(sp1);
-
Fetching data from multiple datasources
Hi,
I want to fetch data from different datasources to a single cube.
What would be the pre-requisites for carriying out the activity.
Awaiting kind advise.
Thanks
Edited by: gskitu on Mar 7, 2012 6:51 PMHi
There r no prerequisites to your requirement . How ever we have different data flows for your requirement as 1. multiple data source to different info sources or transformations to a single cube 2. multiple data sources to single info source or transformation to a single info cube . Any way regarding data flow complexity , second approach is easier one ......
Thanks.
Rajendra. -
I want to fetch data from two tables which are in two separate database. Is it possible to fetch similar from two schemas of same database.
Pls help with query.Hi,
Say you have two schema S1 and S2 in the same database 'xyz' then you can create two database links to these two schemas from any third schema as ::
CREATE database link s1link connect to S1 identified by <password of S1> using 'xyz' ;
CREATE database link s2link connect to S2 identified by <password of S2> using 'xyz' ;
Now say if there is a table called tab1 in schema S1, then you can get data from it as ::
SELECT T1.*
FROM tab1@s1link T1
WHERE < you can put conditions here> ;
Similarly for the columns of a table of schema S2.
- Thanks
Sandipan -
To Fetch data from r/3?
Hi
I am new to SAP
I have created one table according to the table we have in r/3, now I want to know how we store data and also want to fetch data from r/3. There are the use of BAPI, but I dont know how to use.
!!!!!!!!!!Points assured!!!!!!!!!!!!In order to transfer data between R/3 and MDM you can use one of a few different methods. Unfortunately you cannot use traditional ALE because MDM is a completely different architecture than R/3, and does not support ALE (hopefully it will in the future).
(1) But currently you can either integrate those two products using XI, if you choose to do that, you may want to check out a three part weblog series on a sample scenario of this:
<a href="/people/harrison.holland5/blog/2006/11/27/mdm-syndication 1</a>, <a href="/people/harrison.holland5/blog/2006/12/20/xi-configuration-for-mdm-integration--sample-scenario 2</a>, <a href="/people/harrison.holland5/blog/2007/01/22/testing-and-monitoring-an-interface-between-mdm-xi 3</a>
(2) Or you can use the API's that SAP built for MDM. There is an ABAP API and a JAVA API. The ABAP API seems to have the most documentation. You can find documentation on the ABAP API here:
https://websmp203.sap-ag.de/~sapidb/011000358700004121872006E
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/masterDataManagement
Good luck -
Error in fetching data from DB to Matrix
hi everyone...i want to fetch data from Db and sisplay it on matrix..i tried this way..but i'm not getting data..it is saying that invalid row index..what should i give at row value...
Try
oitem = oForm.Items.Item("8") ''''8 is uid of matrix
oMatrix = oitem.Specific
oColumns = oMatrix.Columns
rset = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
query = "select * from [@VIDS_MGT]" '
rset.DoQuery(query)
oMatrix.FlushToDataSource()
Catch ex As Exception
End Try
Dim i As Integer = 1
While Not rset.EoF
Try
oMatrix.AddRow()
oMatrix.Columns.Item("V_0").Cells.Item(i).Specific.value = rset.Fields.Item("Code").Value
i = i + 1
rset.MoveNext()
Catch ex As Exception
SBO_Application.MessageBox(ex.ToString)
End Try
End While
oMatrix.LoadFromDataSource()Hello,Shehnaaz
While binding data to matrix u have to use datasources
Steps
1.Create one datasourece
Declare
assign ur matrix table like this
oDB_Row = oForm.DataSources.DBDataSources.Item("@VEDA_TC_DLN")
2. Give here loop
rs.MoveFirst()
For I = 1 To rs.RecordCount
oMatrix.AddRow()
oDBs_Head.SetValue("LineID", oDBs_Head.Offset, oMatrix.VisualRowCount)
oDBs_Head.SetValue("U_BobNo", oDBs_Head.Offset, rs.Fields.Item("U_BobNo").Value)
oDBs_Head.SetValue("U_CovSze", oDBs_Head.Offset, rs.Fields.Item("U_CovSze").Value)
oDBs_Head.SetValue("U_BrWid", oDBs_Head.Offset, rs.Fields.Item("U_BrWid").Value)
oDBs_Head.SetValue("U_BrThi", oDBs_Head.Offset, rs.Fields.Item("U_BrThi").Value)
oDBs_Head.SetValue("U_Flex", oDBs_Head.Offset, rs.Fields.Item("U_Flex").Value)
oDBs_Head.SetValue("U_Adh", oDBs_Head.Offset, rs.Fields.Item("U_Adh").Value)
oDBs_Head.SetValue("U_Elog", oDBs_Head.Offset, rs.Fields.Item("U_Elog").Value)
oDBs_Head.SetValue("U_UTS", oDBs_Head.Offset, rs.Fields.Item("U_UTS").Value)
oDBs_Head.SetValue("U_Hard", oDBs_Head.Offset, rs.Fields.Item("U_Hard").Value)
oDBs_Head.SetValue("U_BDVRt", oDBs_Head.Offset, rs.Fields.Item("U_BDVRt").Value)
oDBs_Head.SetValue("U_BDVEt", oDBs_Head.Offset, rs.Fields.Item("U_BDVEt").Value)
oDBs_Head.SetValue("U_Scrap", oDBs_Head.Offset, rs.Fields.Item("U_Scrap").Value)
oDBs_Head.SetValue("U_Aprvd", oDBs_Head.Offset, rs.Fields.Item("U_Aprvd").Value)
oDBs_Head.SetValue("U_BsLineId", oDBs_Head.Offset, InsBaseRow)
oDBs_Head.SetValue("U_BsDoc", oDBs_Head.Offset, InsBaseDoc)
oMatrix.SetLineData(oMatrix.VisualRowCount)
rs.MoveNext()
Next
3.Try to under stand setline data is very important if did nt mension set line data means that will not display any data
Hope this will help u
By
Firos
Maybe you are looking for
-
I lost the speaker sound suddenly while listening to a previously aired radio program. Cannot hear any sounds on my Apple 4S iPhone since it happened. Cannot even hear Siri anymore. Can only hear any sound at all using my ear buds. No speaker sound w
-
Compatability with Java 5 EE Web Services
I am new to Flash 8. I am trying to consume a web service that is running on my Java EE 5 (GlassFish) application server. First, can anyone comment on compatability of Flash 8 with web services not created with Cold Fusion. I am able to connect and e
-
I am trying to sync my Iphone contacts and mail settings. I have synced the music and photos using itunes but when I go to sync the contacts I get the error message saying that sync could not continue because sync is not enabled. I have gone to prefe
-
Mt Lion with USB devices that worked in Snow Leopard?
just upgraded to Mt Lion and my Maxtor mini external drive (USB) isn't recognized on the desktop I can see it in USB lists I downloaded software from the Seagate website, etc etc still nothing help! all of my backups are on the drive
-
why dows not someone create an app that you can send sms and calls from the windows 8 (pc or tablet) through the phone plan (also using windows 8) using carrier plan (sms from monthly plan or minutes)? if you are logged with the same user on the wp a