Can I use stored procedures to improve data retrieval from the database?
I have been requested to get multiple pieces of data from multiple tables and return the output in an array for use in a Java program.
Eliminating multiple calls to the database. Currently, the data is retrieved from the database in multiple steps but to eliminate
possible bottlenecks in the future, I created several complex sql statements.
For instance,
In the first table there are 20 columns of data. has a column named type which can have the one of these values: line, inn, or bsc
In the second table there are 6 columns of data. has the additional data for type line
In the third table there are 7 columns of data. has the additional data for type inn
In the fourth table there are 2 columns of data. has data regardless of type
etc...
Depending on a specific column value retrieved (inn) from the first table:
I need to collect all 20 columns in the first table and get all the columns in third table and the columns in the fourth table, etc.
Question: How can I remove the duplicate primary key columns without specifying for each table the column names to be returned?
I used the wildcard SELECT * because I didn't want to have to update the retrieval methods if additional columns are added to these
secondary tables.
example of my sql for type inn data:
select * from first_table f, third_table s, fourth_table t
where (f.column1='xxxx' and f.column2='xxxx') (the 'xxxx' are passed into the sql statement)
and
((s.column1=f.column1 and s.column2=f.column2)
and
(f.column3=t.column1));
Currently, I've duplicated the separate sqls for each valid type found in the first table (at least a dozen types). The only difference is
the table name. Instead of the third table I use the second table, etc.
The MAIN Question: How can I set this up to have one sql to handle each type? I want to eliminate having over a dozen duplicated sqls. Can I
incorporate this into a stored procedure or something? If so, how? Can anyone provide sample coding?
Your help is very much appreciated. Thank you.
GD
Hi, Salah.
Use "Exec" in your query to run procedures.
SAPbobsCOM.Recordset oRS;
oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
oRS.DoQuery ("EXEC YourStoredProcName");
Triggers are not supported in SDK.
Regards,
Aleksey
Similar Messages
-
Sub report using Stored Procedure returns incorrect data
Post Author: rikleo2001
CA Forum: Data Connectivity and SQL
Guys,
I am using CR 9 in ASP.net application.
One simple report and one Sub report, sub report is basically linked with Stored procedure accepting one parameter and returns a select query.
Main report is linked with that sub report using that parameter field.
Sub report is on demand sub report.
Now when I execute that main report and click on on demand sub report I am getting Wrong order information.
Here is out put on main report
Order 1 on demandDetail
Order 2 on demandDetail
Order 3 on demandDetail
NOW If I click on Order 3 (On demanddetail link, it displays rondom order details, some time correct on too), I am really stuck and don't know where I am going wrong.
Please help me to solve this issues.
Many ThanksPost Author: rikleo2001
CA Forum: Data Connectivity and SQL
Hi Yangster,
Thank you so much for your reply.
On DEMAND Sub report is located in main report, IN DETAIL SECTION
I am passing Order ID from main report linked to {?morderid} in subreport under command object, and if I run it in design mode, it works perfectly alright, so problem is isolated to ASP.NET and Crystal report post back method on Crystal report.
The example I give to you this is a simple example to identify issues in my real application and report.
My main report contains summary of data base on unique identifier. that summary have 4 differant types of details which has to be on the same report (as Crystal report doesn't provide Nested subreport), so I decided to use 4 subreports on main report and all subreport using Stored procedure command object.(Sub report has it own complex processing requirement to fulfill).
Please help me with any further ideas? for the sample which I presented to you this is only using one SP on main report with a simple processing.
Many Thanks -
Can i use Stored procedures and triggers with SDK
hi all
How to use the stored procedure and Triggers with SDK, can i get a sample code
Regards
SalahHi, Salah.
Use "Exec" in your query to run procedures.
SAPbobsCOM.Recordset oRS;
oRS = (SAPbobsCOM.Recordset)pCmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
oRS.DoQuery ("EXEC YourStoredProcName");
Triggers are not supported in SDK.
Regards,
Aleksey -
Please help - Can not use stored procedure with CTE and temp table in OLEDB source
Hi,
I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata could not be determined because statement with CTE.......uses
temp table.
Please help me how to resolve this ?you write to the temp tables that get created at the time the procedure runs I guess
Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
You must set retainsameconnection to TRUE to be able to use the temp tables
Arthur My Blog -
I installed the 8 Ball app using my old ID I also redeemed a 25$ ITunes card, I want to buy more coins but can't using my new ID, also the password for my previous ID keeps me from updating the apps I have, there's Justine more thing, I have been asked to put a password for an ID I don't recognize
You can't delete iTunrd accounts, all you can do is remove personal info from them and stop using them - any content that you downloaded with an account will remain tied to it.
As apps are tied to the account, you can only make in-app purchases using the account that you bought the app with - so you will only be able to make in-app purchases using the old account.
For the app update, if you don't recognise the account id is showing for the app, then did somebody else download that app onto your iPad ? Only the account that bought/downloaded an app can download updates to its apps. -
HT3702 Can I use iTunes gift cards to purchase accessories from the apple store
I got a lot of iTunes cards for my birthday and I was wondering if I could use those credits in the apple store.
No, you can only use them in iTunes store, the App Store, ibookstore, and the Mac App Store, they can't be used in Apple stores (including online) to buy hardware.
-
We have a file that we are loading 1st into a staging database then into a production database that contains over 5 million rows. Both databases belong to a SQL Server 2012 AG. We would like to minimize the logging in the staging database but t
the same time keep the staging database in the AG. I know about fast load and setting the buffer settings in SSIS but I've read that this doesn't work on replicated tables and I am assuming that speaks to the AG.
Are there any articles or someone's personal experiences with this type of scenario that could point us in the right direction and offset some of the initial data load into staging by minimizing logging?
Thanks,
Sue
SueHi Sue,
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
IReport data retrieval from MySql database
Hi,
can anyone help me? i am using iReport - jasperreports to design a report using a datasource/ connections.
i designed my report and everything works fine except that the data of the fields in mthe detail band is been retrieved more than once making the reports to have one data printed more than once(as many as possible). In my quey, i even used the "order by" as specified in the iReport manual.
Questions: Is there to fix this so that i can have one data of a field printed only once witout repeatition in the detail band(that is, print one value then the next till the last value then stop)Play with the evaluated and printed when options. Another thing you should do is create a group whose evaluation string is the key from your database. every time this value changes as the records are being evaluated the detail section will be printed.
-
How to get the date fromat from the database?
I am using Oracle9i database and i want to get the format of the date that is stored in the database.
How do i do that?
Thanks,
Shrimonconcatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
or yo ucan use the fm:
HR_JP_MONTH_BEGIN_END_DATE
usage:
call function 'HR_JP_MONTH_BEGIN_END_DATE'
exporting
iv_date = sy-datum
importing
ev_month_begin_date = gv_begda
ev_month_end_date = gv_endda.
Regards,
Ravi
Message was edited by:
Ravi Kanth Talagana -
Using stored procedure with Oracle user-defined types in database control
Hi,
I have a requirement where I need to call an Oracle Stored Proc which has IN and OUT parameters. OUT parameters are of user-defined types in Oracle packages.
I am getting error while calling the Stored proc like below:
Procedure:
==========
create or replace
PROCEDURE AA_SAM_TEST (
col1 out types_aa.aa_tex_type ,
col2 out types_aa.aa_tex_type ,
col2 out types_aa.aa_num_type ) As
Types:
======
create or replace
package types_aa as
type aa_tex_type is table of varchar2(255) index by binary_integer;
type aa_num_type is table of char index by binary_integer;
end
Wli Code:
=========
DB Control:
===========
* @jc:sql statement="call AA_SAM_TEST(?,?,?)"
void Call_AA_SAM_TEST(SQLParameter[] param) throws SQLException;
JPD Code:
=========
param = new SQLParameter[3];
Object param1 = new String();
Object param2 = new String();
Object param3 = new String();
this.param[0] = new SQLParameter(param1 , Types.STRUCT, SQLParameter.OUT);
this.param[1] = new SQLParameter(param2, Types.STRUCT, SQLParameter.OUT);
this.param[2] = new SQLParameter(param3, Types.STRUCT, SQLParameter.OUT);
database_Update.Call_AA_SAM_TEST(this.param);
I am getting the following error...
<Jul 24, 2007 6:47:42 PM IST> <Warning> <WLW> <000000> <Id=database_Update; Method=Ctrl_files.Database_Update.Call_AA_SAM_TEST(); Failure=java.sql.SQLException: ORA-06553: PLS-:
ORA-06553: PLS-:
ORA-06553: PLS-:
ORA-06553: PLS-:
ORA-06553: PLS-:
ORA-06553: PLS-306: wrong number or typ
ORA-06553: PLS-306: wrong number or types of arguments in call to 'AA_SAM_TEST'
ORA-06553: PLS-306: wrong number or types of arguments in call to 'AA_SAM_TEST'
Can anyone know how to specify OUT parameter of USer-Defined types while using a DB control to access a Stored Proc in Oracle.
Any help is highly appreciated.
ThanksHi,
I have similar problem. Have you already solved the issue?
Thanks -
Entered DATA missing from the Database ( SEM CUBE )
Hi,
We are in the process of compiling the Annual Budget for 2011- 12. We
are using BW-BPS for capturing the data.
The Problem, is that we are not able see the Data entered in last two
days. The users have entered the data in SEM-BPS layouts and saved it.
Also they have executed the Queries through the Bex Analyzer which had
the data till yesterday evening, but today if the user tries to refresh
the query then the data is missing.
The name of BW SEM-CUBE is "ZUCOPA_TC".
Please suggest some solution.
Thanks
NileshNilesh,
someone might have run a delete function or another incorrectly configured planning function that deleted the data (or set records to zero).
First, STOP any compression jobs on your planning InfoCubes. (If any compression job with zero eliminiation ran the past two days, the data is probably lost for good).
Second, check in LISTCUBE if the data is still in the InfoCube. Make sure to select ALL fields for the output (including request id). If you are lucky, you will find all the deltas of changes that happened in the past days. If there was a delete (or similar) you should find these deltas, too. Now you can recreate the original data again (it's tedious but can be done).
Whatever the outcome, you should implement some operational improvements to your planning applications:
1) Create backup InfoCubes of your planning InfoCubes (fill with nightly DTP for example)
2) Implement audit log of planning activities (see how-to guides)
Both will give you a much better chance of recovering data in such cases.
Good luck,
Marc
SAP Techology RIG -
How to modify data recieved from the database and displayed in a DG
Hello, it's me again with a simple question :
i've got the SQLi request who returns multiples rows.
In this row i have for example :
Reward --> 1
How to, instead of displaying 1 in the datagrid, change this value to "YES"
I follow this lead :
private function onResultStats(event:ResultEvent):void
ServerStatsArr = new ArrayCollection(event.result.source);
for (var i:int=0; i < ServerStatsArr.length;i++)
if (ServerStatsArr[i].abonnement == 304){
ServerStatsArr[i].abonnement = 'Premium';
}else{
ServerStatsArr[i].abonnement = 'Non';
if (ServerStatsArr[i].transparence == 1) {
ServerStatsArr[i].transparence = 'Oui' ;
}else{
ServerStatsArr[i].transparence = 'Non' ;
ServerStatsArr.refresh();
Why this method is working for abonnement when (ServerStatsArr[i].abonnement == 304) it displays Premium but it's NOT working for transparence ?
i tested (ServerStatsArr[i].transparence == 1) and (ServerStatsArr[i].transparence == '1')
Thank youhi Again,
private function setLabel(item:Object,column:DataGridColumn):String
switch(column.dataField)
case "transparence":
if (item.transparence == "1")
return ("yes")
else
return ("no")
break;
case "abonnement":
if (item.abonnement == "304")
return ("premium")
else
return ("none")
break;
default:
return("");
and the adjustments to your grid - add the labelfunction to the following columns
<mx:DataGridColumn headerText="transparence" dataField="transparence" labelFunction="setLabel"/>
<mx:DataGridColumn headerText="abonnement" dataField="abonnement" labelFunction="setLabel" />
I hope we get a distinction credit for this assignment ...
David. -
hi all
How can i use stored procedures for tuning the database?
thanksIf you mean "will using stored procedures help improve application performance?" the answer is they may, depending on your application, number of users, etc, etc.
Stored procedures are just application code stored in the database. This means the network traffic of information being sent back and forth between the server and clients is reduced and the application has more resources (usually) as it is running on the server and not the client. Also stored procedures can be used to cache information for future use by the same user.
These 2 tutorials on pl/sql may help
[http://www.asktheoracle.net/plsql-tutorial.html | oracle-plsql-tutorial-part1.htm]
and
[http://www.smart-soft.co.uk/Oracle/oracle-plsql-tutorial-part1.htm | plsql-tutorial-part1.htm]
They are specifically on pl/sql but the general principles pf when and why to use them would be teh same for Java stored procedures or .net stored procedures.
Edited by: ow007829 on 15/06/2010 14:40 -
How to retrieve the large data from the database
in my program, I want to operate the data retrieved from the database. but there are too many rows in the ResultSet . so when I try to get the ReusltSet from the database, the error of "java.lang.OutOfMemoryError
" will appear . because there are two million rows contained in the ResultSet, So I want to know whether there are some methods to deal with this problem.
anyone can give me some tips or recommend some papers and books to me.
thanks!!!!the program is developed for the data warehourse, you know there is a large number of data in data warehourse. so I think I have to deal with the very large ResultSet in my program, this code is a example for my problem :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Untitled1 {
String user = "";
String password = "";
public void createTable() {
try {
Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
System.out.println("Good to go");
String url = "jdbc:sybase:Tds:59.64.137.240:5000/TJ";
Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("connect successfully!");
// Statement st1 = conn.createStatement();
String sqlsentence2 = "SELECT DISTINCT caller FROM upcdr";
PreparedStatement st2 = conn.prepareStatement(sqlsentence2);
PreparedStatement st3 = conn.prepareStatement("INSERT INTO callerTable VALUES(?)");
System.out.println("createstatement successfully!");
// String sqlsentence1 = "CREATE TABLE callerTable (caller CHAR(18))";
// st1.executeUpdate(sqlsentence1);
// System.out.println(sqlsentence1);
// st1.close();
ResultSet rs = st2.executeQuery();
while (rs.next()) {
st3.setString(1, rs.getString("caller"));
st3.executeUpdate();
System.out.println(rs.getString("caller"));
st2.close();
st3.close();
} catch (SQLException e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println( e.getSQLState());
System.out.println( e.getErrorCode());
} catch (ClassNotFoundException e) {
e.printStackTrace();
public static void main(String args[]) {
Untitled1 cct = new Untitled1();
cct.createTable();
}at here, the table "upcdr" is very large, it has two million rows. when I run this program , the error will happen. someone told me that if I use the cursor, because it will retrieve one row from the database every time, so it will not produce a very large ResultSet, then the memory would not be used out. but I am not familiar with that aspect. so I think if anyone can give me some advice.
thanks!!!! -
JDBC(using stored procedure) to RFC Scenario
Hi
I am doing JDBC(using stored procedure) to RFC Scenario
While running the scenario i am getting the following error
Database-level error reported by JDBC driver while executing statement 'EXECUTE EMU.EXTRACTRECON'. The JDBC driver returned the following error message: 'com.ibm.db2.jcc.a.SqlException: [ibm][db2][jcc][10100][10910] java.sql.Statement.executeQuery() was called but no result set was returned. Use java.sql.Statement.executeUpdate() for non-queries.'. For details, contact your database server vendor.
Can anybody sortout my problem
Regards
sunilreddyHi,
i am doing the scenario file to rfc scenario.
when i run my scenario xi system is picking the data from file system
but rfc is not accepting the data.this is the error i am getting
Delivery of the message to the application using connection RFC_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Exception thrown in method process. The transaction is marked for rollback.: com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception thrown in method process. The transaction is marked for rollback..
so please any one give me the solution for that
Maybe you are looking for
-
i created a new itunes, but when i add the music i added it from my external hard drive by accident, so when i disconnect it and wish to play music without having it connected, obviously it asks me to located my songs, i dont want to locate each song
-
does anyone know why subscribed calendars from google on iPad cause the calendar app to freeze?
-
LayeredPane, validation Icons, JScrollPane should become invisible
For development of an application we have customized textfields, comboxes etc. The are able to show validation icons, these icons are centered in the down/left corner. Thus a little bit in and outside of the components bounds. To add validation icons
-
Create Delivery with reference to seasonal stock transport order
Hello Gurus How do we create a delivery with respect to seasonal stock transport order, in R/3 4.7. Thanks in advance
-
HT201328 How wil I know if my phone has been unlocked?
I've just phoned t-mobile to have my phone unlocked, how will I know when this has happened