How to Split a Stored Procedure into 4 SP's URGENT!!!!!!!!!!!!!!!!
hi,
Every thing is set now. But only one issue is left over.
CREATE OR REPLACE package dyn_query_MBU21
is
type r_cur is ref cursor;
procedure get_query(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer);
procedure printQuery(p_scorecard_id integer,p_user_id integer,p_start_bu integer,p_end_bu integer,p_parent_srsid integer);
end dyn_query_MBU21;
CREATE OR REPLACE package body dyn_query_MBU21
is
procedure get_query(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer)
is
l_query VARCHAR2(32700);
v_temp varchar2(300);
v_strLength integer;
val integer;
--p_start_bu INTEGER;
--p_end_bu INTEGER;
--v_cur r_cur;
l_buCount integer default 0;
BEGIN
l_query := 'select
a.PLAN_TO_WIN PTWID,
a.SPQRC SPQRCID,
l.NAME Plan_to_Win,
m.NAME BPD,
a.metric_id,
a.NAME Key_Measures,
a.DESCRIPTION,
c.DATE_MONTH_DIM_KEY,
c.CALENDAR_MONTH_NBR,
c.CALENDAR_YEAR_MONTH_CDE,
e.SRS_ID,e.YEAR_VALUE,
f.YTD_VALUE YTD,
g.CALENDAR_YEAR_NBR,
h.FIRST_NAME || h.LAST_NAME Scorecard_Owner
, j.TYPE_NAME Management_Level,
k.NAME Business_Unit
, N.SCORECARD_ID
, N.NAME
, K.LOC_CURRENCY_ID
--decode(ltrim(rtrim(k.PARENT_SRS_ID)),' || p_parent_srsid || ', k.NAME) Parent_BU ';
, decode(ltrim(rtrim(k.PARENT_SRS_ID)),3,''Bill Boggs'') Parent_BU ';
for x in ( select distinct NAME from SRS_DIM where parent_srs_id = p_parent_srsid and rownum < 20)
loop
l_buCount := l_buCount + 1;
l_query := l_query ||
' , decode(ltrim(rtrim(K.NAME)),'''||ltrim(rtrim(x.NAME))||''', D.MONTH_VALUE ) '||replace(to_char(x.NAME),' ','_');
-- dbms_output.put_line('this is the query'||l_query);
end loop;
l_query := l_query ||
' FROM
METRIC_DIM A,TARGET_MONTH B,DATE_MONTH_DIM C,METRIC_SRS_MONTH_EVAL D,TARGET_YEAR E,METRIC_SRS_YTD_EVAL F,DATE_YEAR_DIM G,
GM_USER_DIM H,USER_PRIV I,SRS_ITEMTYPE_DIM J,SRS_DIM K,PLAN_TO_WIN_DIM L,SPQRC_DIM M,SCORECARD_DIM N
WHERE
L.PLAN_TO_WIN_ID= A.PLAN_TO_WIN
AND M.SPQRC_ID= A.SPQRC
AND A.METRIC_ID=B.METRIC_ID
AND B.DATE_MONTH_DIM_KEY=C.DATE_MONTH_DIM_KEY
AND B.SRS_ID=K.SRS_ID
AND B.SRS_ID=F.SRS_ID
AND D.SRS_ID=F.SRS_ID
AND D.SRS_ID=K.SRS_ID
AND D.DATE_DIM_KEY=C.DATE_MONTH_DIM_KEY
AND D.METRIC_ID = B.METRIC_ID
AND D.METRIC_ID = E.METRIC_ID
AND D.METRIC_ID = F.METRIC_ID
and d.SRS_ID=b.SRS_ID
and d.DATE_DIM_KEY=b.DATE_MONTH_DIM_KEY
AND E.SRS_ID = F.SRS_ID
AND G.DATE_YEAR_DIM_KEY = E.DATE_YEAR_DIM_KEY
AND G.CALENDAR_YEAR_NBR = C.CALENDAR_YEAR_NBR
AND F.DATE_DIM_KEY = E.DATE_YEAR_DIM_KEY
AND K.PARENT_SRS_ID =n.SRS_ID
AND N.SCORECARD_ID= :p_scorecard_id
AND H.USER_ID = :p_user_id
AND K.SRS_ID BETWEEN :p_start_bu AND :p_end_bu
--AND P_PARENT_SRS_ID = :p_parent_srsid1
-- ANd n.Scorecard_id=2
-- AND H.USER_ID = 7000001
AND J.TYPE_ID = :p_parent_srsid
--AND K.SRS_ID = 8
GROUP BY
a.PLAN_TO_WIN,
a.SPQRC,
l.NAME,
m.NAME,
a.metric_id,
a.NAME,
a.DESCRIPTION,
c.DATE_MONTH_DIM_KEY,
c.CALENDAR_MONTH_NBR,
c.CALENDAR_YEAR_MONTH_CDE,
e.SRS_ID,
e.YEAR_VALUE,
f.YTD_VALUE,
g.CALENDAR_YEAR_NBR,
h.FIRST_NAME || h.LAST_NAME,
j.TYPE_NAME,
K.NAME,
l.PLAN_TO_WIN_ID,
m.SPQRC_ID,
N.SCORECARD_ID,
N.NAME,
K.LOC_CURRENCY_ID,
--decode(ltrim(rtrim(k.PARENT_SRS_ID)),' || p_parent_srsid || ', k.NAME) Parent_BU ';
, decode(ltrim(rtrim(k.PARENT_SRS_ID)),3,''Bill Boggs'') Parent_BU ';
for x in (select distinct NAME from SRS_DIM where parent_srs_id = p_parent_srsid and rownum < 20 )
loop
l_query := l_query ||' , decode(ltrim(rtrim(K.NAME)),''' || x.NAME || ''', D.MONTH_VALUE ) ';
end loop;
l_query := l_query ||'order by a.PLAN_TO_WIN';
-- open p_cur for l_query using p_scorecard_id,p_user_id,p_start_bu,p_end_bu,p_parent_srsid;
select (length(l_query)/255) + 1 into v_strLength from dual;
dbms_output.put_line('String Lenghth is :'||v_strLength);
for c in 1..v_strLength
loop
if c = 1 then
v_temp := SUBSTR(l_query, 1, 255);
else
if length(l_query) > (255 * c) then
v_temp := SUBSTR(l_query, 255 * (c-1) , 255);
end if;
end if;
dbms_output.put_line(v_temp);
end loop;
end get_query;
procedure printQuery(p_scorecard_id in integer,p_user_id in integer,p_start_bu in integer,p_end_bu IN INTEGER,p_parent_srsid in integer) is
Begin
get_query(p_scorecard_id,p_user_id,p_start_bu,p_end_bu,p_parent_srsid);
End printQuery;
end dyn_query_MBU21;
I want to split this procedure into 6 procedures to make it look easier.
1.getSQLSelect
2.getSQLFrom
3.getSQLWhere
4.getSQLGroupBY
5.getSQLOrderBY
add another proc...getSQL that returns all the above procs ie,
I need to build the entire sql & call "Open Cursor" meaning...getSQLSelect||getSQLFrom()...
How to do this ?
Thanks in Advance
You're missing a comma.
Similar Messages
-
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
How to execute oracle stored procedure through php as externally?
hi...
i am searching for the way that how to execute oracle stored procedure through web service, i am using php and mysql, i have some stored procedures in oracale database, i want to execute them, from php, means the database will be remain mysql, and the stored procedures of oracle will be executed externally...
Kind regards,
Wilayat.Ok, so first of all this is a kind of strange question. Since Oracle and MYSQL can happily live side by side.
Make sure you have the oracle client (instant or regular ) installed and OCI_8 is set up and working correctly in PHP. If it is, when you run the phpinfo() routine you will see oci_8 on there. IF PHP connects just fine from the command line yet apache wont connect check permissions and things like the LD_Library Path.
Then in php, right along with your MySQL statements run Oracle Statements eg:
<?php
$OraDB = oci_connect(name,pass,tnsname);
$MySQLdb = mysql_connect([parms]);
$oraQueryText = "begin sp_some_proc([some parms]); end;" ;
$mysqlQuery = " Some mysql Query";
$oraQuery = oci_parse($OraDB,$oraQueryText );
oci_execute($oraQuery);
mysql_execute([parms]);
?>
Use the standard fetch code to get data from either of them.
If you cannot and I mean absolutely cannot get an admin to link in OCI_8 then you still have recourse although it will be tedious as hell. PHP allows you to exec calls to the OS. You still MUST make sure the Oracle Client is installed and that sqlplus runs from the command line. You will more then likely have to have a shell script written to do this as well, but maybe not as I have never tried it with the exception of capturing the return value of sqlplus and you will have to dig into sqlplus to get it to send its results to a file you can then parse with php.
Good Luck! -
How to convert MSSQL stored procedure to PostgreSQL
Hi,
Anyone can help me...?
How to convert MSSQL stored procedure to PostgreSQL function?
Is there any tool available to convert T-SQL from MSSQL to PostgreSQL?
Thanks in advanceHello
Here, I write one sample stored procedure of SQL Server which I need to convert into PostgreSQL. Please help me in this with PostgreSQL.
Thanks in advance.
Below is sample SQL Server stored procedure: require to convert into PostgreSQL stored procedure
CREATE PROCEDURE [dbo].[usp_GetData_ByTableName]
@TableName NVARCHAR(MAX)
,@IncludeKeepAlive BIT
,@RowsAffected BIGINT=0 OUTPUT
) AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL VARCHAR(MAX)
Select data base on parameter.
SET @SQL =
SELECT *FROM '+@TableName+'
WHERE 1=1
+
CASE WHEN (@IncludeKeepAlive = 0)
THEN
AND [MessageTransactionID] <> 152
ELSE
END
EXECUTE SP_EXECUTESQL @SQL
RETURN 0 -
Calling stored procedure into Crystal Report
Could any one help in suggesting how to call the stored procedure with parameters into crystal report?
i have tried using couple of methods
I have added this in add command option of Crystal report
Execute HRMS_DEVP.DPRC_GET_LEAVE_BAL(P_COMP_CODE,P_EMP_CODE,P_LV_CATG_CODE,P_DATE,P_BALANCE)
WHERE in p_balance i would be retrieving the output.
Second method i followed is
SELECT DFUN_GET_LEAVE_BAL(:P_COMP_CODE,:P_EMP_CODE,:P_LV_CATG_CODE,:P_DATE)FROM
DUAL;Hi,
Have you tried the 'get_value' function?..The syntax is
declare
l_dept number(5);
begin
l_dept := get_value('dept');
/* further process */
end;
where 'dept' is name of the bind variable.
-Krishnamurthy -
How to use a stored procedure as a datasource in Crystal Report for Eclipse
Hi All,
I've written a stored procedure in oracle 10g with few input parameters and one refcursor output parameter. I want to use this stored procedure as a data source for creating a report in "Crystal Report For Eclipse 3.6.0".
When I tried to add this stored procedure to the report using the connection explorer, I don't see any option to do this. But when I try to add any table, it shows options like "Add to the current report"....
Can anybody assist me how to use a stored procedure as a data source in "Crystal Report For Eclipse"?
Which driver should I use to connect to the oracle database? I tried using JDBC Driver for Oracle.
Thanks in advance.Did you solve your problem? How did you do?
-
How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
Hi
I have a stored procedure. It can be executed like this
exec test @p = 1;
exec test @p = 2
exec test @p = n;
n can be hundred.
I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
However, the n is not static. It is coming from a table.
How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
be run parallel. But I am not sure if it works.
Any idea is really appreciated.Hi nam_man,
According to your description, you want to call stored procedures in parallel, right?
In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
For more information about SSIS job and Sequence container, please refer to the following documents:
http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
How to call a stored procedure from WorkShop
Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
me .. Today I'm simply trying to find out how to call a stored procedure from
within workshop, using any of the DB Controls .. I see workshop provides a way
create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
to be entered in place of the inline query .. Perhaps I've over looked it. Any
advise on the best way to tackle this task will be appreciated.
AtahualpaAtahualpa--
Maybe this will help:
http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
Eddie
Atahualpa wrote:
Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
me .. Today I'm simply trying to find out how to call a stored procedure from
within workshop, using any of the DB Controls .. I see workshop provides a way
create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
to be entered in place of the inline query .. Perhaps I've over looked it. Any
advise on the best way to tackle this task will be appreciated.
Atahualpa -
How to use a stored procedure in oracle reports
How to use a stored procedure in oracle reports
Dear,
In report triggers you can write your procedure/functions or call it like
function AfterPForm return boolean is
begin
myprocedure(:mydate);
return (TRUE);
end;
Thanks
Jamil -
How to create a stored procedure and use it in Crystal reports
Hi All,
Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
Thanks in advance.If you are using MSSQL SERVER then try creating a stored procedure like this
create proc Name
select * from Table
by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
here is the syntax to create SP
Syntax
CREATE PROC [ EDURE ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]
[ WITH
{ RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
[ FOR REPLICATION ]
AS sql_statement [ ...n ]
Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
Regards,
Raghavendra
Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM -
How to call a stored procedure using its package name in Oracle
hi
we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
i have got 2 queries:
1- How to call the stored procedure using it's package.
2- How to capture the In/Out parameter in the response.hi Prateek
thanks for the reply.
However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
How to get the IN-OUT parameter in XI? -
How to introspect a Stored Procedure in BPm 10g
Could some give points on how to introspect the Stored procedure from BPM
Hi,
I hope you must have created DB connection in External Resources (Workspace).
So Now create one module in catalog component called DBTables, right click on the module -> New -> Catalog Component -> SQL Query -> Select the DB connection that you created earlier -> select the schema, now you can see all the procedure, tables, function that are defined in your schema.Click on the procedure that you want to import to your workspace and click on finish. The procedure will be imported to your workspace.
Hope the above will help you.
Bibhu
Edited by: Bibhuti Bhusan on Jul 14, 2011 10:44 PM -
How to execute a stored procedure/function in TOAD?
Hi, All ,
Can someone please tell me how to execute a stored procedure/function in TOAD?
I have tired
EXECUTE PROCEDURENAME(888), but it doesn’t work.
TOAD give me the error: invalid SQL statement.
Thanks a lotWrite PL/SQl block.
i.e Begin
Procedure name..
end;
Then it will be excuted.
Ashutosh -
How do write a stored Procedure in PL/SQL
Hi,
I am new to this forum. I am creating a webpage using Gridview in Visual Studio 2005.
How to write a Stored procedure in Oracle using PL/SQL?
I want to write a SP for the following query :
"Select S_No, Task_ID,Last_Act_Dt,Last_Act_Tm,Status from E002 Order by S_No"
Please help.In Oracle, you normally wouldn't create a stored procedure that just does a query. Depending on what you're attempting to do on the client side, and the client libraries involved, you may be able to write a stored procedure that returns a REF CURSOR and call that. This will put some limitations on what the client can do with the results, for example. The data would be read-only and scrolling back and forth in the result set would potentially rather slow and rather expensive in terms of client memory. That makes this generally a somewhat unattractive option.
You could create a view in Oracle and just query the view in your application code. If you needed to change the query, you could then just change the view.
Justin -
Need an Example for How to call a Stored Procedure using DBAdapter
Hi
I am trying to invoke a stored procedure in Oracle Database using DB Adapter. I have successfully invoked and when i try to run it i got the following error.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ExecuteScript' failed due to:
Stored procedure invocation error.
Error while trying to prepare and execute the RESONANCEDEMO.SP_QUERY API.
An error occurred while preparing and executing the RESONANCEDEMO.SP_QUERY API. Cause: java.sql.SQLSyntaxErrorException: ORA-00917: missing comma
ORA-06512: at "RESONANCEDEMO.SP_QUERY", line 7
ORA-06512: at line 1
Check to ensure that the API is defined in the database and that the parameters match the signature of the API.
This exception is considered not retriable, likely due to a modelling mistake.
To classify it as retriable instead add property nonRetriableErrorCodes with value "-917" to your deployment descriptor (i.e. weblogic-ra.xml).
To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.
All properties are integers.
I am trying to have a Out Parameter in my Procedure. Please provide me an example on how to invoke a Stored Procedure using Out Paramter using DB Adapter.Hi,
It looks more like an Oracle error and not within the DbAdapter.
Try to test first your procedure from PL/SQL or other developer you are using.
Arik
Maybe you are looking for
-
A few questions about Canvas and other Image related stuff.
I am just starting to play around with Canvas in the hopes of using it to make a little game (not an applet) in my spare time. I have gotten a ball to bounce around the screen and switch colors when it bounces without too much work. (hooray for me!).
-
My CS can't start with error code 16
How can I find the CS5.5 serial number under MAC OS X if I want to reinstall it? My CS can't start with error code 16, it says configuration error.
-
GETWA_NOT_ASSIGNED short dump when load business partner master data
Hi I've this error GETWA_NOT_ASSIGNED short dump when load business partner master data, it's running in BI 7.0 with support package 12. The error is because the field symbol is that pointed to the line of an internal table that was deleted. I think
-
Can flex start a standard windows application
Hi I am building an application in flex 3 and I need it to be able start other windows application and pass information to that application via the command line, is this possible? I have not been able to find any thing that says it can or cannot, I a
-
Need assistance on 5800Xm internet
Hi alll, Just yesterday i have purchased the Nokia 5800XM. I am using Vodafone sim from india. I have Vodafone live and idont have the WWW service. Can i use maps using that? Can i use the push mails? as i am new to this kinda mobile pls help me Adva