Assign variable
What is the difference:
if I write
public class Test
static final String ImeDat="joga1.gif";
public static void main (String args[]) throws Exception
try {
System.out.print("Connecting to the Database. Please wait..");
//Load the Oracle JDBC Driver and register it.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database:
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger");....
I get NO ERROR message during compiling
BUT
public class Test
static final Connection conn;
static final String ImeDat="joga1.gif";
public static void main (String args[]) throws Exception
try {
System.out.print("Connecting to the Database. Please wait..");
//Load the Oracle JDBC Driver and register it.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database:
conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger");...
I always get
C:\xsu>javac Test.java
Test.java:41: Can't make a static reference to nonstatic variable conn in class
Test.
conn =
^
1 error
C:\xsu>javac Test.java
Test.java:17: Blank final variable 'conn' may not have been initialized. It must
be assigned a value in an initializer, or in every constructor.
public class Test
^
Test.java:41: Can't assign a second value to a blank final variable: conn
conn =
^
2 errors
null
In the inspector for your "on" button, set the audio stream to whatever stream you want. for the "off" button set it to the other stream. dont forget to assign the action you want the button to take (ie - jump to main menu:play.) You can also do this with a script as well
Similar Messages
-
Garbage Collection facilitation by assigning variables to null
Hello,
I understand Garbage Collection (GC) can be facilitated by assigning variables to null. Is this true for all variables?
I have a class and there are some member variables which are strings. Also i have some methods with some string variables declared and defined inside the method. I am assigning null to class member variables and also the string variables of the method.
is it correct to assign null and faciliate GC for the string variables declared and defined inside the method?
Class A {
String t1;
public void test() {
String t2 = "test";
// processing
t2 = null; // Will this facilitate GC?
public static void main (String[] args) {
test();
A obj = new A();
A.t1 = "testclass";
A.t1 = null; // Will this faciliate GC?
Thanks, AravinthIn fact, the java heap is divided into a space for new allocations, and two survivor spaces. The algorithm for when collection occurs in each space is complex, and tuning GC is an interesting topic all its own. Follow the best advice you have been given ... chillax. The JVM has GC under control.
<think/> Of course, having said this, you can have memory leaks if you create references that never go out of scope, even if they are no longer used. Avoid this.
� {� -
Assigning variable value to another variable
I want to assign value from one variable with type DATETIME to another variable which has type STRING.
E.G: I need to convert this variable P_CreatedDate of type DATETIME to STRING variable CreatedDate.
Can someone help me in C# script. Im using SSIS script task.
Thanks in advance.
ZKI have a requirement where I need to convert following datetime variable value into the string vaiable format.
Here is the example:
7/23/2014 11:24 PM
I need above datetime to be converted into following string format
2014-01-01 03:15:01.470
yyyyMMdd HHmmssFFF
Thanks in advance.
ZK -
Why assign variable doesn't work
In my test in sqlplus:
variable testa number;
select max(length(name)) into :testa from myschema.tabletest;MAX(LENGTH(NAME))
6
print :testa;TESTA
----------You have to assign the value in pl/sql:
SQL> begin
2 select 5 into :testa from dual;
3 end;
4 /
Procedura PL/SQL completata correttamente.
SQL> print testa
TESTA
5Max
http://oracleitalia.wordpress.com -
SQL query returns value but EXEC SQL Task fails to assign variable
I have an execute SQL task to get an identifier from an Oracle database and assign it to a variable (the variable is used in subsequent query's where clauses to transfer the data to a SQL Server database). If I copy the query from the SSIS
package to the Oracle SQL Developer interface and run the query; I get the expected single identifier. If I run the execute SQL task I get the error "[Execute SQL Task] Error: An error occurred while assigning a value to variable "VariableName":
"Single Row result set is specified, but no rows were returned."
I can create phony/simpler versions of the query that will return the wrong identifier that will successfully assign the value to the variable, so the problem isn't with the variable itself or the way the result set is set up in the task (Result
Set/Single Row in the General panel; Result Name 0/VariableName in the Result Set panel).
How can two queries that return a single value produce different results with respect to the variable assignment process?Perhaps you can trap (profile) the query in Oracle to see what it gets submitted,
thing is this query
select id from table where ProcessedStatusColumn is null and DateColumn = (sub select to get most recent date in table where ProcessedStatusColumn is null)
is not guaranteed to return a value, you need a default returned in case the search failed e.g.
select
NVL(id, 0)
from table where ProcessedStatusColumn is null and DateColumn =
(sub select to get most recent date in table where
ProcessedStatusColumn is null)
Arthur My Blog -
Dynamically assigning variables based on condition in pl/sql
I have a script which takes 6 input parameters but based on input 1 parameters 2 to 6 will be assigned to different variables. but the condition is not being checked during variable assignment phase. even if table_update is 'P' para,mater 2 is getting assigned to tariff_group instead of offer_id. Is there any way to solve this problem so that variables get assigned based on condition.
table_update := '&1';
if(table_update = 'T')
THEN
tariff_group := '&2';
gf_version := &3;
tariff_table_name := '&4';
flag := '&5';
if(no_rows_tariff(tariff_table_name, gf_version, tariff_group))
THEN
if(flag = 'I')
THEN
tariff_column_name := column_tariff(tariff_table_name);
ELSIF(flag = 'R')
THEN
max_gf_tariff(tariff_table_name, gf_version, tariff_group);
ELSE
DBMS_OUTPUT.PUT_LINE('Please enter correct option for update I- Insert R-Rollback');
END IF;
END IF;
ELSIF(table_update = 'P')
THEN
offer_id := &2;
gf_version := &3;
promotion_table_name := '&4';
flag := '&5';Although you do not say what your problem is, I suspect that it si something like this:
SQL> !cat t.sql
DECLARE
table_update VARCHAR2(1);
tariff_group VARCHAR2(3);
gf_version NUMBER;
tariff_table_name VARCHAR2(5);
offer_id NUMBER;
promotion_table_name VARCHAR2(5);
flag VARCHAR2(1);
BEGIN
table_update := '&1';
IF table_update = 'T' THEN
tariff_group := '&2';
gf_version := &3;
tariff_table_name := '&4';
flag := '&5';
ELSIF table_update = 'P' THEN
offer_id := &2;
gf_version := &3;
promotion_table_name := '&4';
flag := '&5';
END IF;
DBMS_OUTPUT.Put_Line ('TableUpdate: '||table_update);
DBMS_OUTPUT.Put_Line ('TariffGroup: '||tariff_group);
DBMS_OUTPUT.Put_Line ('GfVersion: '||gf_version);
DBMS_OUTPUT.Put_Line ('Tarifftable: '||tariff_table_name);
DBMS_OUTPUT.Put_Line ('OfferID: '||offer_id);
DBMS_OUTPUT.Put_Line ('PromoTable: '||promotion_table_name);
END;
SQL> @t T TG1 1 TTN1 F
old 10: table_update := '&1';
new 10: table_update := 'T';
old 12: tariff_group := '&2';
new 12: tariff_group := 'TG1';
old 13: gf_version := &3;
new 13: gf_version := 1;
old 14: tariff_table_name := '&4';
new 14: tariff_table_name := 'TTN1';
old 15: flag := '&5';
new 15: flag := 'F';
old 17: offer_id := &2;
new 17: offer_id := TG1;
old 18: gf_version := &3;
new 18: gf_version := 1;
old 19: promotion_table_name := '&4';
new 19: promotion_table_name := 'TTN1';
old 20: flag := '&5';
new 20: flag := 'F';
offer_id := TG1;
ERROR at line 17:
ORA-06550: line 17, column 19:
PLS-00201: identifier 'TG1' must be declared
ORA-06550: line 17, column 7:
PL/SQL: Statement ignoredAs you can see, the initial assignments for compilation purposes are done prior to actually running the code, and the assignment to offer_id is failing.
If I change offer_id to a varchar and quote the &2, then the compilation assignemnt works, and the actual logic of the script works:
SQL> !cat t.sql
DECLARE
table_update VARCHAR2(1);
tariff_group VARCHAR2(3);
gf_version NUMBER;
tariff_table_name VARCHAR2(5);
offer_id VARCHAR2(3);
promotion_table_name VARCHAR2(5);
flag VARCHAR2(1);
BEGIN
table_update := '&1';
IF table_update = 'T' THEN
tariff_group := '&2';
gf_version := &3;
tariff_table_name := '&4';
flag := '&5';
ELSIF table_update = 'P' THEN
offer_id := '&2';
gf_version := &3;
promotion_table_name := '&4';
flag := '&5';
END IF;
DBMS_OUTPUT.Put_Line ('TableUpdate: '||table_update);
DBMS_OUTPUT.Put_Line ('TariffGroup: '||tariff_group);
DBMS_OUTPUT.Put_Line ('GfVersion: '||gf_version);
DBMS_OUTPUT.Put_Line ('Tarifftable: '||tariff_table_name);
DBMS_OUTPUT.Put_Line ('OfferID: '||offer_id);
DBMS_OUTPUT.Put_Line ('PromoTable: '||promotion_table_name);
END;
SQL> @t T TG1 1 TTN1 F
30 /
old 10: table_update := '&1';
new 10: table_update := 'T';
old 12: tariff_group := '&2';
new 12: tariff_group := 'TG1';
old 13: gf_version := &3;
new 13: gf_version := 1;
old 14: tariff_table_name := '&4';
new 14: tariff_table_name := 'TTN1';
old 15: flag := '&5';
new 15: flag := 'F';
old 17: offer_id := '&2';
new 17: offer_id := 'TG1';
old 18: gf_version := &3;
new 18: gf_version := 1;
old 19: promotion_table_name := '&4';
new 19: promotion_table_name := 'TTN1';
old 20: flag := '&5';
new 20: flag := 'F';
TableUpdate: T
TariffGroup: TG1
GfVersion: 1
Tarifftable: TTN1
OfferID:
PromoTable:John -
Assigning variable to the values from OUT.PRINTLN
Inside our Servlet doGet, we have the following,
out.println("<TR><TD></TD><TD><INPUT TYPE=\"text\" NAME=\"empphone\" VALUE=\"\" SIZE=\"40\" MAXLENGTH=\"50\" ></TD></TR>\n");
and we need to assign the value entered by the user to a variable.
I don't think the following is doing the trick?
String empphone1;
empphone1 = req.getHeader("empphone");
Thanks a lot
KAuse req.getParameter("empphone");
regards,
~K -
Assigning variable to a column value
Hi,
I am creating a report wherein I use a formula in one of the columns to forecast data. The values obtained in this column (as a result of application of the formula) is to be used to calculate the values for the second column.And the third column value is dependent on the second and so on....
If I use the column formula directly,then many lines of coding are involved...Is it possible to store the value of a column in a variable and hence forth use it for manipulation in subsequent columns?Helios,
I'm already having the same setup mentioned in the thread. And I'm doing exactly whats given there. But the issue seems to be something different. I'm assigning the value to the Global Variable in the Package through Apex. Here's the Package Code:
CREATE OR REPLACE PACKAGE Schema1.SPMS_SECURITY_PKG
AS
X_app_user_id NUMBER DEFAULT -1;
FUNCTION USER_ID RETURN NUMBER;
END SPMS_SECURITY_PKG;
CREATE OR REPLACE PACKAGE BODY Schema1.spms_security_pkg
AS
FUNCTION user_id
RETURN NUMBER
IS
BEGIN
-- RAISE_APPLICATION_ERROR(-20001,'USER ID'||'*'||X_app_user_id);
RETURN NVL (x_app_user_id, -1);
-- RETURN NVL (sys_context('USERENV', 'CURRENT_USER'), -1);
EXCEPTION
WHEN OTHERS
THEN
RETURN -1;
END;
And Here is the Trigger Code:
CREATE OR REPLACE TRIGGER Schema1."USER_DETAILS_TRIGGER"
BEFORE INSERT OR UPDATE
ON PMS_SICAL.SPMS_USER_DETAILS REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF INSERTING
THEN
:NEW.created_by := spms_security_pkg.user_id;
:NEW.created_date := SYSDATE;
:NEW.START_DATE := SYSDATE;
ELSIF UPDATING
THEN
:NEW.updated_by := SPMS_SECURITY_PKG.X_app_user_id;--spms_security_pkg.user_id;
:NEW.updated_date := SYSDATE;
END IF;
END;
But I always get -1 in the both in the table after the DMLs. -
Dynamically assigning variable in xml loop
I am trying to dynamically assign a variable name so I can
build an accordian nav from and XML doc. the code looks like this:
ACnav['depthChild0']._alpha = 0;
ACnav.setStyle("color", 0x0ffffff);
ACnav.setStyle ("openEasing",
mx.transitions.easing.strong.easeout);
ACnav.setStyle ("selectionDuration",
mx.transitions.duration.slow);
navXML = new XML();
navXML.ignoreWhite = true;
navXML.load("menu1.xml");
oY=5;
var currentSection = 0;
function buildNav () {
DisposableXML = new XML();
TempXML = new XML();
button = new Array();
//buttonNum = new Array();
subitem = new Array();
menuItem = new Array();
o = new Array ();
subitemlocation = new Array();
DisposableList = new Array();
buttonList = navXML.firstChild.childNodes;
i = 0;
sectionLength = buttonList.length;
while (i<=buttonList.length) {
if (buttonList
.nodeName.toLowerCase() == "button") {
DisposableXML = buttonList;
DisposableList = DisposableXML.childNodes;
buttonName = buttonList
.attributes.name;
set ("buttonNum", "buttonNumber"+i);
trace(buttonNum);
ii = 0;
//trace(buttonName+"-"+buttonNum);
//ACnav.createChild("View", buttonNum, {label: buttonName,
icon: "mainNav"});
button = ACnav.createChild("View", buttonNum, {label:
buttonName, icon: "mainNav"});
oY=5
while (ii<=DisposableList.length) {
TempXML = DisposableList[ii];
if (DisposableList[ii].nodeName.toLowerCase() == "subitem")
subitem = TempXML.attributes.name;
//subitemlocation = TempXML.attributes.location;
subitemNum="subitemNum"+[ii]+
//trace(buttonNum+"-"+subitemNum+"-"+subitem);
menuItem = ACnav.buttonNum.createChild("subNav",
subitemNum, {childText: subitem});
menuItem
.move(0, oY);
oY=(oY+25);
//trace(buttonNum);
ii = Number(ii)+1;
i = Number(i)+1;
//trace(button);
trace(menuItem);
redraw();
//gotoAndPlay('reload');
The problem lies with this line: button =
ACnav.createChild("View", buttonNum, {label: buttonName, icon:
"mainNav"});
If I quote the "buttonNum", it works, but jumbles the subnav
items together vs in the proper node. I need to have that declared
dynamically so that each parent node has a differentID and then
createchild goes under that. Anyway, I've tried alot of stuff over
the last few days and its getting frustrating.
Thanks for the help if anyone contributes!You shouldn't need to do a concat within the XQuery path parameter. Try the following:
bpws:getVariableData('inputVariable','payload','/ns1:Request/ns1:instance[bpws:getVariableData("j")]') -
Hi everybody,
I'm writting a procedure and I want to assign to some variable, a value taken fron a cursor. I have 20 variables , and it could be more, that's why I want to do that within a loop.
I tried the following:
DECLARE CURSOR retrieve_salary IS
(SELECT ID, SALARY FROM TABLE ORDER BY ID);
retrieve_salary_row retrieve_salary%ROWTYPE
ID_1 NUMBER;
ID_2 NUMBER; .........
SALARY1 NUMBER;
SALARY2 NUMBER; .....
i NUMER;
BEGIN
OPEN retrieve_salary;
i:=1;
WHILE i < 3 --or te number of variable you have to assign
LOOP
FETCH retrieve_salary INTO retrieve_salary_row;
ID_||i := retrieve_salary_row.ID;
SALARY||i := retrieve_salary_row.salary;
i:=i+1;
END LOOP;
END;
this code doens't work because of the concatenation........is there a way to do that smartly?
Thanks in advance....
AlexHi,
If you want to store table data in different variables then why you are approaching to VARRAY or Assiciative Array. e.g.
"afiedt.buf" 17 lines, 399 characters
1 DECLARE
2 CURSOR emp_cur
3 IS SELECT ename,sal FROM emp WHERE rownum <=3;
4 TYPE emp_type is TABLE OF emp_cur%ROWTYPE
5 INDEX BY BINARY_INTEGER;
6 arr_var emp_type;
7 i NUMBER :=0;
8 BEGIN
9 OPEN emp_cur;
10 LOOP
11 i := i + 1;
12 FETCH emp_cur INTO arr_var(i).ename,arr_var(i).sal ;
13 EXIT WHEN emp_cur%NOTFOUND;
14 DBMS_OUTPUT.PUT_LINE('Name :'||arr_var(i).ename||' Sal :'||arr_var(i).sal);
15 END LOOP;
16* END;
SQL>/
Name :SMITH Sal :800
Name :ALLEN Sal :1600
Name :WARD Sal :1250
PL/SQL procedure successfully completed.
SQL>Regards
Avinash -
Spurious lint warning about assigned variable never used
I'm getting a lint warning "assigned value never used" (and another one "set but not used in function")
that seems to be spurious. Test case included below. Can someone either confirm that this is a bug or explain to me why
this warning is legitimate.
marten 229% cc -V
cc: Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12
marten 230% uname -a
SunOS marten.isi.edu 5.10 Generic_127111-11 sun4u sparc SUNW,Sun-Blade-1000 Solaris
marten 231% cat test93.c
static long value;
long get_value (void) {
value++;
return value;
int main (int argc, char ** argv) {
long k, val;
value = 0;
k = 0;
while ((val = get_value()) != 47) {
k++;
return 0;
marten 249% lint -u -m -x -Ncheck=%all test93.c
argument unused in function
(9) argc in main
(9) argv in main
set but not used in function
(10) val in main
.c file has no corresponding .h file
/nfs/m_usr/dhollen/junk/test93.c
assigned value never used
val defined at test93.c(10) :: set at test93.c(14)The value of variable "val" is never actually used in function main.
You could delete its declaration and the assignment to it in the while-loop header without affecting the program.
Maybe you are thinking that the line
while ((val = get_value()) != 47)
uses the value of val. An assignment-expression has the type and value that is stored in the left operand, and is not an lvalue. The actual storage into the variable is a side effect that need not occur before the value of the assignment is used.
Reference: C99 Standard, section 6.5.16 "Assignment operators", paragraph 3.
In this example, the storage into val must occur before entering or skipping the loop body, but need not occur before evaluating the control expression. Variable val is therefore not used in the function.
We can go further and notice that since storing into val is not an "observable side effect", a compiler is free to omit allocating the variable or storing into it. -
Hi all,
I'm working on a JS-script to extract the text from text layers and I was wondering if it was possible to assign a Variable from within this script or through an Action.
Basically I want to auto-assign Text Replacement variables to all of the layers in an existing image. Is this possible?
Thanks in advance!I was able to solve this without using Variables, but I would still like to know if anyone has the answer.
-
Assigning variables to form components?
Would anyone know how I could assign a variable to one of the
form components that come with flash? Just like the text box
variables? Thanks a lot.Ah man... I guess noone knows anything about this... I mean,
I just need to know how I can give them a tag for communication
outside of flash... basically -
Oracle Service Bus - Assign Variables with max occurs of unbounded
Hello,
I have the following response document from a call to a Tuxedo Service. I need to assigned the values for all <SOC> tags below to the response document which was created with a min occurs of 1 and max occurs of unbounded. When I try to assign the values from all <SOC> tags from the response document below, only the first value of SOC get assigned. When I run a test in the XQuery Expression Editor, I get back all 7 values for SOC below using the following expression: $outputCsLsSrvAgr00/SOC. However, the variable this data gets assigned to only has the first SOC node.
<FML32>
<SERVICE_TYPE>R</SERVICE_TYPE>
<SERVICE_TYPE> </SERVICE_TYPE>
<SERVICE_TYPE> </SERVICE_TYPE>
<SERVICE_TYPE>P</SERVICE_TYPE>
<SOC_EFFECTIVE_DATE>20080924</SOC_EFFECTIVE_DATE>
<SERVICE_TYPE>R</SERVICE_TYPE>
<SOC_EFFECTIVE_DATE>20080802</SOC_EFFECTIVE_DATE>
<SERVICE_TYPE>R</SERVICE_TYPE>
<SOC>DTMMSBUIN</SOC>
<SOC>FN0132007</SOC>
<SOC>DTUNLB004</SOC>
<SOC_EFFECTIVE_DATE>20080922</SOC_EFFECTIVE_DATE>
<SOC_EFFECTIVE_DATE>20080924</SOC_EFFECTIVE_DATE>
<SOC_EFFECTIVE_DATE>20080608</SOC_EFFECTIVE_DATE>
<SOC_EFFECTIVE_DATE>20080924</SOC_EFFECTIVE_DATE>
<SOC_EFFECTIVE_DATE>20080923</SOC_EFFECTIVE_DATE>
<SERVICE_TYPE>R</SERVICE_TYPE>
<SOC>VMA0.00</SOC>
<SOC>OUTRSTRCN</SOC>
<SOC>SMSBAN202</SOC>
<SOC>VM</SOC>
</FML32>
Can someone tell me how to populate the response variable structures with all 7 values of SOC?
Thanks,
David Walaskican you post your schema, this XML looks strange, there seems to be no order or logic to the way it is being represented.
This could be causing you the issues. The test function in workshop can behave differently to when run at runtime.
cheers
James -
Hello,
silly question: I can assign values of ABAP-variablen to Javascript-variables:
<script language="javascript">
function find_value(){
var xxx = "<%=variable%>"; }
</script>
now I need to do the opposite, that is, assign the value of Javascript-variables to ABAP-variablen, but I can´t:
<%=variable%> = xxx; <-- error message object expected
How does it work ?? Thanks a lotthis sample code can be helpful to you,
<SCRIPT language="JavaScript">
function func()
var txt;
txt = "Hello";
document.formBody.if01.value = txt;
document.formBody.submit();
</SCRIPT>
<htmlb:form id="formBody" >
<htmlb:inputField id = "if01"
type = "string"
visible = "false"
size = "20" />
Get the value in the Input field in your event handler and assign it to the ABAP variable.
Thanks & regards,
Ravikiran.
Maybe you are looking for
-
Are you drawing text at an angle with TextRenderer?
This is a question for folks that are aware of the difference in quality of output between TextRenderer.DrawText and (Graphics.DrawString + Graphics.TextRenderingHint = Text.TextRenderingHint.AntiAlias). It is an issue that has been discussed by othe
-
I forgot the questions to my apple id... Please help!!
How can i recover the answers of mu apple id security of i forgot them!
-
My Macbook won't read flashdrives
Is there anyting it can be besides a hardware problem? Is there anything I can test or try?
-
Right now I am getting the following error when I try to connect to any of my Oracle databases: Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and po
-
Guy's, May someone can help me with this. 1) Is goods receipt possible in SRM PPS? 2) Is invoice receipt possible in SRM PPS 3) Is XI mandatory? Please advise. Rgds Saj