Using values passed by parameters
I'm hoping someone can help me understand how to use the value provided in a parameter. I must pass 3 different parameters to 3 differetn output statements.
I am supplied with the following:
public class TestProgram {
* Method to assign parameter num to valueAmt
public void valueAmt(int num) {
public static void main(String[] args) {
//Create an object of type TestProgram to use for the testing
testProgram testItem = new TestProgram();
testProgram.valueAmt(133);
System.out.println .....
I am having trouble developing the statement(s) that I need to "pull" the 133 that is provided into a calculation in my System.out line. If is use 'num' in my calculation this does not work - does not find 'num'. I believe I am missing a statement or two.
Also, as I said, I must do this 3 times for 3 difft amounts. How do I do the 2nd and 3rd amounts - do I create 2 more objects such as testProgram testItem2 = new TestProgram2(), etc?
Thanks.
Have you looked at your stack trace to see what the error is?
It may be a typo, but
testProgram testItem = new TestProgram();
should be
TestProgram testItem = new TestProgram();
AND
testProgram.valueAmt(133);
should be
testItem.valueAmt(133);
As far as doing it three times, you could use a loop or simply call testProgram.valueAmt(someVal) from three println statements. Put the call right in the println statement. Although, since valueAmt returns void, it might be better to put the println statement in it and call it three times (loop or otherwise) from main.
-S.
Similar Messages
-
Filter Records in WHERE clause iReports using values passed from a prgram
I have searched for iReports manual and what i can see are docs on sale. I have managed to create jrxml file, execute it in jsp and actually view the report.
Now i have a big list of customers from various branches and have various categories. I would like to know how to pass the parameters so that i retrieve a small list of items. e.g. WHERE cu.branch=200 AND cu.category=10. That is i would like to pass 20 and 10 to the jrxml query stored.
In iReports i saw parameters, variables and fields but it seems like these are displayable fields.
How will i achieve this. Am seeking for assistance.
null>
Please help me to use an associate array in SQL query (WHERE clause).
select *
bulk collect into some_array
>
there is no variable 'some_array' in what you posted.
If you want help with your code you have to post the code you are really using, not some hacked-up version of it that has errors.
Here is sample code that shows how to treat a collection as a table using the TABLE operator
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
declare
tb emp_table_type;
deptnoList sys.OdciNumberList;
BEGIN
select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
bulk collect into tb from emp;
SELECT deptno bulk collect
INTO deptnoList
FROM dept where deptno not in (select deptno from table(tb));
for i in 1..deptnoList.count loop
dbms_output.put_Line(deptnoList(i));
end loop;
END;Note that tb is a collection and is useds in the subquery 'select deptno from table(tb)'. -
Use hyperlink to open another page , and pass some parameters to that page
Hi
Thank you for reading my post.
How i can use hyperlink to open another jsp file in a new window meanwhile pass some parameters to it.
for example i need something like this :
http://127.0.0.1:8080/myProj/faces/Viewmessage.jsp?messageID=10
i can not use session bean because i must open that in a new window and use hyperlink not Action
Thank youI tried the following in the equivalent of your Viewmessage (page bean):
ExternalContext eContext = FacesContext.getCurrentInstance().getExternalContext();
String text = "Parameters: ";
Iterator it = eContext.getRequestParameterNames();
Map requestParams = eContext.getRequestParameterMap();
while (it.hasNext()) {
String key = (String)it.next();
String value = (String)requestParams.get(key);
text += "; " + key + " = " + value;
staticText1.setText(text);That works as expected when you reach that new page via a hyper link.
The session object is also the same as in your `old' window. So be careful about synchronization!
I hope this helps.
-- Marco -
I am facing a problem in passing multiple values as out parameters from fo
Hi All,
i am facing a problem in passing multiple values as out parameters from for loop.
EX:
i have a select statment inside a loop like.....
PACKAGE SPEC:
create or replace PACKAGE EMP_PKG AS
TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
temp_table TAB_NUM;
procedure test(temp_TAB_e_no OUT TAB_NUM,
temp_TAB_e_name OUT TAB_NAME,
temp_TAB_e_job OUT TAB_JOB);
END EMP_PKG;
PACKAGE BODY:
create or replace PACKAGE BODY EMP_PKG AS
v_e_no NUMBER;
procedure test(temp_TAB_e_no OUT TAB_NUM,
temp_TAB_e_name OUT TAB_NAME,
temp_TAB_e_job OUT TAB_JOB) IS
BEGIN
select EMPNO bulk collect into temp_table from emp;
for i in 1..temp_table.count loop
v_e_no := temp_table(i);
select empno,
ename,
job
into temp_TAB_e_no(i),
temp_TAB_e_name(i),
temp_TAB_e_job(i)
from emp
where empno = v_e_no;
end loop;
end test;
END EMP_PKG;
PROBLEM FACING IS:
I am expecting all rows returning from bellow select statment ...
select empno,
ename,
job
into temp_TAB_e_no(i),
temp_TAB_e_name(i),
temp_TAB_e_job(i)
from emp
where empno = v_e_no;
But,while running the SP , i am getting error like
ORA-06531: Reference to uninitialized collection
ORA-06512: at "SCOTT.EMP_PKG", line 16
why i am not getting all values as out parameters.please provide a solution for me.
Thanks in advance my friend.user9041629 wrote:
Hi All,
i am facing a problem in passing multiple values as out parameters from for loop.
EX:
i have a select statment inside a loop like.....
PACKAGE SPEC:
create or replace PACKAGE EMP_PKG AS
TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
temp_table TAB_NUM;
procedure test(temp_TAB_e_no OUT TAB_NUM,
temp_TAB_e_name OUT TAB_NAME,
temp_TAB_e_job OUT TAB_JOB);
END EMP_PKG;
PACKAGE BODY:
create or replace PACKAGE BODY EMP_PKG AS
v_e_no NUMBER;
procedure test(temp_TAB_e_no OUT TAB_NUM,
temp_TAB_e_name OUT TAB_NAME,
temp_TAB_e_job OUT TAB_JOB) IS
BEGIN
select EMPNO bulk collect into temp_table from emp;
for i in 1..temp_table.count loop
v_e_no := temp_table(i);
select empno,
ename,
job
into temp_TAB_e_no(i),
temp_TAB_e_name(i),
temp_TAB_e_job(i)
from emp
where empno = v_e_no;
end loop;
end test;
END EMP_PKG;
PROBLEM FACING IS:
I am expecting all rows returning from bellow select statment ...
select empno,
ename,
job
into temp_TAB_e_no(i),
temp_TAB_e_name(i),
temp_TAB_e_job(i)
from emp
where empno = v_e_no;
But,while running the SP , i am getting error like
ORA-06531: Reference to uninitialized collection
ORA-06512: at "SCOTT.EMP_PKG", line 16
why i am not getting all values as out parameters.please provide a solution for me.
Thanks in advance my friend.Probably not a bad thing that this isn't working for you.
This is a horrible way to return the contents of a table.
Are you doing this for educational purpose, or ... what is your goal here? If you just want to return a result set to a client you'd want to look in to using a REF CURSOR and not a bunch of arrays combined with horribly procedural (slow) code. -
No value for given parameters error when using command parameters in RDC.
I am trying to create a report using RDC with a parameter in the query, but I keep getting "No value for given parameters" error. Here is the code I use:
Dim creport As CRAXDDRT.Report
Dim appn As CRAXDDRT.Application
Dim datcmd1 As New ADODB.Command
Dim adocn As New ADODB.Connection
Dim sqltext As String
Dim x As CRAXDDRT.ParameterFieldDefinition
Set appn = New CRAXDDRT.Application
Set creport = appn.NewReport
Set x = creport.ParameterFields.Add("test", 2)
x.AddCurrentValue 0
sqltext = "SELECT Name FROM TestTable WHERE ID={?test}"
Set adocn = New ADODB.Connection
adocn.Open "Provider=SQLOLEDB;Data Source=myDB;UID=xxx;PWD=xxx;"
Set datcmd1 = New ADODB.Command
Set datcmd1.ActiveConnection = adocn
datcmd1.CommandText = sqltext
creport.Database.AddADOCommand adocn, datcmd1
creport.SaveAs "test", crDefaultFileFormat
Set datcmd1 = Nothing
Set adocn = Nothing
Set creport = Nothing
Set appn = NothingHello, Paul;
If you add your database connection to the command object and put fields on your report without the parameter, do you get the report you expect?
These are version 8/8.5 samples but the code is the same:
[Note 1|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
[Note 2|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
Once you have added the database connection follow that with the parameter code.
[Note 3|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
[Note 4|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
If you add the parameter and put the field on the report, can you pass the value successfully?
Elaine -
Subroutine Pass by Value, Pass by Reference using xstring
Hi,
I am trying to check the difference between pass by value, pass by reference, pass by return value to a subroutine. When I tried integers as parameters the following functionality worked. When I am using xstring as parameters I am not getting desired results.
Some one please explain me how the xstring's are passed to a subroutine.
Here I am giving the code and output of the code.
data : s_passbyref type xstring,
s_passbyval type xstring,
s_passbyretval type xstring.
* Pass by Value, Pass by Reference, Pass by return value - STRINGS
s_passbyref = 'ABCD'.
s_passbyval = 'ABCD'.
s_passbyretval = 'ABCD'.
write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', s_passbyretval.
perform call_str_sub using s_passbyref s_passbyval changing s_passbyretval.
write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', s_passbyretval.
form call_str_sub using ps_passbyref value(ps_passbyval) changing value(ps_passbyretval).
ps_passbyretval = 'XYZ'.
ps_passbyref = 'XYZ'.
ps_passbyval = 'XYZ'.
endform.
OUTPUT
ByRef : ABCD By Val : ABCD By Return Value : ABCD
ByRef : By Val : ABCD By Return Value :
Thanks in advance
Naveentry this
write : / 'ByRef :', s_passbyref, 20 'By Val :', s_passbyval, 40 'By Return Value : ', ps_passbyretval. -
Passing Multiple Parameters values to a command- ORA-00907
I am trying to create a report in CR2008 using a SQL query against an Oracle 9i database. The field ( im."Report_No") I am using the parameter ({?CaseNo}) on is a VarChar, even though it only contains numbers. The number is 9 digits in the database (like 123456789), but is used differently by the users (12-456789) omitting the 3rd character. The query below works with a single value in the parameter, but returns ORA-00907 when multiple values are used.
SELECT im."Report_No"
--, ic."Report_No" Redundant from IM
, im."Reported_Date"
, im."Assignment"
, CASE
WHEN ip."Address" IS NOT NULL
THEN ip."Address"
WHEN ip."Address" IS NULL
AND ia."Address" IS NOT NULL
THEN ia."Address"
WHEN ip."Address" IS NULL
AND ia."Address" IS NULL
THEN im."Location"
END Address
, CASE
WHEN ip."City" IS NOT NULL
THEN ip."City"
WHEN ip."City" IS NULL
AND ia."City" IS NOT NULL
THEN ia."City"
WHEN ip."City" IS NULL
AND ia."City" IS NULL
THEN im."City"
END City
, CASE
WHEN ip."State" IS NOT NULL
THEN ip."State"
WHEN ip."State" IS NULL
AND ia."State" IS NOT NULL
THEN ia."State"
WHEN ip."State" IS NULL
AND ia."State" IS NULL
THEN 'NV'
END State
, CASE
WHEN ip."ZIP_Code" IS NOT NULL
THEN ip."ZIP_Code"
WHEN ip."ZIP_Code" IS NULL
AND ia."ZIP_Code" IS NOT NULL
THEN ia."ZIP_Code"
WHEN ip."ZIP_Code" IS NULL
AND ia."ZIP_Code" IS NULL
THEN im."ZIP_Code"
END Zip_Code
, ip."First_Name" || ' ' || ip."Last_Name" Name
, ip."Involvement"
FROM "TIBURON"."RP_INMAST_VIEW" im
INNER JOIN "TIBURON"."RP_INCASE_VIEW" ic
ON im."Report_No" = ic."Report_No"
INNER JOIN "TIBURON"."RP_INPER6_VIEW" ip
ON im."Report_No" = ip."Report_No"
LEFT OUTER JOIN "TIBURON"."RP_INADRS_VIEW" ia
ON ip."INPER6_ID" = ia."INPER6_ID"
WHERE im."Report_No" IN (substr({?CaseNo}, 1, 2))|| '0' || (substr({?CaseNo}, 4, 6))
AND ip."Involvement" = '{?InvCode}'
Thanks in advance for any help.
Edited by: James Cody on Dec 29, 2011 8:49 PMHi James,
Does the query accept commad separated values? Could you check if the query runs fine (with multiple values passed as a command separated string) on the database (using SQL+)?
-Abhilash -
Probs sharing a report that uses SETPARAM to pass multiple parameters
Ok we have master DB account Disco that creates reports. I also have oracle acct Duser for the users to run the reports.
Per Metalink Note:304192.1, we've got the setparam stuff working to pass in date parameters into our sheet. This works fine when I run the report as Disco. When I try to share the report to Duser, it still prompts for the dates, but then the report returns all 0's for the results. I have no idea why this is happening.
Any suggestions on how to share reports with other users that pass in parameters would be much appreciated. thanks!!
AllenHi Allen,
I would always recommend that you use sys_context to pass parameters. You can search this site for sys_context or take a look at (Re: Passing multiple parameters into Custom Folder... for more details.
Rod West -
Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API. This is a serious error and contributes to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
This console log is a note to the developers of whatever application you are using. You can safely ignore it.
-
How to pass request parameters using html:link in struts
Hi All,
I am trying to send parameters to action class using <html:link>.
Can anybody give sample code how to do it?
Thanks in advance.
By
K.Siva Prasad Reddyhi,
you can pass the parameters in link like this
http://www.xyz.com&username=someuserID&password=somePassword
username and password are parameters which you want to pass as paramets to server..hope this will work for you...
Thanks
Surya -
Passing multiple parameters to attribute value
Hi All,
My requirement is, the notification message should get a link, by clicking the user should navigate to the form. I kept the attribute type as form and attribute value as INV_INVIDITM:ITEM_ID=41817 where inv_inviditim is the form function name and item_id is the parameter.
The problem is when passing multiple parameters. I am passing multiple parameters as INV_INVIDITM:ITEM_ID=41817&ORG_ID=204.
Can any one help me to solve the above problem?
Thanks is advance.
SrinivasTry a different Database driver...
-
Passing String Parameters using forward tag
Hi...
Can anyone please tell me how to pass string parameters using the forward tag, and how to access it?
And while we're at it, can one pass a String variable using <forward> ?
Thanks... :-)PS...
Does anyone know what this error is:
NullPointerException at PageContext.forward(...) Thanks again... -
Using shell pass parameters with space to Java
Hi friends,
I have a shell script accepting parameters as below
#!/bin/sh
#test.sh
./setEnv.sh
java -classpath $CP com.rky.Main *$@*
CP=
If I run the script like this ./test.sh -annotation "This is a problem".
If shell pass the parameters to Java, the parameter "This is a problem" will recognized as 4 parameters by java. That's not what I want . I still need java use it as a whole parameter.
Do you have any easy ideas to resolve this problem out of my java code?
Thank you.yes, from the bash manpage:
@ Expands to the positional parameters, starting from one. When
the expansion occurs within double quotes, each parameter
expands to a separate word. That is, "$@" is equivalent to "$1"
"$2" ... If the double-quoted expansion occurs within a word,
the expansion of the first parameter is joined with the begin-
ning part of the original word, and the expansion of the last
parameter is joined with the last part of the original word.
When there are no positional parameters, "$@" and $@ expand to
nothing (i.e., they are removed).(your manpage could be a little different because of versions, and I got this from the manpage of bash on a mac. but the main things should apply) -
Pass two parameters using extraParams attribute in protlet:createWebFlowURL tag
Ho do I pass two parameters using extraParams attribute in portlet:createWebFlowURL?
<portlet:createWebFlowURL event="RTFM" extraParams="read=manual&do=you">
"Linda" <[email protected]> wrote:
>
Ho do I pass two parameters using extraParams attribute in portlet:createWebFlowURL? -
USING A PASSING PARAMETERS IN A REPORT
I don't know how to use a passing parameter in Reports.
I have a form in which i have a button with the following trigger WHEN-BUTTON-PRESSED :
DECLARE
p1_id ParamList ;
BEGIN
p1_id:=Create_Parameter_List('tmpdata');
Add_Parameter(p1_id,'LOCATIA',TEXT_PARAMETER,:VLOCATIA);
Run_Product(REPORTS,'c:\arhiva\rapstoc\incercare.rdf',SYNCHRONOUS,RUNTIME,FILESYSTEM,p1_id,NULL);
END;
I don't know how to use this passing parameter in my report. This report have a trigger in which I have to use this parameter.hello,
create a user-parameter in your report and use the name you used in the ADD_PARAMETER command in forms.
you can then access the parameter from inside your PLSQL logic in reports using the bind syntax (e.g. :myParameter)
regards,
the oracle reports team --pw
Maybe you are looking for
-
Using Apple Tv as a wireless connection to second monitor
I gather from reading here that AppleTv will only display iTunes content Is there a third party solution to allow anything on my computer to display on my tv also? Also curious why Apple locked this great device to only display iTunes content and not
-
Using Oracle 8i DB in SOA suite 11g
Hi All, Good Morning.. Hope all are doing good. I need a permanent solution or some work around for my below issue: We were on SOA suite 10.1.3.4 and now we are migrating to SOA suite 11.1.1.5 We have legacy system which has Oracle 8i DB. For some of
-
I made the chapter titles in dvd pro but they come out very bad quality even though I tried changing the font. Any idea what the problem might be?
-
why does it keep asking me to install adobe flash player even after i have installed it once? Please help me.
-
Time Zone Problem with jdk1.4.2_04
I have changed my jdk from 1.3 to 1.4.2. C . Now im getting a Time zone exception. exception is : nested exception is: java.lang.ClassNotFoundException: Class bytes found but defineClass() failed with java.lang.UnsupportedClassVersionError: sun/