Defined variable and substitution variables
Are both of these internally treated in the same way by the Oracle database?
for example a defined variable
DEFINE p_grade = a
and if I use a substitution variable p_grade
DECLARE
p_grade VARCHAR2(10);
v_name VARCHAR2(10);
BEGIN
SELECT last_name
INTO v_name
FROM employees;
WHERE job_id = &p_grade
END;
Edited by: user6287828 on Feb 24, 2009 10:52 AM
Hi,
What you're calling a "defined variable" is nothing but a substitution variable.
DEFINE p_grade = ais just one way of setting the value of the substitution variable p_grade.
When you later use that variable, for example
WHERE job_id = &p_gradethere is no way of telling how p_grade got its value (if it has one).
Avoid using the same name for two different types of variables.
For example:
DECLARE
p_grade VARCHAR2(10); -- Local variable declared
v_name VARCHAR2(10);
BEGIN
SELECT last_name
INTO v_name
FROM employees
WHERE job_id = &p_grade; -- Substitution variable used
END;In the second line, you are creating a local VARCHAR2 variable called p_grade that is never used. It has nothing to do with the substitution variable p_grade (unless the value of that substitution variable happens to be p_grade,
DEFINE p_grade = p_grade)
If you do use the same name for differnt types of variables, SQL*Plus may keep them straight, but no one else (including you) will.
Similar Messages
-
Global variable vs substitution variable
Hi Gurus,
Can we can use substitution variables in Business Rules(we can make it applicable for all the applications)..
Then what exactly is the difference between Global variable and substitution variable.
Thanks,
~RNYes you can use substitution variables.
A Global variable in Business rules can be used across all business rules and can only be used in business rules, it has the added benefit that they can be set as run time prompts, more info at About Variables
Cheers
John
http://john-goodwin.blogspot.com/ -
Financial Reporting and substitution variable
Hello,
i have a problem with FR and substitution variable. I create the substitution variable in Essbase for example antYear but i dont'see in dimension layout in FR studio and workspace.
Thanks.You'll need to restart FR studio, after you have created the substitution variables. As the studio only performs one read of the sub var database on startup.
It also won't show up unless you assign a member to it.
Hope this helps.
Iain -
How to pass parameter [bind variable or substitution variable] to a view?
How can I pass a parameter [bind variable or substitution variable] to a view in Oracle?
Some will tell me that this is not necessary, that I can only pass the parameter when I query the view, but I found some case where this cause performance issue. In long view where I use subquery factoring [WITH], it's necessary to pass the parameter many time through different subqueries and not only to the resulting view.
In other database (SQL Server, Access), we can pass parameters through query. I can't find how to do that in Oracle. Can some one tell me what is the approach suggest by Oracle on that subject?
Thank you in advance,
MB
What I can do:
CREATE VIEW "HR"."EMP_NAME" ("FIRST_NAME", "LAST_NAME")
AS
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES;
What I want to do:
CREATE VIEW "HR"."EMP_NAME" ("FIRST_NAME", "LAST_NAME")(prmEMP_ID)
AS
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID IN (:prmEMP_ID);Blais wrote:
How can I pass a parameter [bind variable or substitution variable] to a view in Oracle?
Some will tell me that this is not necessary, that I can only pass the parameter when I query the view, but I found some case where this cause performance issue. In long view where I use subquery factoring [WITH], it's necessary to pass the parameter many time through different subqueries and not only to the resulting view.Yes, there can be performance issues. Views are a form of dynamic SQL and it is hard to predict how they will perform later.
You can't pass parameters to a view. They are not functions. The mechanism to put the values in is what you mentioned, passing the parameter when you query the view.
In other database (SQL Server, Access), we can pass parameters through query. I can't find how to do that in Oracle. Can some one tell me what is the approach suggest by Oracle on that subject? This functionality is not supported.
What I can do:
CREATE VIEW "HR"."EMP_NAME" ("FIRST_NAME", "LAST_NAME")
AS
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES;
What I want to do:
CREATE VIEW "HR"."EMP_NAME" ("FIRST_NAME", "LAST_NAME")(prmEMP_ID)
AS
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID IN (:prmEMP_ID);Include the bind value when you use the view in a SELECT. The value will be applied to the view at run-time, somthing like
CREATE VIEW "HR"."EMP_NAME_VW" ("FIRST_NAME", "LAST_NAME","EMPLOYEE_ID")(prmEMP_ID)
AS SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES;
select *
from emp_name_vw
WHERE EMPLOYEE_ID IN (:prmEMP_ID);To use EMPLOYEE_ID I added it to your list of columns in the view so it can be referenced in the WHERE clause. If you don't want to see that value don't select it from the view. -
What is the difference between Instance variable and Global variable?
Hi folks,
Could you please explain me, "what is the difference between Instance variable and Global variable?"
Are they really same or not?
--SubbuHi flounder,
I too know that there is no such a term GLOBAL in java.
generally people use to say a variable which is accessible throught out the class or file has global access
and that will be called as a global variable...
my point is very much similar to what Looce said.
In simple that is not a technical term, but just a causual term.
In technically my question is, "What is the difference between a instance variable and public variable?".
Hi looce,
Thanks for the reply. even thats what my understanding too....in order to confirm that i raised this question..
Your reply has given a clear answer...... thanks again.
--Subbu -
Issue with rule file and Substitution variable
Hi All,
I am using Essbase 9.3.3
I created a rule file with 5 dimensions in which 3 dimensions I defined in columns and two dimensions I gave it as header in data column with comma seperated.
Among those two dimension members, one is an account member with "/" in it within quotes and other is a substitution variable.
The member assigned for that Substitution variable has a space in between and is updated within quotes in variables list.
When I try loading data, I am getting an error saying that two members are not valid.
Eg: "Tax/Unit",&Scenario is not valid.
&Scenario - "Budget Q1"
Can some one please suggest on the issue.
I am not facing any problem in calc scripts or reports scripts using the substition variable.
Thanks in advanceMark,
Modifying the default files is dangerous and ill advised. You could always just add a style sheet (inline or linked) to your application that overrides that one setting while you wait on the permanent fix.
Regards,
Dan
http://danielmcghan.us
http://sourceforge.net/projects/tapigen -
HSGetValue and substitution variables
Hi volks,
is it possible to use the SmartView Hsgetvalue/HSSetValue with substitution variables like &CurrFC etc..
any examples (Syntax) ?
Thanks in advance
Muser11956030 wrote:
Hello everyone i'm having a little trouble on using define command for a hw assignment.
Here is what is needed:
1)Use the DEFINE command to define a variable sal and initialize it to 6000
2)In the declarative section declare two variables: ename of type employees.last_name and emp_sal of type employees.salary. Pass the value of the substitution variables to emp_sal.
Here is what i put in and it doesn't work:
SET SERVEROUTPUT ON
SET VERIFY OFF
DEFINE sal=6000
DECLARE
ename emp.last_name%TYPE;
emp_sal emp.salary%TYPE;
emp_sal = &sal;
BEGIN
END;
Thanks for the help.The assignment operator in PL/SQL is :=, with a colon first.
Change:
emp_sal = &sal;to
emp_sal := &sal;Also, a stand-alone assignment statement like that can not be in the DECLARE section. Put it after BEGIN.
It is allowed to assign a value when you declare a variable, like this:
emp_sal emp.salary%TYPE := &sal;but it is not allowed to have an empty BEGIN section. If you want to assign the value in the DECLARE section, then put something (anyhting, at least for now) in the BEGIN section.
For example:
DECLARE
ename emp.last_name%TYPE;
emp_sal emp.salary%TYPE := &sal;
BEGIN
dbms_output.put_line ( TO_CHAR (emp_sal)
|| ' = emp_sal at start of BEGIN section'
END;
/= (without a colon) is the PL/SQL (and SQL) equality operator . You can use it in constructions like this:
IF emp_sal = &sal
THEN
END IF; Edited by: Frank Kulash on Nov 30, 2009 7:26 PM -
Block based on "From clause query" and substitution variable
Hi Folks,
I have a "From clause query" block type, which is based on query that uses a substitution variable (:BLOCK.COLUMN) from previous block. When I run a query, then I obtain an error: ORA-01008: not all variables bound.
My query looks like:
select seq_no, prod_code, descr, curr_code,
max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
from
select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
from repay_scheds r,
fac_prods f
where r.fac_no = f.fac_no
and r.prod_code = f.prd_code
and r.prod_seq_no = f.seq_no
and r.fac_no = :B2.FAC_NO
and r.trans_ref_from is not null
and r.status <> 'P'
group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code
group by seq_no, prod_code, descr, curr_code
having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0Once I replace that substitution variable in query condition with some exact test number then it works fine.
select seq_no, prod_code, descr, curr_code,
max(decode(sched_type_code,'ROLLOVER',amt,0)) OUTSTD_DRAW,
max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) OUTSTD_INTEREST_FEE
from
select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
from repay_scheds r,
fac_prods f
where r.fac_no = f.fac_no
and r.prod_code = f.prd_code
and r.prod_seq_no = f.seq_no
and r.fac_no = 2012500
and r.trans_ref_from is not null
and r.status <> 'P'
group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code
group by seq_no, prod_code, descr, curr_code
having max(decode(sched_type_code,'ROLLOVER',amt,0)) >0 or max(decode(sched_type_code,'INTCHG',amt,decode(sched_type_code,'FEEREC',amt,0))) > 0How can I use substitution variable within query for "From clause query" block type? Or any other way how to get the same result?
Thanks for your reply.
TomasI have a solution:
Before entering block I'm calling function, that populates my block:
PROCEDURE POP_<<MY_BLOCK>>_BLOCK IS
query_txt varchar2(2000);
BEGIN
query_txt := '(select seq_no, prod_code, descr, curr_code,
max(decode(sched_type_code,''ROLLOVER'',amt,0)) OUTSTD_DRAW,
max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) OUTSTD_INTEREST_FEE
from
select r.fac_no, r.prod_code, f.descr, r.prod_seq_no seq_no, r.curr_code, r.sched_type_code,sum(nvl(rep_amt,0)) amt
from repay_scheds r,
fac_prods f
where r.fac_no = f.fac_no
and r.prod_code = f.prd_code
and r.prod_seq_no = f.seq_no
and r.fac_no = '||:B2.FAC_NO||'
and r.trans_ref_from is not null
and r.status <> ''P''
group by r.fac_no, r.prod_code, f.descr, r.prod_seq_no, r.curr_code, r.sched_type_code
group by seq_no, prod_code, descr, curr_code
having max(decode(sched_type_code,''ROLLOVER'',amt,0)) >0 or max(decode(sched_type_code,''INTCHG'',amt,decode(sched_type_code,''FEEREC'',amt,0))) > 0)';
Go_Block('<<MY_BLOCK>>' );
Clear_Block ;
Set_Block_Property( '<<MY_BLOCK>>', QUERY_DATA_SOURCE_NAME, query_txt) ;
-- populate my block --
Execute_Query ;
END;Thanks,
Tomas -
Default initialisation of member variables and local variables
I don't understand why member variables are initialized with default values by Java.
Objects are initialized with "null" and primitives with "0", except boolean, which is initialized with "false".
If these variables are used locally they are not initialized. The compiler requires them to be initialized by the programer, for example "String s = null".
Why? What is the use of that difference?
And why are arrays always initialized with default values, no matter if they are member variables or local variables? For example String[] s = new String[10]; s[0] to s[9] are initialized with "null", no matter if "s" is a local or member variable.
Can someone please explain that strange difference, why it is used? To me it has no sense.Most of the time I have to initialize a local variable
with "String s = null" in order to use it because
otherwise the compile would complain. This is a cheap
little trick, but I think everyone uses it.
I wouldn't agree with "most of the time". The only cases where it is almost necessary to do that is when the variable should be initialized in a loop or a try-catch statement, and that doesn't happen too often.
If local variables were initiliazed automatically without a warning it would be a Bad Thing: the compiler could tell when there is a possibility that a variable hasn't been assigned to and prevent manymanymany NullPointerExceptions on run time.
And you didn't answer me why this principle is not
used with arrays if it is so useful as you think.
Possibly it is much more difficult to analyse the situation in the case of arrays; what if values are assigned to the elements in an order that depends on run time properties such as values returned from a random number generator.
The more special rules one has to remember, the more
likely one makes errors.I agree, but what is the rule to remember in this case? -
How to change value of instance variable and local variable at run time?
As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
Suppose I have a class, say employee like -
class employee {
public String name;
employee(String name){
this.name = name;
public int showSalary(){
int salary = 10000;
return salary;
public String showName()
return name;
i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
Can someone tell me how to change these value?
Please help
Regards,
Sujeet SharmaThis is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.
-
What is the difference between instance variable and class variable?
i've looked it up on a few pages and i'm still struggling a bit maybe one of you guys could "dumb" it down for me or give and example of how their uses differ.
thanks a lotInstance is variable, class is an object.What? "Instance" doesn't necessarily refer to variables, and although it's true that instances of Class are objects, it's not clear if that's what you meant, or how it's relevant.
if you declare one instance in a class that instance
should be sharing within that class only.Sharing with what? Non-static fields are not shared at all. Sharing which instance? What are you talking about?
if you declare one class object it will share
anywhere in the current program.Err...you can create global variables in Java, more or less, by making them static fields. If that's what you meant. It's not a very good practice though.
Static fields, methods, and classes are not necessarily object types. One can have a static primitive field. -
What's the difference between global variables and instance variables?
hi im just a biginner,
but what is the difference between these two?
both i declare them above the constructor right.
and both can access by any method in the class but my teacher said
global variables are not permitted in java....
but i don't know what that means....and i got started to confuse these two types,,
im confusing.......
and why my teacher said declaring global variables is not permitted,,,,,,
why.....instance variables are kindof like Global variables. I'm not surprised you are confused.
The difference is not in how they are declared, but rather in how they are used.
There are two different "styles" of programming
- procedural programming.
- object oriented programming.
Global variables are a term from Procedural programming.
In this style of programming, you have only one class, and one "main" procedure. You only create one instance of the class, and then "run" it.
There is one thread of control, which goes through various methods/procedures to accomplish your task.
In this style of programming instance variables ARE "global" variables. They are accessible to all methods. There is only one instance of the class, and thus only one instance of the variables.
Global variables are "bad" BECAUSE you can change them in any method you like. Even from places that shouldn't have to. Also if you use the same name as a global variable and a local variable, you can cause great trouble. This can lead to very subtle bugs, as the procedures interact in ways you don't expect.
The preferred method in procedural programming is to pass the values as parameters to the methods, and only refer to the parameters, and local variables. This means that you can track exactly what your method is doing, and what it affects. It makes it simpler to understand. If you use global variables in your methods, it becomes harder to understand.
So when are instance variables not global variables?
When you are actually using the class as an Object, rather than just a program to run. If you are creating multiple instances of an object, all with different values for their instance variables, then they are not global variables. For instance you declare a Person object with an attribute "firstname". Your "main" program then creates many instances of the Person object, each with their own "firstname"
I guess at the end of all this, it comes down to definitions.
Certainly you can write procedural code in java. You can treat your instance variables, for all intents and purposes like global variables.
I can only think to show a sort of example
public class Test1
User[] users;
public void printUsers(){
// loop through and print all the users
// uses a global variable
for(int i=0; i<users.length; i++){
users.printUser();
public void printUsers(User[] users){
// preferred method - pass it the info it needs to do the job
for(int i=0; i<users.length; i++){
users[i].printUser();
public Test1(){
User u1 = new User("Tom", 20);
User u2 = new User("Dick", 42);
User u3 = new User("Harry", 69);
users = new User[3];
users[0] = u1;
users[1] = u2;
users[2] = u3;
printUsers();
printUsers(users);
public static void main(String[] args)
new Test1();
class User{
String firstName;
int age;
public User(String name, int age){
this.firstName = name;
this.age = age;
public void printUser(){
// here they are used as instance variables and not global variables
System.out.println(firstName + " Age: " + age);
Shit thats a lot of typing, and I'm not even sure I've explained it any good.
Hope you can make some sense out of this drivel.
Cheers,
evnafets -
UCCE - ECC Variable and User Variable
Hello All
As known from Cisco documents, total size of the buffer used to store the "ECC variables" internally is 2000 bytes.
Is there any constraint similar for User Variables?
Did some googling and found this one from the link below
https://supportforums.cisco.com/discussion/10336156/icm-variables
Its says "User Variables are up to 40 characters in length, with no specific limit to the amount of them,
the data collected is stored in a specific way"
Can you please confirm is there any buffer limit to User Variables in ICM?
Thanks
Mahesh
[email protected]Mahesh,
The ECC variable limit is 2500 bytes, not 2000.
There is no hard limit for User Variables, though I suspect if you had more created than what can fit in the RAM on the router, you would have some issues. You would likely need many thousands of User Variables in order to use gigabytes of RAM, though.
The use cases for ECC and User variables are quite different... an ECC variable is for data about the current call, while User Variables are usually more appropriate for "global" data that needs to last across multiple calls, such as open/closed states.
-Jameson -
MDX and substitution Variable usage in Essbase 7.1.5 -- Problem
<p>Hi,</p><p> </p><p>Iam trying to write a query like this and Iam unable to validatethis in MDX -</p><p> </p><p>SELECT<br><br>{ [USD]}<br>ON COLUMNS,<br>{&CurMon}<br>ON ROWS<br><br>FROM [Sample.Basic]</p><p> </p><p>It gives me error at "&"</p><p> </p><p> </p><p>Also I tried to use substituion variable in a formula on amember like this and I couldnot get it validated -</p><p> </p><p> </p><p>CASE [Time Periods].CurrentMember<br>WHEN [JAN]<br>THEN SUM( CROSSJoin( {[Net Income]} , {[JAN]} ) )<br>WHEN &CurMon<br>THEN SUM( CROSSJoin( {[Net Income]} ,{[JAN] : &CurMon} ) )<br>ELSE<br>missing<br>END</p><p> </p><p> </p><p>Please reply me if indeed , we cannot use substitution variablesin MDX.</p><p> </p><p>( Note: Subsitution variables were already setup in thesystem)</p><p> </p><p>Thanks<br></p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p>
Each essbase application can go up to 2GB only. If you have one application which use more than 2GB of ram, it will probably crash.
If you use direct I/O, you can use more than 2GB of ram, however it is limited by the operating systems.
For Windows, it is recommended to turn on the /PAE setting in boot.ini. This will allow the windows to use more than 4GB of RAM. According to Essbase DBA guide, Turning 4GT will allow Essbase to use up to 3GB of RAM when you use direct I/O. -
Defining text and integer variables??
I found this in some code:
var num = 0, txt = "bo";
I guess it could also have been written as:
var num = 0,
txt = "bo";
Why is it allowed to define an integer by just using "," and when you define a text variable you use ";"The code you are looking at would be javascript, not java.
Despite the name, the two are definitely NOT the same thing.
Why is it allowed to define an integer by just using "," and when you define a text
variable you use ";" You are misunderstanding the syntax.
The semicolon ';' completes a statement
the comma was just separating multiple variable declarations on the same line.
It could just as easily have been
var txt="bo", num=0;
var a=42, b=69, c=666;
Just to reiterate this is NOT valid java code. Java does not use the "var" keyword.
It is javascript, which means it can do pretty much whatever it likes ;-)
Maybe you are looking for
-
Can not read or write to disk (error -36)
I have an additional internal SATA 250GB Drive that is partitioned into "Videos" 135GB and "Music" 100GB. Everything has been working fine until recently. The "Music" drive (where my itunes library is stored) will no longer let me copy a file and giv
-
Hi Experts, When I try to run F110. Below Error shown. I pasted Error Job log below: Job started Step 001 started (program SAPF110S, variant &0000000002020, user ID SAPUSER) Log for proposal run for payment on 12.07.2014, identification WIP4 Informa
-
Changing composing email address.
I ended up with a virus on my hotmail email address which I had linked to my macbook pro apple mail. I signed up for a new Outlook address & I am in the process of switching over to this new address. I have gone into mail, preferences, accounts, an
-
How do I transfer ringtones from itunes to my iphone4 syncing them doesn't work
How do I transfer ringtones from itunes to my iphone as syncing them doesn't work
-
If you have your service cancel from nonpayment, is your phone unlocked?
Can you still use your phone with another provider if your service is suspended for nonpayment?