Stored Procedure vs Inline Query
Hi all,
The other day i came across a link
http://www.blackwasp.co.uk/SpeedTestSqlSproc.aspx
saying that in sql server stored procedure takes more time for execution
rather than inline queries.
Is this true in the case of Oracle.Kindly seeking valuable suggestions from gurus
Regards
josh
Handle: user588120
Status Level: Newbie (5)
Registered: Aug 2, 2007
Total Posts: 228
Total Questions: 29 (25 unresolved)
so many questions & so fews answers.
Is this true in the case of OracleWhat will you do differently if it is always true?
What will you do differently if it is always false?
What will you do differently if it depends upon externals factors?
Similar Messages
-
Running a SQL Stored Procedure from Power Query with Dynamic Parameters
Hi,
I want to execute a stored procedure from Power Query with dynamic parameters.
In normal process, query will look like below in Power Query. Here the value 'Dileep' is passed as a parameter value to SP.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData 'Dileep'"]
Now I want to pass the value dynamically taking from excel sheet. I can get the required excel cell value in a variable but unable to pass it to query.
Name_Parameter = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
Name_Value = Name_Parameter{0}[Value],
I have tried like below but it is not working.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData Name_Value"]
Can anyone please help me with this issue.
Thanks
DileepHi,
I got it. Below is the correct syntax.
Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData '" & Name_Value & "'"]
Thanks
Dileep -
How to call pl/sql stored procedure in JDBC query dialogbox
Hi,
how to call pl/sql stored procedure in JDBC query dialogbox(reports 9i) .
Cheers,
Raghuplease refer : Re: problem If you have more doubts, please ask in that question.
-
Hi,
I'm new to SharePoint 2013 I want to be able to query a MSSQL database from a SharePoint App I have tried to create an External Content Type (ECT) which is produced from a MSSQL stored Procedure, this procedure has several parameters which are needed to
filter the data correctly. From here I want to produce an external list which I can then query from a c# SharePoint app. If I leave the filters in the ECT null then the list is of course empty or if enter a default values the results are limited
for the app to query so are no good.
I want to dynamically pass values to the ECT when querying from the app, is this not possible. Should I just be returning everything in an external list and then letting the query in the app filter the data, this seems inefficient?
Is this the best way to do this or should I be doing this differently?
Please can someone point me in the right direction.
ThanksHi Pandra801,
When you create a the external content type, please try to add a filter based on your select statement.
http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
A step by step guide in designing BCS entities by using a SQL stored procedure
http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Calling Oracle stored procedure from xMII Query Templates.
Hi All,
We have a requirement to call a Oracle stored procedure from xMII, the SP expects some inputs and then it returns multiple rows.
I tried different approches with no results, I remember some posts on the same topic but I could not get in search results.
Looking for some help in this regards
Rupesh.Hi Rupesh Bajaj,
In oracle stored procedure we have to use Packages..if you used packages the u have to assign to some variable.
To calling Stored procedure in Query Template is CALL Testing('[Param.1]','[Param.2]',,:X)
In above line Testing is Stored procedure name and Param.1 is parameters and X is Package.
Thanks
Ravilla Ramesh -
Stored Procedures - Executing a query with multiple variables
Hello everyone..
During development I faced the followng problem. When I tried to execute a query in a stored procedure using 2 or more variables an unexplained error came up! The fact is that I use a form that calls this particular stored procedure using 2 variables.
Does anybody know why is this happenning?
Thanx!To better help you, could you provide the procedure (or part of it) and the query causing the error?
Hello everyone..
During development I faced the followng problem. When I tried to execute a query in a stored procedure using 2 or more variables an unexplained error came up! The fact is that I use a form that calls this particular stored procedure using 2 variables.
Does anybody know why is this happenning?
Thanx! -
Run a Stored procedure in Orchestrator Query Database
I dont see an option where a stored procedure can run in Database query.
Instead of putting a query, I would like to have a stored procedure run at different intervals and then send out the notification.
If it is not in Database Query, Where do I find an option for Stored proc.?HI Sd,
You need to do following for using Stored procedure as polling statement
1. Right click the project and select Add-->Add Generated Items
2. Then select "Consume Adapter Service"
3. Now the Consume Adapter Service wizard wants us to provide it the required information, so firstly select "sqlbinding" against the label Select a binding.
4. Click the Configure button, on security tab select the Client credential type .
5. On URI Properties tab:
-->Type the name of the server where your database is located
--> Provide the name of the database you want to use.
--> In front of InboundId , type the name whatever you want so as to identify the purpose of polling. It acts as a unique identifier which helps in avoiding conflict when you poll same tables for some other purpose.
6. Binding Properties tab:
Select Polling from the dropdown list in front of InboundOperationType
Give a valid PolledDataAvailableStatement such as (Select count (*) from table1)
"exec MyStoreProcedureName" from receive location polling statment
Thanks
Abhishek -
How to add parameters to a stored procedure in B1 Query generator
Dear All,
I made a stored procedure in sql. I'd like to call it from B1. It's working fine when I call like this (I created an empty query in Query generator and paste this) :
exec stproc @projectFrom = '',
@projectTo = 'PRJ03',
@profitCodeFrom = '',
@profitCodeTo = 'uj',
The problem is, Could I call this procedure with parameters like normal queries (select ... where .. = [%0])? Can I pass parameters to it somehow?
Thanks a lot
JaniInside B1 :
DECLARE @return_value int
Declare @Fromdate datetime
declare @Todate datetime
declare @supp nvarchar(15)
SELECT * FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry where
T0.cardcode = '%Supp' and T0.DocDate <=%FromDate
and T0.DocDate >=%ToDate
EXEC @return_value=SQL2XMLforINV
@Fromdate= %FromDate,
@ToDate= %ToDate,
@Supp = '%Supp'
SELECT 'Return Value' = @return_value
And in SQL I have a stored procedure :
Starting like this :
PROCEDURE [dbo].[SQL2XMLforINV]
@Fromdate datetime,
@Todate datetime,
@supp nvarchar(15)
AS
DECLARE @bcpCommand AS varchar(3000)
declare @base nvarchar(50)
BEGIN
SET NOCOUNT ON;
And my error message is in B1 ....
Thanks in advance for your help .... -
Stored procedure with select query
Hi,
I have a problem , We have a sysnchronous scenario and executing a stored procedure and a selcect statement .
it is running fine with little confilt in data is there.
We we run the scenario it execute the strored procedure and return the value like 500 and under select statement it select entire table which has same flag.
I want to execute stored procdure and in slect statement one row at a time and then again it will insert to other table in then database.
currently we are getting value like this.
<?xml version="1.0" encoding="utf-8" ?>
- <ns0:MT_SP_JDBC_response xmlns:ns0="http://ns_cfgCountry">
- <GetNextSiteNumber_response>
<Result>10000000000400</Result>
</GetNextSiteNumber_response>
- <Statement2_response>
- <row>
<ID>IN</ID>
<Description>INDIA</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
- <row>
<ID>EN</ID>
<Description>ENGLAND</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
- <row>
<ID>ZA</ID>
<Description>SA</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
</Statement2_response>
</ns0:MT_SP_JDBC_response>
Regards
Laxmi Bhushan JhaHi,
Can u please write your req little clear....
If you want to selcect and update a table and again select ... what ever it may be.... all these has to be done in the stored procedure only.
At the end of all ur statements u pass back the value from your Stored Procedure
Babu -
Converting oracle stored procedure to inline sql
I have an oracle stored proc.. that i need to convert to inline sql in code.. (vb.net)
getting formatting errors all over the place..
was wondering if someone could help.
I have attached the oracle sp as well as my code sample..
create or replace
PROCEDURE "LAYOUT_UPDATE_INSERT" (
v_layout_name IN NVARCHAR2 DEFAULT NULL,
v_layout_description IN NVARCHAR2 DEFAULT NULL,
v_layout_data IN BLOB DEFAULT NULL,
v_profileid IN NUMBER DEFAULT NULL,
v_layout_id IN NUMBER DEFAULT NULL,
cur_out OUT sys_refcursor
/*ADVICE(8): This item has not been declared, or it refers to a label
[131] */
AS
v_temp NUMBER (1, 0) := 0;
BEGIN
BEGIN
SELECT 1
INTO v_temp
FROM DUAL
WHERE EXISTS (
SELECT *
FROM layouts
WHERE profileid = v_profileid
AND layout_id = v_layout_id);
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
IF v_temp = 1
THEN
BEGIN
UPDATE layouts
SET layout_data = v_layout_data,
layout_name = v_layout_name,
layout_description = v_layout_description
WHERE profileid = v_profileid AND layout_id = v_layout_id;
END;
ELSE
BEGIN
INSERT INTO layouts
(layout_name, layout_description, layout_data,
profileid
VALUES (v_layout_name, v_layout_description, v_layout_data,
v_profileid );
OPEN cur_out FOR
SELECT 1
FROM DUAL;
END;
END IF;
END "LAYOUT_UPDATE_INSERT";
Code sample
If DB.GetType.Name.Equals("OracleDatabase") Then
Dim block As String
block = block & " v_temp NUMBER (1, 0) := 0;"
block = block & "BEGIN BEGIN"
block = block & " Select 1 INTO(v_temp) FROM(DUAL) WHERE EXISTS ("
block = block & " SELECT * FROM(layouts) WHERE(profileid = :4)AND layout_id = :5);"
block = block & "Exception WHEN OTHERS THEN NULL;"
block = block & " END;"
block = block & "If v_temp = 1 Then THEN "
block = block & "BEGIN UPDATE(layouts) SET layout_data = :3,"
block = block & "layout_name = :1, layout_description = :2"
block = block & "WHERE profileid = :4 AND layout_id = :5;"
block = block & "END;"
block = block & "Else BEGIN "
block = block & "INSERT INTO layouts (layout_name, layout_description, layout_data,profileid)"
block = block & "VALUES (:1, :2, :3, :4 );"
block = block & "OPEN cur_out FOR"
block = block & " Select 1 FROM DUAL; END; END IF;"
Dim dbcommand As Common.DbCommand
dbcommand = DB.GetSqlStringCommand(block)
DB.AddInParameter(dbcommand, ":1", DbType.String, vLayoutName)
DB.AddInParameter(dbcommand, ":2", DbType.String, vLayoutDescription)
DB.AddInParameter(dbcommand, ":3", DbType.Binary, vLayoutData)
DB.AddInParameter(dbcommand, ":4", DbType.Int32, vProfileID)
DB.AddInParameter(dbcommand, ":5", DbType.Int32, vLayoutID)
Dim result As DataSet
result = DB.ExecuteDataSet(dbcommand)
Edited by: Mainiac007 on May 11, 2009 12:59 PMHowdy,
I do not know the VB syntax but this may help:
using System.Text.RegularExpressions;
Regex _regex = new Regex(@"\s{2,}", RegexOptions.None);
string A_WONDERFUL_STRING = regex.Replace(MORETHAN_LIKELY_EVIL_STRING, " ");
r,
dennis
I forgot this part:
System.IO.FileStream fs = new FileStream(SOME_TEXT_FILE_WITH_PROC, FileMode.Open);
System.IO.BinaryReader br = new BinaryReader(fs);
ba = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
string MORE_THAN_LIKELY_EVIL_STRING = Encoding.UTF8.GetString(ba);
should be in try/catch block
Edited by: user633187 on May 11, 2009 3:07 PM -
Error when use stored procedure in Named Query and Custom SQL
This is a toplink development on Jdev 1013. A package with a function is created which returns a "ref cursor" in a oracle 9i database. I tried to access the function in jdev toplink descriptor editor either through custom sql (Readall) or a named query (procedureTest) and I got java.sql.SQLException: SQL string is not Query. Note: I am NOT talking about programatic storedprocedurecall object.
The client access code is following (where error was thrown):
results = (Collection) session.executeQuery("procedureTest", WuTest.class);Any responses? Thanks.
-
1] What is the reason for mostly using Procedure instead of sql and main use?
2] How to increase the procedure speed?> 1] What is the reason for mostly using Procedure instead of sql and main use?
The rule which I often repeat around here (sometimes a couple of times per day):
Maximise SQL. Minimise PL/SQL
In other words, only when the logic is too complex to be dobe efficiently and effectively in SQL, then PL/SQL is used. BUT PL/SQL IS ONLY USED WHEN SQL CANNOT DO THE JOB.
Why? SQL is not what they call a "Turing Complete" language. It is limited in the constructs and logic processing it can do. PL/SQL is otoh a 4GL language (based on the 3GL called Ada). It is "Turing Complete" and can do the complex funky walk.
> How to increase the procedure speed?
By maximising SQL. Treating Oracle data as data sets and not perform row-by-row processing.
Using bulk processing.
By adhering to fundamentals of software engineering.
By reading the Oracle® Database Application Developer's Guide - Fundamentals and applying these.
By reading the Oracle® Database Concepts guide and understanding these concepts.
Oh yeah - the URLs for the docs:
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14251/toc.htm
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/toc.htm -
Calling a Stored Procedure with output parameters from Query Templates
This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
We encountered a problem while calling a stored procedure from MII Query Template as follows-
1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
a) Input1 - CLOB
b) Input2 - CLOB
c) Input3 - CLOB
d) Output1 - CLOB
e) Output2 - CLOB
f) Output3 - Varchar2
2. There are two ways to get the output back.
a) Using a Stored Procedure by declaring necessary OUT parameters.
b) Using a Function which returns a single value.
3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
characters)
6. So the method 2-a is ruled out.
7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
Thanks in Advance.
RajeshRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
Problem Calling MaxDB stored procedure with output from MII Query template
Hi,
I am using Max DB Database studio to write stored procedure, I am calling stored procedure from MII Query using CALL statement.
Can anyone guide me how to pass output values of stored procedure.
Examlpe::
call ProcName('[Param.1]','[Param.2]','[Param.3]','[Param.4]','[Param.5]', :isSuccess, :Trace)
In the above line of code I am not able to get the output values of stored procedure that is isSuccess and Trace values in Query template when executed. But same thing I get when executed in Database studio.
How do I call with outputs for any stored procedure in MII.
Any help would be appriciated.
Thanks,
PadmaMy call statement is like this
call RESULTDATA_INSERT('[Param.1]','[Param.2]','[Param.3]', :isSuccess, :Trace)
I am able to insert record in DB, But I am not getting output values in Query template.I have done this in Fixed Query, when I execute it throws me "Fatal error as Loaded content empty".
I tried giving select below call but it dont work.
Regards,
Rao -
Displaying data from stored procedure into textbox fields based on user input.
I have a stored procedure that is selecting data from a table called "Vendor" in my database. The data that is being returned are vendor names, vendor addresses, vendor Id's, etc...In my stored proc, I have one parameter that allows
the user to enter a vendor name and then return all the data for that specific vendor. The report that I'm building is going to look like a basic form with a bunch of textboxes on the screen labeled Vendor Address, Vendor Id, Vendor City, Vendor State,
etc...In the report I'm trying to build, the user will enter in a vendor name and then it will return all of the vendor's data based on what the user searches for. However, the report will only return ONE vendor's data at a time.
The problem is that some of the data in the database has very similiar vendor names, but different vendor addresses, vendor Id's, etc...In some instances the vendor name is actually
exactly the same, but the vendor address, vendor city, vendor Id, is all different. So what I did was added another parameter in my report that shows a drop down list of vendor names based on the wildcard search the user just did and
allows the user to select the exact vendor name that he/she is looking for based on what they searched. The problem I'm having is that I don't know what expression I need to put in each one of my textboxes to retrieve the correct data from
the vendor table that the user selects from the drop down list. So what I want to do is return the exact data from the vendor table based on the selection that the user makes from that drop down list. It's like I somehow have to compare the
drop down list parameter directly to the dataset but I don't know what expression needs to go in the textbox. I've tried...=First(Fields!VendorName.Value, "DataSet1").EqualsParameters!DropDownList.Value(0) but I keep getting an error message.
--Here is an example of the kind of thing the user might search for...when the user searches the word "sprint" it returns three different vendor names to the drop down list.
1. sprint
2. sprint
3. sprint co
Each one of those three vendor names has a different vendor address, vendor city, vendor ID, etc...but the vendor names are extremely similar and in some cases
exactly the same. In my report now I can't get the textboxes to return the correct data based on what the user selects. Any advice at all is greatly appreciated.
P.S. I didn't even know what SQL Server was a month ago and had zero knowledge of SSRS at all. I've learned a lot recently, but if you could explain a solution in the easiest way possible I would appreciate it. Thanks!Hi Jrcowles,
If I understand you correctly, you wnat to list all the Vendor Name which like the user typed Vendor Name on a drop-down list, right? If in this case, we can use a cascading parameters to achieve your requirement. I have tested it on my local environment,
the steps below are for you reference.
Create an other stored procedure using the query below.
CREATE PROCEDURE GetVendorName
@VendorName NVARCHAR(50)
AS BEGIN
exec( 'SELECT * FROM Vendor WHERE VendorName LIKE ''%'+@VendorName+'%''')
END
Create another dataset DataSet2 and using the new created procedure.
Create another parameter VendorName2 and check "Allow Multiple Values" for this parameter.
On the Available Values tab, check "Get values from a query". Select corresponding dataset and field.
On the Default Values tab, check "Get values from a query". Select corresponding dataset and field.
The screenshots below are for you reference.
Reference
http://technet.microsoft.com/en-us/library/aa337169(v=sql.100).aspx
http://www.msbiguide.com/2012/02/adding-cascading-parameters-to-ssrs-reports/
Regards,
Charlie Liao
TechNet Community Support
Maybe you are looking for
-
So when I plug my ipod nano into my computer usb port it say it has malfunctioned and windows doesnt recognize it. I've tried everything possible also i cant see it on itunes or ipod updater. PLEASE HELP. Thank YOU
-
Open Recent - CS3 Complete File Path
In CS2 my open recent files showed the complete file path. e.g. d:\jobs\clients name\file name.indd. In CS3 it only shows file name without the complete path. Is there a setting to change this or am I stuck with it?
-
Cancelling following events on error
HI, I have a input field where the user can enter some values. After he made some changes, I fire an OnChangeEvent, where I check the entries. On the same view there is also a button, where the user can order items. When the user change a value and c
-
HT1391 how do i report my stolen ipod
how do i report my stolen ipod
-
Gigabit ethernet only supports 100Mb
Hi Im having a problem with the 48-port Gigabit ethernet blade (48-port 10/100/1000BaseT (RJ45)) on a 4506 switch, one of the ports only support 100Mb, if hardcoded to 1000Mb on both sides, then the connectivity would be gone. All other ports on this