Alternative to Substitution Variables
I'm attempting to loop though some logic X number of times based on a user-defined (defined using substitution variable) parameter. Within the loop I need to have user-definable parameter as well. Since substitution variables cannot be used in a loop I'll need an alternative.
Here an example:
accept L_num_recs NUMBER PROMPT 'Enter Number of Records (0-9);
BEGIN
FOR i in 1..&L_num_recs LOOP
parameter1 := &m1
parameter2 := &m2
END LOOP
END;
Because &m1 and &m2 are substitution variables they are bound each time through the loop.
Any thoughts? Thanks!
Just assign those subs to local variables and then use the local variables in the loop:
sql>accept l_num_recs number prompt 'Enter Number of Records (0-9): '
Enter Number of Records (0-9): 3
sql>declare
2 v_text1 number := &m1;
3 v_text2 number := &m2;
4 begin
5 for i in 1..&l_num_recs loop
6 dbms_output.put_line( v_text1 );
7 dbms_output.put_line( v_text2 );
8 end loop;
9 end;
10 /
Enter value for m1: 55
old 2: v_text1 number := &m1;
new 2: v_text1 number := 55;
Enter value for m2: 77
old 3: v_text2 number := &m2;
new 3: v_text2 number := 77;
old 5: for i in 1..&l_num_recs loop
new 5: for i in 1.. 3 loop
55
77
55
77
55
77
PL/SQL procedure successfully completed.
Similar Messages
-
Can we use Substitution variables in MAXL?
Hi,
Can we use substitution variables in MAXL script?
I have to run this MAXL command for clearing a slice of ASO cube on V11.1.1.3.
alter database Apname.DBname clear data in region 'CrossJoin({[2009]},{[Dec]})';
I am planning to use Current_year & Current_month variables instead of hardcoding 2009 & Dec as I have to use this everymonth to clear the current months data.
If it is allowed, what is the syntax?
Is there any alternative apart from substitution variables?
Appreciate your thoughts.
Thanks,
-Ethan.You would just use ampersand and the variable name instead of the hard coding e.g. &yearVar &periodVar.
Not tried it on aso clears but in theory it should work as ...'CrossJoin({&yearVar},{&periodVar})';
just change yearVar and periodVar for your substitution variable names.
Cheers
John
http://john-goodwin.blogspot.com/ -
SQLPlus problem - user enters quote in substitution variable
Hello,
I have a SQL Plus script report, where user is prompted to enter "customer name".
Some customer names contain single quotes/apostrophes.
When user type such name, the script will error out with
ORA-01756: quoted string not properly terminated
I can't ask users to use '' instead of ' . I can't control what they enter. Is there a way to process single quote so the statement below will work:
select * from sometable where customer_name = '&1'
where &1 = Smith's
I can't do replace, etc, because it's all error out with the same error. I need to replace ' on SQLPlus level somehow. One logical way to do it would be to redefine the string separation charachter somehow...
SQL*Plus: Release 8.0.6.0.0
Thanks,
Vlad
Message was edited by:
user454392As it's a SQL*Plus substitution variable it is literally copied into the code just prior to compilation, so you can't stop it from breaking the compilation of the code. q quoted strings are the only solution I can think of but of course they are only available from 10g onwards.
The other alternative is to capture the input in a shell/batch script which validates it first and then passes the value to the SQL to be executed. -
Use varialbe as a value in substitution variable
Hi there,I incrementaly update my cube day by day.And I set a user variable in autoexec.bat to get the current date,eg '2003-06-23'.Could I use such variable as a variable's value in substition variable ?My platform is 6.5 on w2k.Regards,luau
You can use that in a MAXL script to set the substitution variable.the MAXL script would be something like:Alter database $4 drop variable $5;alter database $4 add variable $5 $7 ;where: $4 is the app.cub $5 is the substitution variable name $7 is the value of the subs. variableRich Sullivan - Beacon Analytics
-
How to use a substitution variable in a load rule?
I need to use a substitution variable in a load rule in a column, as I will receive a parameter to fix the Month and Year values within the data loading, could somebody tell me if this is possible. I put an expresion "&Yearproc" in the column value but it is not working.
If you're a member of ODTUG (or even if not, you can sign up for an associate membership for free) you can download Glenn's presentation from 2009 Kaliedoscope "Little Used Features of Essbase (Like Data Mining and Triggers)" -- there is a section in that presentation on substitution variables -- he does a really good job in showing how this works.
Go to: www.odtug.com, then Tech Resources, then Essbase/Hyperion, and search for Schwartzberg. Currently it's the ninth presentation on the list -- I think this changes based on popularity of downloads.
Regards,
Cameron Lackpour -
Error When Prompting for Substitution Variable
Hi - I'm receiving an error when I try to run the following using the substitution variable - but only when I enter a string; when I enter a numeric value it runs fine.
DECLARE
l_SCR_Info VARCHAR2(50) := '''SCR'||&SCR_NUM||'-'||'''';
begin
dbms_output.put_line(l_SCR_Info);
end;Here is the error I receive when I supply a string value when prompted:
ORA-06550: line 3, column 52:
PLS-00201: identifier 'AB' must be declared
ORA-06550: line 3, column 27:
PL/SQL: Item ignored
ORA-06550: line 10, column 22:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 10, column 1:
PL/SQL: Statement ignoredCan anyone shed some light on what I'm missing here?
Thanks!
ChristineHi,
It looks like you just want one string there:
l_SCR_Info VARCHAR2(50) := '''SCR&SCR_NUM-''';Remeber how substitution variables work: SQL*Plus replaces them with values before sending the code to the back end to be compiled.
If you give a value like AB for the variable, the code you posted is equivalent to:
l_SCR_Info VARCHAR2(50) := '''SCR'|| AB ||'-'||'''';by the time it reaches the compiler. AB is not inside quotes, so the compiler looks for a variable or function called AB.
If you gave a number:
l_SCR_Info VARCHAR2(50) := '''SCR'|| 123 ||'-'||'''';there's no problem; the compile knows what the literal number 123 is. -
Conditional suppression using substitution variable in Hyperion financial r
Hi all,
Is there a way that I can suppress a column using substitution variable in hyperion financial reporting?
For eg, i want to suppress the column if the value of the substitution variable curr_mnth = jun.
Is there a way to do this? In conditional suprression dialog box, I dont find this option.
Please suggest.
Your response is appreciated.
Thanks,
Sirisha.Hi Sirisha
In my earlier reply I think I may have mislead you as I thought that you could set the member name equal to that in a row/column and I've managed to get into a HFR studio session this morning and realised that the conditional suppression only allows you to suppress where member name = 'XXX' (specific text) so that doesn;t meet your requirement.
Different people will have different ways of achieving what you want and everyones requirements are different. If it helps my preferred way of conditionally suppressing periodic data (for Planning/Essbase) is to add a dynamic calc account member called 'TP-Index' into the database, set up a formula so that each period returns a numeric value from 1 to 12 to match the fiscal/calendar year as required.
Then in reporting bring the account and period dimensions into rows/columns so that you are able to retrieve data for the TP-Index account and the period as defined in your substitution variable. You can then choose how the suppression works based on a numeric value, commonly you may want to suppress if greater than, e.g. you have a multi-period report where your actual data is to June so you want to suppress everything from July onwards.
I'm sure that a similar thing could be achieved in HFM as well if that is your underlying system instead of Essbase.
Does that help?
Stuart -
Using substitution variable in sql -- Issue
Hello All
I am trying to do a sql operation from command prompt of my system and that sql requires substitution variable which i am passing it but when i pass the variable ( there are two) the first one assign as " \c" and second gets both what i am passing.
I am not sure what exactly happening here, i have done this on AIX but here its not working any ideas?
System : uname -a
Linux ## 2.6.18-128.1.1.el5 #1 SMP Mon Jan 26 13:58:24 EST 2009 x86_64 x86_64 x86_64 GNU/LinuxAIX and Linux are not the same. An output of "\c" may indicate a compatibility issue of your shell script with your current command line interpreter (shell). A \c can be used to suppress a newline with the echo command. Bash understands both formats echo -n and echo \c, but other shells like Ksh don't. Try to run your script under a Bash, which is the default under Linux. If the problem persists you will need to post your script for any further analysis.
-
Problems using substitution variable in Web Analysis
Dear all,
I have a Web Analysis report that I need to show a raking table with the current month.
For that I create a variable in Essbase that is updated with that date (E.g.: varCurrentMonth).
After that I use it as my substitution variable to filter my date dimension in a report data source (E.g.: Scr5, row: product, column: date dimension & measure):
2008 (current month)
Product $ qty.
AAA 100 10
BBB 90 7
CCC 80 5
The problem is that in our cube we need to use an alias in every dimension not to have duplicate members (E.g.: DT.Date, MS.Measure, PD.Product, etc). And when we use it we need to set up the variable in Essbase using that alias (E.g.: DT.Feb/05/08). And if we use that variable as a substitution variable in the report data source the label displayed is the DT.2008 and not 2008 as expected.
Does anybody have an idea how to solve that?
Many thanks,
Thiago GabrielYou usually get this error message if you are trying to assign a value from a sub var to a member that does not exist.
e.g. trying to put FY08 which is a year member against a period dimension
or trying to use a sub var of FY09 which does not yet exist in the essbase, so say you added a new year in planning FY09 and used the sub var in the form but have not refreshed the database then it would fail because the year would not have been pushed down to essbase yet.
or the value of the subvar does not match a member name exactly
or using a sub var name that does not exist in essbase, e.g. using &nextYear but the sub var has not been created in essbase.
You can definitely use subsitution variables in columns in the version you are using and prior version.
Cheers
John
http://john-goodwin.blogspot.com/ -
Error with define substitution variable in SQL
Hi there,
I am using PL/SQL developer and trying to define a substitution variable as follows:
define freq = 'Weekly'
Then later on, in my SQL statement, I used this variable in WHERE statement as follows:
WHERE ... (&freq = 'Weekly') and ...
But I got the "ORA-00904: "WEEKLY": invalid identifier" error.
Where is the problem?
Thanks in advance!I don't know about PL/SQL developer but in sqlplus you need single quotes around the variable.
SQL> define freq = 'Weekly'
SQL> select null from dual
2 where &freq = 'Weekly';
old 2: where &freq = 'Weekly'
new 2: where Weekly = 'Weekly'
where Weekly = 'Weekly'
ERROR at line 2:
ORA-00904: "WEEKLY": invalid identifier
SQL> edi
Wrote file afiedt.sql
1 select null from dual
2* where '&freq' = 'Weekly'
SQL> /
old 2: where '&freq' = 'Weekly'
new 2: where 'Weekly' = 'Weekly'
N
SQL> -
Substitution Variable in WA error
Hi there,
We have moved our server's IP beacuse we promoted developement (server07) to production (server08). Prior to that all reports worked fine. Now we're having some problems with the Substitution Variables, because everytime we select them, to include them in a report, it displays the following error:
*"Actual_Month is not a valid substitution variable for dimension Period"*
In fact I've tried to create a new variable with a new name and I get the same error. What intrigues me is that if we use the same variable for Dynamic Time Series let's say Y-T-D(Actual_Month) it works and displays a value.
Maybe is there something in the connection but still with no clue how to fix it. Any database or setting at the config file to set?
Thanks!I don't know about PL/SQL developer but in sqlplus you need single quotes around the variable.
SQL> define freq = 'Weekly'
SQL> select null from dual
2 where &freq = 'Weekly';
old 2: where &freq = 'Weekly'
new 2: where Weekly = 'Weekly'
where Weekly = 'Weekly'
ERROR at line 2:
ORA-00904: "WEEKLY": invalid identifier
SQL> edi
Wrote file afiedt.sql
1 select null from dual
2* where '&freq' = 'Weekly'
SQL> /
old 2: where '&freq' = 'Weekly'
new 2: where 'Weekly' = 'Weekly'
N
SQL> -
Assign substitution variable to another substitution variable with truncation of value
I launch a sql*plus .sql script by way of a concurent job. The concurrent job provides a date paramenter to the script. Job log shows the date passed to scrpit as:
Arguments
2013/09/01 00:00:00
For cosmetic purposes in the ouput's heading, I want to convert/truncate the character string to an end-user format of 2013/09/01.
Trying to simply change one substitution variable
(below is not working, but hopefully telegraphs my intention:
UnDefine Low_date
Define Low_date = '2013-09-01 00:00:00'
UnDefine Low_date_10
Define Low_date_10 = 'yyyy-mm-ds'
select substr('&Low_Date',1,10) into &Low_date_10 from dual;
prompt "Variable value is: &Low_date_10"
WHICH PRODUCES:
old:select substr('&Low_Date',1,10) into &Low_date_10 from dual
new:select substr('2013-09-01 00:00:00',1,10) into yyyy-mm-ds from dual
Error starting at line 8 in command:
select substr('2013-09-01 00:00:00',1,10) into yyyy-mm-ds from dual
Error at Command Line:8 Column:55
Error report:
SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:
old:prompt "Variable value is: &Low_date_10"
new:prompt "Variable value is: yyyy-mm-ds"
"Variable value is: yyyy-mm-dd"
"I need to get to "Variable value is: 2013/09/01"Hi,
SELECT ... INTO only works in PL/SQL.
In SQL*Plus, you can use COLUMN ... NEW_VALUE, like this:
DEFINE low_date = '2013-09-01 00:00:00'
COLUMN low_date_10_col NEW_VALUE low_date_10
SELECT REPLACE ( SUBSTR ( '&Low_Date', 1, 10)
) AS low_date_10_col
FROM dual;
PROMPT Variable value is: &Low_date_10 -
Unable to execute the substitution variable in calc scripts in essbase 11.1
Unable to execute the substitution variable in calc scripts in essbase 11.1.3
FIX(&CURRVERSION,COLA)
Unit=units*Listprice;
dataexport "file" "," "E:\NEW.TXT";
ENDFIX
Error: 1200471 Error parsing formula for FIX STATEMENT (line 1): expression expected before [)]
This is error it throws when executing the calculation script
I wonder whether its a problem with substitution variable i want to know wat went wrong inside the fix statement
I have created substitution variable use maxl
Installed the essbase in custom manner and standlone mode nt register with the shared services ,
Is this problem with the custom installation of essbase
Regards
shennaIf you remove the substitution variable and replace it with the actual value (whatever that is), does the code work? That will tell you if the issue is around the substitution variable or not.
John -- First you race Glenn, then you race me -- and you always win. :)
Regards,
Cameron Lackpour -
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 -
Peculiar problem with Essbase (Calc Script) - substitution variable / UDAs
This is odd but I have a script like :
VAR iloop=1,break=0;
FIX(<required POV>)
Loop (20,break)
VAR Country_total1,Country_total2,Country_total3;
FIX (@UDA(Entity,@ALIAS(@CONCATENATE("&Country",iloop)))) // &Country1, &Country2 - are substitution variables with UDAs stored as strings
Statements;
/* +<statements for calculating total values.. for that country and stored against variables>+ */
Country_total1=Country_total1+ +<Calculation>+
ENDFIX
/* Second part : Now again the calculations stored in the variables are to be stored against specific entities */
FIX (@UDA(Entity,@ALIAS(@CONCATENATE("&Country",iloop))))
FIX(@ISUDA(Entity,<Check1>)
..... Assign to relevant account
ENDFIX
ENDFIX
ENDLOOP
ENDFIX
Now the problem is that the first fix statement works just fine, but the FIX statement in the 'second part' throws an error
Error: 1200354 Error parsing formula for [FIX STATEMENT] (line 66): expected type [STRING] found [EXTVAR] ([iloop]) in function [@CONCATENATE]
If I hard code the 'second part' FIX statement to the substitution variable directly - it works just fine.
How can the first statement work and not the second one ? They are exactly the same.Glenn, thanks - I hadn't thought of that :).
But it still does not entirely solve my problem (please see my previous post depicting a requirement similar to ours )
- We have lots of countries (50-60+ might be much more) and each country can have multiple entities (3-4 on an average - can go unto 7-8)
- so good guess would be around 200 entities
- So say I have to do it for 2 countries only (two entity types). Then I need 4 variables - 2 for each country ('country 1 ET1 total', 'Country 1 ET2 Total')
When the list is 20 counties - variables become 40 :(.
- Still leaving aside the 40 variables for a bit -
There are subsequent steps of calculations which needs to be done based on these totals (which are exactly the same for all countries) - just that we need the correct totals to begin with and the rest is already stored in the DB
So since I have a different variable for each country - I cannot write one single calculation block to use the variables sequentially one by one (can I ?)
I might have to write a separate calculation block for each of these countries. (20 separate blocks)
That's what I was trying to avoid and simplify with the substitution variable (but is not working)
- Create substitution variables - which would store the alias of the required countries (2/10/20 as many required)
- Loop through these substitution variables - using them one by one
- So I just need one single block of calculation with all the variable in the calc script being reused after each country calculation is done
- and the user need not go into the script, as the only thing that will change are the countries. And he can change it easily through the substitution variable.
Edited by: Ankur on Jun 27, 2012 12:53 PM
Maybe you are looking for
-
Late 2011 Macbook Pro Freezing ......
My Macbook Pro keeps freezing and it is driving me crazy. It typically freezes about 3 times a week. I usually have my Macbook Pro attached to a 23" Cinema Display (With Macbook Pro screen closed), 2 daisy chained external WD mybook external drives (
-
Is music created in logic pro compatible with the logic pro x ? for instance if you have created something in logic pro and want to add or tweak it, is that possible? I suppose you would need the original logic folder?
-
Hello all! I have a problem with OCI8 and RoR, when I use select query to Orcle Data Base I take result where cyrilic characters are "?", and I can't decode this result, but when I create OCI8 conection in .rbx file on the server ( Linux) I take a ri
-
Composite Key Validation in EOImpl
Hello, Please anyone can give example of how to validate composite key validation? I have tried by following in EOImpl code but its not working: OADBTransaction transaction = getOADBTransaction(); Object[] ItemKey = {getOrganizationId(),getUserId(),g
-
PSE 8 - recurring error creating WMV file
I'm in Windows Vista Business using PSE 8 but with PRE 8 available but not in play here. I have successfully created one slideshow and saved it to an 8GB ur drive using high quality output and saving the file as wmv. at 800x600. It only took up abou