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:
user454392
As 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.
Similar Messages
-
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 -
Passing a user-entered value of one variable to other.
Hi Experts,
I am writing an exit for a variable 'Ref. Date' which is the FROM value of 'Cal. Week' variable.
Code works fine when written in CASE I_STEP = 2 of 'Ref. Date' . But errs when "Ready for input" condition is unticked. ('Ref. Date' is used for restriction of a KF).
CAn u pls tell me. Where exactly the code should be written?Ok. Done.
-
Isql*plus 9.2 problem: Substitution variables
hi, i'm new to using isql*plus.
i have written the following script to setup my the structure of a database, it works but when i execute it it asks me to:
Substitution Variables
Enter values for substitution variables in the script to execute:
Variable Value
d
I cant work out why, please help.
here's the script:
--author: daniel smith
--student number: 2235592
--date: 17/02/2005
--isql plus
--Application Development and Database (AD&D)
--Assessment 3
--drop existing tables
drop table expense;
drop table sess;
drop table assignment;
drop table task;
drop table stage;
drop table project;
drop table task_type;
drop table employee;
drop table grade;
--create new tables
create table grade
grade_no number(6) primary key,
description varchar2(50),
rate_per_hour number(5,2)
create table employee
employee_no number(6) primary key,
surname varchar2(50),
first_name varchar2(50),
grade_no number(6),
foreign key (grade_no) references grade(grade_no)
create table task_type
task_type_no number(6) primary key,
description varchar2(50),
grade_no number(6),
foreign key (grade_no) references grade(grade_no)
create table project
project_no number(6) primary key,
project_code varchar2(50),
client varchar2(50),
description varchar2(50),
manager number(6),
foreign key (manager) references employee(employee_no)
create table stage
project_no number(6),
stage_no number(6),
description varchar2(50),
Start_date date,
planned_Duration number(6,1),
fees_basis varchar2(2),
primary key (project_no,stage_no),
foreign key (project_no) references project(project_no),
constraint fees_basis_ck check(fees_basis IN ('fq','vs','vn','cs','cn'))
create table task
project_no number(6),
stage_no number(6),
task_no number(6),
description varchar2(50),
estimated_hours number(6,2),
planned_start_date date,
max_duration number(6,2),
task_type_no number(6),
primary key (project_no,stage_no,task_no),
foreign key (project_no,stage_no) references stage(project_no,stage_no),
foreign key (task_type_no) references task_type(task_type_no)
create table Assignment
project_no number(6),
stage_no number(6),
task_no number(6),
employee_no number(6),
estimated_hours number(6),
primary key (project_no,stage_no,task_no,employee_no)
create Table Sess
Session_no number(6),
Session_date date,
actual_Hours number(6),
chargeable char(1),
project_no number(6),
stage_no number(6),
task_no number(6),
employee_no number(6),
primary key (Session_no),
Foreign key (project_no, stage_no, task_no, employee_no)
references Assignment(project_no, stage_no, task_no, employee_no),
constraint chargeable_sess check(chargeable IN ('y','n'))
create table expense
expense_no number(6),
description varchar2(50),
quantity number(4),
unit_cost number(4,2),
chargeable char(1),
project_no number(6),
primary key(expense_no),
foreign key(project_no) references project(project_no),
constraint chargeable_exp check(chargeable IN ('y','n'))
**********************************************************<< ..
<< --Application Development and Database (AD&D)
<< --
take the '&' off your script,
oracle thinks you want to define variable D,
and obviously you don't want that -
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> -
Oracle 10g express edition ..ampersand substitution variable
when i enter the ampersand substitution variable and run the script in the oracle 10g express edition it is giving me the error of (ORA-01008: not all variables bound)...can someone please indicate what the problem is..
thank youi am running the script in the browser but when i run it it does not give me the possibility to enter the value and that error which i mentioned before comes instantly
reuben -
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. -
User enter sales order, system display " Lock table overflow",
Hi Experts,
We are facing a problem, user enter sales order, system display " Lock table overflow", and using T-code VL02N, system display "You cannot block the transaction at the moment.
Please help.
Thanks,
Sujit S.Dear Sujit,
[Lock Table Overflow|Re: Lock table overflow]
Also, Just check with your Basis-Admin in T. Code: TU02 - profile parameter maintenance
Best Regards,
Amit -
Problem with my substitution variable.
My substitution variables don't prompt properly now. It worked fine before, but I don't know what I did to it. Here is the test code:
set define on;
connect sys/&sysPassword @&instanceName as sysdba;
execute dbms_output.put_line('this is a test');
When I tried to execute above lines in sqlplus, it didn't prompt anything, but got following result instead:
SQL> set define on;
SQL> connect sys/&sysPassword@&instanceName as sysdba;
Enter value for syspassword: execute dbms_output.put_line('this is a test');
Enter value for instancename:
SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon> ::= <username>[<password>][@<connect_string>] | /
SQL>
I remember when I used substitution variables before in sqlplus worksheet, it popup a dialog for input, but it doesn't anymore.
Any ideas about this issue? Or what setting could affect the behavior? Thanks in advance.It would work only if you put these set of statements in a .SQL file and run that file at SQL*Plus prompt:
SQL> @the_sql_script_created_above.SQL -
Financial Reporting (FR) using Substitution Variables with Quotes
HI all,
I've created a substitution variable, &CurWk, for a Period Dimension member. The member name, Dec Wk2, has an embedded space, so I enclose the member name in quotes when assigning it to the substitution variable in EAS. However, when I try to use that substitution variable in Financial Reporting, it does not recognize the Substitution variable. I've closed down and re-opened the FR Studio. If I remove the quotes around the member name when assigning it to the Substitution Variable, then FR will recognize the substitution variable. However, I get an error in the calc scripts if I try to reference the substitution variable if this member name is not enclosed in quotes. In my mind, this seems to be a bug in FR since quotes can be optional when referencing any member name. Has anyone else had this problem? Is there a work-around? I'm using EPM 11.1.1. Thanks for your help!
Vince KellyHi Vince,
For the Calc scripts add & to the front of the sub var and surround the sub var with [ ], for example:
where sub vars are ReptQTR, ReptYR, ReptScenario:
CASE
When (Is(QTR.Currentmember,[&REPTQTR]) and (IS(FY.Currentmember,[&REPTYR]))) then
CASE
When ((ISUDA(L000.CurrentMember,"NC"))) then
CASE
WHEN (ISUDA(L000.CurrentMember,"Expense")) THEN
(([&REPTPYR],[ACT]) - [&REPTSCENARIO])
ELSE
([&REPTSCENARIO] - ([&REPTPYR],[ACT]))
END
END
END
Edited to fix stupid html codes: Iain Curtain on Feb 1, 2010 5:44 PM -
Howto check substitution variable in sqlplus
Hi all,
Is there a way to pass a parameter to a sql script (&1) and set a default if the parameter was not passed.
This should be possible without sqlplus asking for OBJECT_OWNER at runtime.
Something like IFDEF would be fine ;-)
DEFINE OBJECT_OWNER = nvl(&1,'OO')
PROMPT Run for schema: &OBJECT_OWNER
thanks for your help
chrisFrank Kulash wrote:
Hi,
I don't think there's any good way.
You can SPOOL the results of DEFINE, and then parse the output file to see if it contains a given variable name.
The following should set &got_variable to 'Y' or 'N', depending on whether &1 is defined or not:
SPOOL define_output.lst
DEFINE
SPOOL OFF
COLUMN got_variable_col NEW_VALUE got_variable
SELECT CASE
WHEN REGEXP_LIKE ( Q'[
@define_ouptut.lst
, '^DEFINE 1 *=' -- or put any variable name in place of 1
THEN 'Y'
ELSE 'N'
END AS got_variable_col
FROM dual;I haven't test this.
Edited by: Frank Kulash on Oct 30, 2009 6:58 AMNo that won't work, SQL*PLUS commands (the '@') cannot be used inside a SQL statement or PL/SQL block.
Since SQL*PLUS is not designed to have any flow control, best approach may be to use named substitution variables and a more formal usage pattern:
Create initialization script(s) that define all the substitution variables and sets them to their default values.
Create completion script(s) the undefine all the substitution variables.
Any user of your script system must call the initialization script(s) first.
Then if they want to override defaults, they redefine the variable.
Then they call the script(s) that do the interesting stuff. The scripts only use the named variables.
When done, call the completion script(s) to clean up. -
I am trying to create a form in LiveCycle 8 where a user who has the form open can enter in information, and that information then populates into different locations on the page.
Say that there is a drawing of a door. I'd like there to be a form where they enter the width and height, and those numbers that they enter are then put in their corresponding location on the drawing. Any help would be great!!I had something similar and it was because the denominator was a zero before the user entered the variables. It was fixed with an "if/then/endif".
It looks like the problem in yours is form1 being zero. Try
if([YOUR DENOMINATOR]>0)then[YOUR FORMULA HERE]endif
Example:
if(form1>0)then(this.rawValue=form1.#subform[0].NumericField4.rawValue / form1.#subform[0].NumericField5.rawValue)endif
Your formula is a bit more complicated than I can decipher, so I'm not sure how much after the "/" you need to include to capture the part of your denominator that is making it null. You may need to insert everything after the "/" in the ">0" parameter. The goal is to tell it only to execute the calculation when the denominator is greater than 0. -
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/ -
Problem in taking correct Substitution variable in MDX Formula
Hi,
We have MDX Formula which takes Substitution Variable as input . Previously we used Hyperion Essbase 9.3.1.3 version and working fine currently we upgraded to 11.1.1.3 version After Upgrade this formula is not taking correct updated value. Its taking previously updated value . To Take the Correct value we are bouncing the Essbase Services then only new Formula is picking the latest Updated value. This is happening only for one formula and rest everything is working fine. Can you please tell us is there any bug or where is the problem is ?
Thanks,
Naresh.The Database Administrator's Guide and the Essbase Technical Reference are available through the documentation portal:
http://download.oracle.com/docs/cd/E17236_01/nav/portal_3.htm
Both the Database Administrator's Guide and the Technical Reference are searchable on an exact phrase, to find the source of the extract John provided.
http://download.oracle.com/docs/cd/E17236_01/epm.1112/esb_dbag/dotcreat.html#dotcreat1053369
See section "Setting Substition Variables".
Maybe you are looking for
-
Can't open ANY pdf files. Updated to 10.1.8--still "Access Denied."
Hello everyone, I am currently unable to open any PDF files. I recently did a clean re-install of Windows 7 (restored my Toshiba Satellite to out-of-the-box state). After that, I restored all of my personal files from an external HD. Now, every time
-
Hi all, I created a new payment terms but the invoice output shows the one thats in the order i.e. the correct one. but the order output shows the diffrent payment terms the one that is not in the order or the customer master. all partner functions a
-
Post 10.3: Could not find the file "hw.kb" to install.
I'm getting this error on my 10.3 clients. "Could not find the file "hw.kb" to install" I think this is the April PRU...I have applied the post 10.3 fix and this is still not working :/ Full Message: GenericActions.FileCouldNotBeFound{hw.kb} Message
-
AIP-50547 - TPA Not Found - Not Picking up Sender ID (re: "test")
I am getting closer and closer here. I have created an 850 with ACME as the sender, and the host being GlobalChips, but now the system thinks that a sender called "test" is in the edi packet. Does anyone have any ideas here ? I also made sure that my
-
My Laptop crashed. I had a full backup on Carbonite so the iTunes folder is there and downloadable. Is there any way just to import that and have iTunes on my new computer (Windows 7) recognize it?