Assign dynamic statement in declare block or begin block
Hi all,
For below code, if I assign the select statement in the declare section for corresponding variable, will it improve the performance.
For cust_veh_id we have another cursor in declare block, only partial code is provided.
What I meant.
declare
v_addr_chg_stmt varchar2(2000) := 'select ''Y''
FROM cust_addrs addrs
WHERE customer_id = :v_customer_id
AND updated_date >:p_end_date
and rownum = 1';Actaul
declare
p_end_date date;
v_addr_chg_stmt varchar2(2000);
v_mileage_stmt varchar2(2000);
begin
select updated_date into p_end_date
from process_log_rfsh
where tran_code ='CAP';
v_addr_chg_stmt :=
'select ''Y''
FROM cust_addrs addrs
WHERE customer_id = :v_customer_id
AND updated_date >:p_end_date
and rownum = 1'
v_mileage_stmt :=
'SELECT ''Y'' FROM cust_vehicles_audit
WHERE cust_veh_id=:v_cust_veh_id
AND field_name =''LAST_MILEAGE''
AND added_date > :p_end_date
and audit_date >= trunc(:p_end_date)
and rownum=1'
begin
execute immediate v_addr_chg_stmt
into v_addr_change_flag
using v_customer_id, p_end_date;
exception
when no_data_found then
v_addr_change_flag:='N';
end;
begin
execute immediate v_mileage_stmt
into v_mileage_change_flag
using v_cust_veh_id, p_end_date, p_end_date;
exception
when no_data_found then
v_mileage_change_flag:='N';
end;
end;Thanks
Raghu
Edited by: Raghu on 18 Jan, 2013 1:13 PM
Raghu wrote:
This code is already running in production from few years.Not a valid reason to justify using dynamic SQL.
YOU NEED JUSTIFICATION FOR USING DYNAMIC CODE. In any language.
Again: WHAT is your justification? If you cannot provide that, then why are you using dynamic code??
If we have to use dynamic sql, performance wise defining in declare block or begin will be better.No difference - as neither method changes the actual SQL cursor executed. Neither makes the resulting cursor read data blocks faster.
PL/SQL also does not care where variable assignment happens. The difference is so tiny and so small, it is irrelevant to performance:
SQL> declare
2 t1 timestamp;
3 begin
4 --// test 1
5 t1 := systimestamp;
6 for i in 1..10000 loop
7 declare
8 num number;
9 begin
10 num := 1;
11 end;
12 end loop;
13 dbms_output.put_line( 'Test 1. '||to_char(systimestamp-t1) );
14
15 --// test 2
16 t1 := systimestamp;
17 for i in 1..10000 loop
18 declare
19 num number := 1;
20 begin
21 null;
22 end;
23 end loop;
24 dbms_output.put_line( 'Test 2. '||to_char(systimestamp-t1) );
25
26 end;
27 /
Test 1. +000000000 00:00:00.000040000
Test 2. +000000000 00:00:00.000024000
PL/SQL procedure successfully completed.
SQL>
Similar Messages
-
PL/SQL declaration blocks within procedure
Greetings,
I have a few PL/SQL scripts that I would like to deploy to the database as stored procedures, but I am having a bit of trouble. The scripts themselves are all over 400 lines and contain multiple declaration blocks, some with multiple cursors in each block. I believe the problems I am encountering revolve directly around these declarations blocks and cursors, which are mandatory for these scripts. Here is a sample of the errors I am receiving:
SQL> SHOW ERRORS
Errors for PROCEDURE *:
LINE/COL ERROR
56/20 PL/SQL: SQL Statement ignored
57/25 PL/SQL: ORA-00942: table or view does not exist
66/20 PL/SQL: SQL Statement ignored
71/70 PL/SQL: ORA-00942: table or view does not exist
127/11 PL/SQL: SQL Statement ignored
128/16 PL/SQL: ORA-00942: table or view does not exist
144/16 PL/SQL: Statement ignored
144/21 PLS-00364: loop index variable * use is invalid
156/16 PL/SQL: Statement ignored
157/36 PLS-00364: loop index variable * use is invalid
189/16 PL/SQL: Statement ignored
189/20 PLS-00364: loop index variable * use is invalid
211/16 PL/SQL: Statement ignored
231/24 PLS-00364: loop index variable * use is invalid
268/25 PL/SQL: SQL Statement ignored
272/48 PLS-00364: loop index variable * use is invalid
272/48 PL/SQL: ORA-00904: *.*: invalid identifier
292/21 PL/SQL: Statement ignored
292/26 PLS-00201: identifier *.* must be declared
345/46 PLS-00201: identifier * must be declared
SQL>
Unfortunately, I cannot paste any of the script itself, nor can I be more descriptive with the error log. That being said, it would be extremely helpful to me to receive any input whatsoever from the community, as even something only vaguely related may push me in the right direction. Mainly, I need to figure out if these errors are generated due to the reasons I suspect.
I must note that these scripts execute correctly and perform their necessary tasks when either pasted into the editor or when executed directly from their respective .sql files.
Thank you for the help.
-JNTSQL> ed
Wrote file afiedt.buf
1 declare
2 v_variable1 varchar2(10);
3 v_variable2 varchar2(10);
4 v_variable3 varchar2(10);
5 begin
6 select alpha into v_variable1 from x;
7 For i in 1..i+2 loop
8 null;
9 end loop;
10 v_variable4 := v_variable3;
11* end;
SQL> /
select alpha into v_variable1 from x;
ERROR at line 6:
ORA-06550: line 6, column 36:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 6, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 7, column 13:
PLS-00364: loop index variable 'I' use is invalid
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored
ORA-06550: line 10, column 1:
PLS-00201: identifier 'V_VARIABLE4' must be declared
ORA-06550: line 10, column 1:
PL/SQL: Statement ignored
The table 'x' does not exist or I do not have access to it.
I cannot specify the loop interval as indicated.
I cannot assign a value to a variable that does not exist.
1 declare
2 v_variable1 varchar2(10);
3 v_variable2 varchar2(10);
4 v_variable3 varchar2(10);
5 v_variable4 varchar2(10);
6 begin
7 select alpha into v_variable1 from dual;
8 For i in 1..2 loop
9 null;
10 end loop;
11 v_variable4 := v_variable3;
12* end;
SQL> /
select alpha into v_variable1 from dual;
ERROR at line 7:
ORA-06550: line 7, column 8:
PL/SQL: ORA-00904: "ALPHA": invalid identifier
ORA-06550: line 7, column 1:
PL/SQL: SQL Statement ignored
There is no column by name 'alpha' in table 'dual'.
SQL> ed
Wrote file afiedt.buf
1 declare
2 v_variable1 varchar2(10);
3 v_variable2 varchar2(10);
4 v_variable3 varchar2(10);
5 v_variable4 varchar2(10);
6 begin
7 select dummy into v_variable1 from dual;
8 For i in 1..2 loop
9 null;
10 end loop;
11 v_variable4 := v_variable3;
12* end;
SQL> /
PL/SQL procedure successfully completed.
Here is the corrected script. I hope it helps. -
Help with dynamic statement returning values into collection
Hi All
I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
create table t(
pk number,
id_batch varchar2(30),
date_created date,
constraint t_pk primary key ( pk )
create or replace type num_ntt is table of number;
create or replace type vc2_ntt is table of varchar2(30);
create or replace
package pkg
as
type rec is record(
pk num_ntt,
id_batch vc2_ntt
procedure p(
p_count in number,
p_rt out nocopy rec
end pkg;
create or replace
package body pkg
as
procedure p(
p_count in number,
p_rt out nocopy rec
is
begin
execute immediate '
insert into t
select level, ''x'' || level, sysdate
from dual
connect by level <= :p_count
returning pk, id_batch into :pk, :id_batch'
using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
end p;
end pkg;
declare
r pkg.rec;
begin
pkg.p( 5, r );
end;
/sanjeevchauhan wrote:
but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
Regards,
Rob. -
Unreachable statement or declaration
I don't know why i'm getting this error. I looked up the error on the Sun site and it says that you get this error when you have code below a return statement like
return x
int x=5
but i don't have anything like that going on in my code heres my code below. The error is coming from the return playerscard line at the very end of the code. Any help at all would be really appreciated. Thanks
public class Blackjack
private int playershand = 0; // declare variable for playershand
private int dealershand = 0; // declare variable for dealers hand
private String playerscard = ""; // declare variable for the card for the player
private String status = ""; // declare variable for game messages
String cardname[]= {"ace","deuce","three","four","five","six","seven","eight",
"nine", "ten", "jack", "queen", "king", "ace",
"ace","deuce","three","four","five","six","seven","eight",
"nine", "ten", "jack", "queen", "king", "ace",
"ace","deuce","three","four","five","six","seven","eight",
"nine", "ten", "jack", "queen", "king", "ace",
"ace","deuce","three","four","five","six","seven","eight",
"nine", "ten", "jack", "queen", "king", "ace"};
int cardvalue[] = {1,2,3,4,5,6,7,8,9,10,10,10,10,11,
1,2,3,4,5,6,7,8,9,10,10,10,10,11,
1,2,3,4,5,6,7,8,9,10,10,10,10,11,
1,2,3,4,5,6,7,8,9,10,10,10,10,11};
int cardspicked[]= new int[56];
int hand = 0;
// constructor
public Blackjack()
}// end blackjack name
// create deal method
public String deal()
// randomly generate a number between and 56 and assign to the
// cardvalue[] array while this cardvalue is equal to cardspicked
do {
int hand = (int) (Math.random() * 56);
} while ( cardvalue[hand] == cardspicked[hand]);
// add the random cardvalue[hand] to the playershand and the random
// cardname to the playerscard.
playershand += cardvalue[hand];
playerscard = cardname[hand];
// add the card selected to the cardspicked[] array
cardvalue[hand] = cardspicked[hand] ;
return Integer.toString(playershand);
return playerscard;
}Within a given block, once return is called, the rest of the code in the block will not get executed (since the thread of control "returns" to the caller) and is thus unreachable.
Since your two return statements are in the same block - in this case a method - the second return (and, in fact, anything after the first return) is unreachable.
However, you can do something like:
public String example( int a ) {
if( (a % 2) == 0 ) {
return "Even";
else {
return "Odd";
}In this case, we have code after the first return. Note that the most narrow block in which the return "Even"; statement appears. It is an if statement, not a method. The return is the last statement in its block. The remaining statement(s) (the "else" block) is still reachable when a mod 2 equals zero.
If you need to return multiple values, create a new class and return an instance of that class. -
How to use union statement with declare & set function?
Hi Experts,
i have small query about how to use union statement with declare & set function?
Example as below :
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]You have to create stored procedure in SQL only .
Like u must have create for Crystal .
You can execute procedure in query manager but you have to enter parameter manually..
example
Exec @Test '20140101' '20140501'
Every time user has to enter it manually in yyyymmdd format in case of date parameters.
Example
Create Proc [@Test]
as begin
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between
between @Name and @Name2
end -
Create "dynamic" statements in a stored procedure
hello
in my stored procedure I need to write a statement like this:
FUNCTION myfunct (mytable IN VARCHAR2)
BEGIN
EXECUTE IMMEDIATE
'SELECT COUNT(*)
INTO myvar
FROM ' || mytable ||
'WHERE mycol = ' || currval;
In short I need to create a sort of "dynamic" statement in which the tablename (nad other...) is a variable....
but I do not guess it's ok...
How can I do?Hi,
With dyanmic SQL, the INTO clause is part of the EXECUTE IMMEDIATE statement, not the query.
Try something like this:
CREATE OR REPLACE FUNCTION myfunct
( mytable IN VARCHAR2
RETURN PLS_INTEGER
IS
return_num PLS_INTEGER;
sql_txt VARCHAR2 (1000);
BEGIN
sql_txt := 'SELECT COUNT (*)'
|| ' FROM ' || mytable;
dbms_output.put_line (sql_txt || ' = sql_txt in myfunct');
-- EXECUTE IMMEDIATE sql_txt INTO return_num;
RETURN return_num;
END myfunct
/It's a good idea to develop dynamic SQL as shown above; putting the dynamic statement into a variable that can easily be displayed for debugging.
When it looks right, then un-comment the EXECUTE IMMEDAITE statement.
Before moving the code into Production, comment out (or remove) the put_line statement. -
Error on out.println inside declaration block
I am trying to generate a html page from a method iside the jsp page. When I use out.println inside the declaration block (<%! ---- %>) I am getting following error : "Undefined variable or class name: out".
I have tried using System.out.println, but that sends the output to the consol, and not the html page.
What is the workaround for this ??
Following is the test jsp page to illustrate the problem:
<%@page language="java" %>
<%@page import="wt.doc.*" %>
<%@page import="wt.fc.*" %>
<%@page import="wt.query.*" %>
<jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="request"/>
<jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>
<html>
<body>
<%!
public void prntest(){
System.out.println("This will print the message only to console");
out.println("This does not work");
%>
<h1>This is to test out.println function</h1>
<%
out.println("<br>This out.println statement works as expected<br>");
%>
<br>Now try this<br>
<%prntest();%>
</body>
</html>Hai ,
Here you are trying to access implict object "out" outside the Scriplets ie in function outside the init/service method .
To get output from prntest() , you have pass a reference of JspWriter out to it .ie Your function should be
<%!
public void prntest(JspWriter out2){
System.out.println("This will print the message only to console");
out2.println("This does not work");
%>
<%prntest(out);%>
This should now work .
rakesh -
Dynamic vs. Declarative HtmlDataTable pagination/scolling issue
I've been struggling with trying to create a paginating HtmlDataTable dynamically to replace my current jsf declarative datatable. I've tried to crib from the BalusC examples and multiple google searches. I've removed a lot of the 'read-only' data column
Here's the current declarative jsp code with my dynamic hook added to it:
<h:panelGroup binding="#{searchHandler.searchResults}"/>
///// Original code to be replaced with the above dynamic control
<center><h1><h:outputText value="#{i18n.searchResults}"/></h1></center>
<h:messages style="color:#FF0000;" globalOnly="true"/>
<f:subview id="searchResultsControls" rendered="#{myResultsHandler.hasResults}">
<h:form id="mySearchResultsForm">
<h:dataTable border="1" cellspacing="2" cellpadding="2"
first="#{myResultsHandler.firstRowIndex}"
id="searchResultsId"
rows="#{myResultsHandler.noOfRows}"
rowClasses="oddRows, evenRows"
value="#{myResultsHandler.results}"
var="result" width="100%">
<h:column>
<f:facet name="header" ><h:outputText value="#{i18n.username}"/></f:facet>
<h:commandLink action="#{userDetailsHandler.selectUserToSeeDetails}" value="#{result.userName}">
<f:param name="userId" value="#{result.userId}" />
</h:commandLink>
</h:column>
</h:dataTable>
<h:commandButton id="declNext" value=">" disabled="#{myResultsHandler.scrollNextDisabled}" action="#myResultsHandler.scrollNext}" />
</h:form>
</f:subview>And here is my dynamic code I'm trying to use to replace it.
private HtmlPanelGroup searchResults;
public HtmlPanelGroup getSearchResults() {
searchResults = (HtmlPanelGroup) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlPanelGroup.COMPONENT_TYPE);
searchResults.setId("dyn_SRPanel");
final HtmlForm form = (HtmlForm) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlForm.COMPONENT_TYPE);
form.setId("dyn_CustForm");
final HtmlDataTable table = new HtmlDataTable();
table.setFirst(myResultsHandler.getFirstRowIndex());
table.setId("dyn_my_results_table");
table.setBorder(1);
table.setCellpadding("2");
table.setCellspacing("2");
table.setRowClasses("oddRows, evenRows");
table.setRows(myResultsHandler.getNoOfRows());
table.setValueExpression("value", createValueExpression("#{myResultsHandler.results}", List.class));
table.setVar("dyn_result");
table.setWidth("100%");
final HtmlColumn actionColumn = new HtmlColumn();
table.getChildren().add(actionColumn);
final HtmlOutputText commandHeader = new HtmlOutputText();
commandHeader.setValueExpression("value", createValueExpression(resultHeaders[0], String.class));
actionColumn.setHeader(commandHeader);
HtmlCommandLink action = new HtmlCommandLink();
action.setValueExpression("value", createValueExpression("#{dyn_result.userName}", String.class));
action.setActionExpression(createActionExpression("#{userDetailsHandler.selectUserToSeeDetails}", String.class));
final UIParameter param = new UIParameter();
param.setName("userId");
param.setValueExpression("value", createValueExpression("#{dyn_result.userId}", Long.class));
action.getChildren().add(param);
actionColumn.getChildren().add(action);
form.getChildren().add(table);
final HtmlCommandButton scrollNext = (HtmlCommandButton) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlCommandButton.COMPONENT_TYPE);
scrollNext.setValue(">");
scrollNext.setId("dyn_next");
scrollNext.setDisabled(myResultsHandler.isScrollNextDisabled());
final FacesContext facesContext = FacesContext.getCurrentInstance();
MethodExpression expr= facesContext.getApplication().getExpressionFactory().createMethodExpression(
facesContext.getELContext(), "#{myResultsHandler.scrollNext}", String.class, new Class[]{});
scrollNext.setActionExpression(expr);
form.getChildren().add(scrollNext);
searchResults.getChildren().add(form);
return searchResults;
}Now here's the odd thing, the dynamically created table doesn't scroll through the results like the declarative table. I've check the JSF event flow and the actions get invoke for the declarative/dynamic controls at the correct place in the event trace, but only the declarative version actually shows the correct model state. When either the dynamic or the declarative button are pressed, the correct backing action is called. All of the beans are session scoped.
What have I missed/messed up?
Thanks,Yes, the action method gets invoked no matter if the dynamic or declarative button is pressed. In both cases, the table model is delegating to the same back end. I'm trying to re-wire this declarative component into a dynamic form. The correct list is being returned in both instances, as far as I can tell the next button event is called in the exact same place in the JSF event flow in both cases.
One curious thing I have noticed, is that if I click through the command link to the 'details' page, when I come back to the result table page both views are in sync with the same model state. I.e. the dynamic table will have been 'scolled' properly. I'm not sure if that is a useful clue or just an odd side-effect.
Thanks for your help so far though, I've spent 2.5 days trying to work through this. -
EXECUTE IMMEDIATE dynamic statement and return procedure value
Hello guys,
How can i return values from procedure using EXECUTE IMMEDIATE statment?
I made easy example:
CREATE OR REPLACE PACKAGE pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER);
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER)
IS
BEGIN
v_out:=(p_age_1+p_age_2+p_age_3)/3;
END pro_calc_average;
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER)
IS
x number;
v_sql varchar2(4000);
BEGIN
v_sql:='pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x)';
dbms_output.put_line(v_sql);
EXECUTE IMMEDIATE v_sql;
dbms_output.put_line(' ====> '||x);
END pro_calc;
END;
-- Run procedures [Faild]
EXEC pac_test.pro_calc(2,9,19);
When i run:
DECLARE
x number;
BEGIN
pac_test.pro_calc_average(2,9,9,x);
dbms_output.put_line(' ====> '||x);
END;
It's works, but this is not what i am looking for.
Thank you guys,
Sam.Hi Sam,
Like this?
CREATE OR REPLACE PACKAGE pac_test
IS
pac_var number; /* added new*/
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER);
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER)
IS
BEGIN
v_out:=(p_age_1+p_age_2+p_age_3)/3;
END pro_calc_average;
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER)
IS
pack_local_var number;
v_sql varchar2(4000);
BEGIN
--v_sql:='pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x)';
v_sql:=' declare x number; begin pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x);
dbms_output.put_line(x);
pac_test.pac_var:=x; /* added new*/
end;';
dbms_output.put_line(v_sql);
EXECUTE IMMEDIATE v_sql;
pack_local_var:=pac_var; /* added new*/
dbms_output.put_line(pack_local_var); /* added new*/
END pro_calc;
END;Declared a package variable.
But be aware this variable is accessible to everyone and they can read or change its value if they have the right privileges.
REgards,
Bhushan -
Error:xml declaration may only begin enttties
my problem is that the code by the name DomEcho01.java in this tutorial
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
compiles fine but at run time it gives me an error saying
"error:xml declaration may only begin enttties "
can ne1 tell me y is this happenin
thanx
sam<?xml version='1.0' encoding='utf-8'?>
<!-- A SAMPLE set of slides -->
<slideshow
title="Sample Slide Show"
date="Date of publication"
author="Yours Truly"
>
<!-- TITLE SLIDE -->
<slide type="all">
<title>Wake up to WonderWidgets!</title>
</slide>
<!-- OVERVIEW -->
<slide type="all">
<title>Overview</title>
<item>Why <em>WonderWidgets</em> are great</item>
<item/>
<item>Who <em>buys</em> WonderWidgets</item>
</slide>
</slideshow>i am using the same xml file that is given in the tutorial -
Return statement in catch block !
Hello Java Gurus,
The code is not compiling when i remove return from the catch block
i dont really understand the essence of return statement in catch block
any help is greatly appreciated !
Thanks in advance !
import java.io.*;
public class fileinputstream {
public static void main(String arg[]) {
FileInputStream fin ;
FileOutputStream fout;
try {
fin =new FileInputStream("input_file.txt");
int bytes_av = fin.available();
System.out.println("bytes available the input file "+bytes_av);
catch(FileNotFoundException e)
System.out.println("The input file is not present");
return;
catch(IOException e)
System.out.println("error while giving bytes available the input file");
return;
try
fout =new FileOutputStream("output_file.txt");
catch(FileNotFoundException e)
System.out.println("The output file cannot be created");
return;
int data=0;
try {
data =(int)fin.read();
catch(IOException e) {
System.out.println("Exception while reading from file");
while(-1!=data) {
try
fout.write(data);
catch(IOException e)
System.out.println("Error while writing to file");
try
data =(int)fin.read();
catch(IOException e)
System.out.println("Exception while reading from file");
try {
fin.close();
fout.close();
catch(IOException e) {
System.out.println("Error while closing files");
}You do understand what "return" means, don't you? It
exits the method, main() in this case.
So the return statements in the catch blocks end the
program. If you remove the return statements, the
program will continue with the code after the catch
blocks. It needs the variables "fout" and "fin"
there, and these must be initialised.
If there are no return statements in the catch
blocks, the variables "fin" and "fout" will be not
initialized when you get to the code that uses them,
and that's an error. The java compiler is telling you
that you must always initialise the variables (you
can set them to "null", for example).Great explanation !!!
Thanks ! -
State tax declaration for Mexico
Hello all
We are trying to obtain the report for the State tax declaration on Mexico, but we have some troubles with one state (Veracruz), if I run the report for some months of 2010 it shows me the text "There are no data for the selection conditions", obviously we have the payroll for those months, and we have employees for that state. Does anyone know why we cannot see results for all months?
Thank you in advance.We found a configuration error on Infotype 0561 date for our employees.
-
How to assign dynamic image at runtime or on Button Action to a Image UI
Hi,
Please let me know is it possible to assign Dynamic Images to Image UI element in a Visual Composer applications. Using Image Manager it is possible, but in my case Image Source i.e URL comes from ABAP RFC, so is it possible to assign Image at runtime.
Please do let me know is it possible or not, If yes please do share your opinions.
I am able to show image using HTML Page by passing URL at runtime to HTML page but here, I cant control the Image width & height.
I am checking for possibility of using some script to manage width & height.
Thanks a Ton.
Regards
TusharHi,
Any inputs for the Query? Atleast, If I get some hint, will do to proceed....
Regards
Tushar Shinde -
Should Output parameters always be declare at the beginning of the Stored Procedure?
Should Output parameters always be declare at the beginning of the Stored Procedure?
Usually input parameters listed first followed by output parameters. This is just a custom, not a requirement.
Blog: How to architect stored procedure parameters?
BOL: http://msdn.microsoft.com/en-us/library/ms187926.aspx
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
Problem in Dynamic Parallel processing using Blocks
Hi All,
My requirement is to have parallel approvals so I am trying to use the dynamic parallel processing through Blocks. I cant use Forks since the agents are being determined at runtime.
I am using the ParForEach block. I am sending the &agents& as a multiline container in 'Parallel Processing' tab. I have user decision in the block. Right now i am hardcoding 2 agents in the 'agents' multiline element. It is working fine..but i am getting 2 instances of the block.I understand that is because I am sending &AGENTS& in the parallel processing tab.. I just need one instance of the block going to all the users in the &AGENTS& multiline element.
Please let me know how to achieve the same. I have already searched the forum but i couldnt find anything that suits my req.
Pls help!
Regards,
SoumyaYes that's true when ever you try to use ParForEach block then for each value entry in the table a separate workitem ID is created, i.e. a separate instance is created that paralle processing is not possible like that
Instead of that what you can do is create a fork with 3 branches and define a End Condition such that until all 3 branches are executed .
Before to the fork step determine all the agents and store them in a internal table , you can access the one internal table entry by using the index value check this [wiki|https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/accessingSingleEntryfromMulti-line+Element] to access single entry from a internal table.
For each task in the fork assgin a agent
So, as we have defined the condition that until all the three branches are executed you don't want to come out of the fork step so, it will wait until all the stpes are completed.
Maybe you are looking for
-
Need to know what to do with new phone and no screen and no support from Telus Store
Purchased a brand new BB Curve 8530, and resigned another three year plan at Telus. Within 20 days, the screen went black and would not light up. I had used the phone in the morning to send a textmail, then set it on the charger. Later in the day, I
-
India | Excise | Jobwork | How to handle excise in Jobwork ?
Hi all, In India, I am working on a project where my customer is a manufacturer and out source some of his production process by sending material to Job Work vendor. Now when the Customer receives the processed material back, it is possible that ther
-
New ipod touch 4th gen restore stops responding
it has been on the restore mode for HOURS. i have followed all instructions to unplug and reset it and try the restore again. Each and every time the restore stops at the same exact spot and does NOT move at all. i have tried it 4 times and i am star
-
Jquery UI effect for onload event
I'm trying to create a fade in effect on a rollover image using the jquery appear/fade effect. It works successfully with the default "onClick" event, but I'd like the rollover image to appear (fade in) gradually over time as the browser window open
-
Not turning page over for blank 2nd side
I have a Canon MX850 all-in-one with duplex printing. My default print Preset is duplex. If I print a 1-sided document, it prints the first side, then draws the page back in as if it were going to print on the 2nd side, waits a bit, then prints nothi