Passing Substitution Variable

Hi Everyone,
I'm trying to pass a substitution variable that contains a where clause from TEST2_PROC to TEST1_PROC, but all records are selected by TEST1_PROC as though the variable is ignored even though it contains the correct syntax.
Code below.
Any suggestions?
Thank You in Advance for Your Help,
Lou
create or replace
PROCEDURE TEST2_PROC
AS
my_refcur SYS_REFCURSOR;
my_id ci_summrpt_report_codes.id% TYPE;
my_descr ci_summrpt_report_codes.descr% TYPE;
my_valid_flag ci_summrpt_report_codes.valid_flag% TYPE;
my_success VARCHAR2(100);
my_where VARCHAR2(50) := ' WHERE ID = 1';
BEGIN
TEST1_PROC(my_refcur,my_where) ;
DBMS_OUTPUT.PUT_LINE('ID DESCR VALID_FLAG');
DBMS_OUTPUT.PUT_LINE('----- ------- ---------');
LOOP
FETCH my_refcur INTO my_id, my_descr, my_valid_flag;
EXIT
WHEN my_refcur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(my_id || CHR(9) || RPAD(my_descr,25) || CHR(9) || my_valid_flag);
END LOOP;
CLOSE my_refcur;
END TEST2_PROC;
create or replace
PROCEDURE TEST1_PROC (
p_refcur OUT SYS_REFCURSOR,
p_where in VARCHAR2
IS
v_id ci_summrpt_report_codes.id% TYPE;
v_descr ci_summrpt_report_codes.descr% TYPE;
v_valid_flag ci_summrpt_report_codes.valid_flag% TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(p_where);
OPEN p_refcur FOR SELECT id, descr, valid_flag FROM
(SELECT 1 AS "ID", 'ONE' AS "DESCR", 'Y' AS "VALID_FLAG" FROM DUAL
UNION ALL
SELECT 2, 'TWO', 'Y' FROM DUAL
UNION ALL
SELECT 3, 'THREE','Y' FROM DUAL
UNION ALL
SELECT 4, 'FOUR','Y' FROM DUAL)
p_where;
END TEST1_PROC;

In TEST1_PROC you need to open ref cursor with dynamic SQL:
create or replace
PROCEDURE TEST1_PROC (
p_refcur OUT SYS_REFCURSOR,
p_where in VARCHAR2
IS
v_id ci_summrpt_report_codes.id% TYPE;
v_descr ci_summrpt_report_codes.descr% TYPE;
v_valid_flag ci_summrpt_report_codes.valid_flag% TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(p_where);
OPEN p_refcur FOR 'SELECT id, descr, valid_flag FROM ' ||
'(SELECT 1 AS "ID", ''ONE'' AS "DESCR", ''Y'' AS "VALID_FLAG" FROM DUAL ' ||
'UNION ALL ' ||
'SELECT 2, ''TWO'', ''Y'' FROM DUAL ' ||
'UNION ALL ' ||
'SELECT 3, ''THREE'',''Y'' FROM DUAL ' ||
'UNION ALL ' ||
' SELECT 4, ''FOUR'',''Y'' FROM DUAL) ' ||
p_where;
END TEST1_PROC;SY.

Similar Messages

  • Pass substitution variable to a region source

    Hi, I am trying to show an oracle report in a region. I was able to display it using javascript popupurl , in a seperate window. But, now I need to display it in the region. I want to pass the &Reports_url to region source, instead of writing the whole url as 'https://host.portname.....' IS it possible? Can anyone please give me some help?
    Thanks in advance,
    Regards,
    Suma.

    Check the header you create in the download procedure. Here's my download procedure:
      PROCEDURE download_file
        ( p_docid IN NUMBER,
          p_sessionid IN NUMBER,
          p_personsystemid IN NUMBER,
          p_pageid IN NUMBER,
          p_attachment IN VARCHAR2 DEFAULT 'Y'  )
      IS
        session_expired EXCEPTION;
        invalid_session EXCEPTION;
        PRAGMA EXCEPTION_INIT( session_expired, -20101 );
        PRAGMA EXCEPTION_INIT( invalid_session, -20100 );
        l_mime VARCHAR2(48);
        l_length NUMBER;
        l_filename VARCHAR2(400);
        l_doc BLOB;
        l_attachment VARCHAR2(1) := p_attachment;
      BEGIN
        p_login.validate_session( p_sessionid );
        IF p_security.check_page_access( p_personsystemid, p_pageid ) = FALSE THEN
          htp.p( '<b>You do not have access to this document</b>' );
        ELSE
          SELECT mime_type, doc_size, doc_name, doc_blob
          INTO l_mime, l_length, l_filename, l_doc
          FROM doc_tab
          WHERE docid = p_docid;
          owa_util.mime_header( NVL( l_mime, 'application/octet' ), FALSE );
          htp.p( 'Content-length: ' || l_length );
          IF p_attachment = 'Y' THEN
            htp.p( 'Content-Disposition: attachment; filename="' || SUBSTR( l_filename, INSTR( l_filename, '/' ) + 1 ) || '"' );
          ELSE
            htp.p( 'Content-Disposition: filename="' || SUBSTR( l_filename, INSTR( l_filename, '/' ) + 1 ) || '"' );
          END IF;
          owa_util.http_header_close;
          wpg_docload.download_file( l_doc );
        END IF;
      EXCEPTION
        WHEN no_data_found THEN
          htp.p( '<B>Document Not Found</B>' );
        WHEN session_expired THEN
          htp.p( '<B>Your session has expired</B>' );
        WHEN invalid_session THEN
          htp.p( '<B>Invalid Session ID</B>' );
      END download_file;Look at the part starting with IF p_attachement = 'Y' THEN
    chet

  • 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.

  • A method for passing in the system date to either a substitution variable or directly into a calc script for use on the fix statement

    Does anyone have an idea of how to pass in the server system date into a calc script or into a substitution variable so that I can fully automate my calc script to only calculate the current day? Thanks very much for any assistance on this.

    unsure why cannot att bat<BR>below is raw code meant to insert into .bat file<BR>================================================<BR><BR>code starts below this line<BR>================================================<BR>:: <BR>:: pls ensure essbase server up and running <BR>:: batch file to upd subs var <BR>:: insert correct values below<BR>:: <BR>:: substitution variables set up in cube: curryr, lastyr <BR>:: substitution variables set up in cube: currmth, prevmth ... <BR>::<BR><BR>:: setting of local env vars<BR>setlocal<BR>::<BR><BR>:: setting of job control vars<BR>set svr=<< insert value here >><BR>set uid=<< insert value here >><BR>set pwd=<< insert value here >><BR>::<BR><BR>:: setting of date and time vars<BR>for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (<BR>set dayofweek=%%i<BR>set day=%%k<BR>set month=%%j<BR>set year=%%l<BR>set datestamp=%%l_%%j_%%k<BR>)<BR>for /F "tokens=1-2 delims=: " %%i in ('time /t') do (<BR>set hour=%%i<BR>set minute=%%j<BR>set timestamp=%%i_%%j<BR>)<BR>::<BR><BR>:: setting year vars<BR>set /a curryr=%year%<BR>set /a lastyr=(%year% - 1)<BR>::<BR><BR>:: setting paths and files<BR>set destpath=<< insert path here >><BR>set errpath=<< insert path here >><BR>set errfiles=%errpath%\*.err<BR>set errfiledir=%errpath%\%datestamp%_%timestamp%_err.dir<BR>set errfile=%destpath%\%datestamp%_%timestamp%_err.err<BR>set logfile=%destpath%\%datestamp%_%timeStamp%_log.log<BR>set upd_var_file=%destpath%\upd_var.txt<BR>::<BR><BR>:: initial housekeeping<BR>if exist %errfile% del %errfile%<BR>if exist %logfile% del %logfile%<BR>if exist %upd_var_file% del %upd_var_file%<BR>if exist %errfiledir% del %errfiledir%<BR>::<BR><BR>:: start all<BR>echo. >> %logfile%<BR>echo rem &0 >> %logfile%<BR>echo. >> %logfile%<BR>echo rem --- start all --- >> %logfile%<BR>date/t >> %logfile%<BR>time/t >> %logfile%<BR><BR>:: dates<BR>echo rem --- dates --- >> %logfile%<BR>echo Curr Year = %curryr% >> %logfile%<BR>echo Last Year = %lastyr% >> %logfile%<BR><BR>:: gen temp txt to upd subs vars<BR>echo rem --- upd subs vars start --- >> %logfile%<BR>echo. >> %upd_var_file%<BR>echo. >> %upd_var_file%<BR>echo login "%svr%" "%uid%" "%pwd%"; >> %upd_var_file%<BR>if %month% == 01 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Dec"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Nov"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>if %month% == 02 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jan"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR> echo updatevariable "CurrYr" "%svr%" "" "" "FY%curryr%"; >> %upd_var_file%<BR> echo updatevariable "NextYr" "%svr%" "" "" "FY%nextyr%"; >> %upd_var_file%<BR> echo updatevariable "NextY2" "%svr%" "" "" "FY%nexty2%"; >> %upd_var_file%<BR> echo updatevariable "LastYr" "%svr%" "" "" "FY%lastyr%"; >> %upd_var_file%<BR> echo updatevariable "LastY2" "%svr%" "" "" "FY%lasty2%"; >> %upd_var_file%<BR> echo updatevariable "LastY3" "%svr%" "" "" "FY%lasty3%"; >> %upd_var_file%<BR> echo updatevariable "PrevYr" "%svr%" "" "" "FY%lastyr%"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Dec"; >> %upd_var_file%<BR>)<BR>if %month% == 03 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Feb"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jan"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR> echo updatevariable "PrevYr" "%svr%" "" "" "FY%curryr%"; >> %upd_var_file%<BR>)<BR>if %month% == 04 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Mar"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Feb"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q1"; >> %upd_var_file%<BR>)<BR>if %month% == 05 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Apr"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Mar"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 06 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "May"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Apr"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 07 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jun"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "May"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q2"; >> %upd_var_file%<BR>)<BR>if %month% == 08 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Jul"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jun"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 09 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Aug"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Jul"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 10 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Sep"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Aug"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q3"; >> %upd_var_file%<BR>)<BR>if %month% == 11 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Oct"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Sep"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>if %month% == 12 (<BR> echo updatevariable "CurrMth" "%svr%" "" "" "Nov"; >> %upd_var_file%<BR> echo updatevariable "PrevMth" "%svr%" "" "" "Oct"; >> %upd_var_file%<BR> echo updatevariable "CurrQtr" "%svr%" "" "" "Q4"; >> %upd_var_file%<BR>)<BR>echo. >> %upd_var_file%<BR>echo exit; >> %upd_var_file%<BR><BR>:: run temp txt to upd subs vars <BR>esscmd %upd_var_file%<BR>echo rem --- update subs vars end --- >> %logfile%<BR> date/t >> %logfile%<BR> time/t >> %logfile%<BR><BR>:: end all<BR>echo rem --- end all --- >> %logfile%<BR> date/t >> %logfile%<BR> time/t >> %logfile%<BR><BR>: end_all<BR>endlocal<BR><BR>===============================<BR>

  • MaxL Pass parameter zu create substitution variable

    Hi everybody,I'm trying to pass a parameter from a DOS batch file to a MaxL script to create a substitution variable with that parameter.DOS batch file:...set var_version = "Final Version"essmsh Test.msh %var_version%MaxL file:....alter application TEST set variable SUBST_VERSION $1=> the substitution variable should be "Final Version" (incl. double-quotes because of the whitespace in the variable's value), but in fact, the substitution variable will be "Final" (without any double-quotes; they have been stripped by MaxL!?)=> if I don't use a parameter it works:alter application TEST set variable SUBST_VERSION '"Final Version"'=> I tried the following statement to keep my double-quotes, but the parameter won't be expanded then:alter application TEST set variable SUBST_VERSION '"$1"'So, does anybody know how to pass a parameter containing whitespaces to create a substitution variable within a MaxL script?Thanks for your hints!Marc

    Hi,Try this one:1. Create batch file which will produse you a whole MAXL statement. This can be done with > or >> statement at the end of the commanad.E.g.: whole_command_with_"Final" >> to file.txt2. Execute maxl with above generated file.Hope this helps,Grofaty

  • 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/Linux

    AIX 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.

  • 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

  • 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.

  • Problem setting the value of a substitution variable in a calc script

    Hi, All.
    I'm trying to update the value of a substitution variable inside an IF statement and I'm having trouble.
    Here's the code:
    *"Jan"(*
    IF  (LoopCounter = 1) &varEntity = "100";
    ENDIF;)
    the error I get back from EAS is:
    Error: 1200336 Error parsing formula for [Jan] (line 54): [(] without [)]

    I know CL knows a lot about HBR, if he's around today... LOL
    As a matter of fact, I just used an HBR (not using Calc Manager till I have to)'s macro functionality to drive fx for different Scenarios in a Planning app. Here's how I call the macro:
              /*     Call the macro mcrFxCoreOutYears for the four fx rate types for ALL 12 months of the year.     */
              FIX(&BudYear)
                   %mcrFxCoreOutYears(Constant)
                   %mcrFxCoreOutYears(Comparable)
                   %mcrFxCoreOutYears(Estimate)
                   %mcrFxCoreOutYears(Actual)
              ENDFIXI pass the Scenarios Constant, Comparable, Estimate, and Actual to the macro mcrFxCoreOutYears. You can apply HBRs against Essbase.
    I believe (I can't remember what exactly -- is it that templates don't accept parameters? That seems hard to believe. Looking at a CM template, that does seem to be the case. Bummer if I'm right.) that Calc Manager BRs have less functionality wrt templates, but I haven't worked with CM for over a year.
    It works really well -- a single place to maintain code and no appreciable performance cost.
    You cannot launch a HBR from a MaxL script but HBRs can be launched from command lines -- this may constrain where you place your automation (it basically has to run off of whatever the EAS server is. You may end up shelling out of MaxL to execute the HBR or even execute scripts across servers -- that does get more complicated.).
    Anyway, if you have any more questions, ask away -- it really is a very powerful component. I will have to look at CM more closely (sooner or later I will lose the HBR vs CM argument and at least need to know if templates support parameters) to see if I'm right on what I wrote above.
    Regards,
    Cameron Lackpour
    P.S. You cannot define an ARRAY in an HBR macro because ARRAY arrayname[value] gets read as a parameter. I ended up declaring the array in the calling HBR.
    P.P.S. I really need to write up the fx approach in a blog post -- it is wicked fast and really easy to use. Too many other posts in the queue already.
    Edited by: CL on Aug 24, 2011 1:48 PM

  • Essbase server - automatic change of substitution variable from SQL

    Hi,I would like to automaticaly change the substitution variable in Essbase Server. Is it posible to change the substitition variable from external source e.g. SQL statement?Simple sample:I would like to assign value "2003" to "CurYear" substitution variable. But value "2003" I would like to get from SQL:"select year(current date) from table".There are commands in Esscmd and MaxL Shell, see bellow.Esscmd command:CREATEVARIABLE "CurYear" "localhost" "" "" "2003";MaxL Shell:alter system set variable CurYear '2003';Is it possible to get the value '2003' from SQL and pass this value to Esscmd command or MaxL Shell?My system:Windows 2000 Professional Service pack 4Essbase at 6.5.3 levelThanks,Grofaty

    You can create a text file from the SQL server that writes the command like"CREATEVARIABLE "CurrYear" "Servername" "AppName" "DBName" "2005";then you can create a schedule job that would run this script which can update the variable. CREATEVARIABLE creates/replaces the current variable.

  • && Substitution Variable in Package Body using SQL Developer

    Hi Folks,
    I've moved over to working to in SQL Developer (its a very early version - 1.0.0) from a combination of SQL*Plus command line and a text editor. I'm trying to get this upgrgraded, but I think the question will be the same with a newer version anyway.
    I am creating a package, and in the package body I have some &&my_var substitutions that I was previoulsy prompted for when calling the .sql from the command line SQL*Plus. I need this as the variable needs to be different for the development and live environment.
    When working in SQL Developer, I can load the package body from Connection->Packages->My Package->My Package Body, and click the edit button to edit the code, however, when I click the Compile button in the top of the window my code error's because of the substituion variablle. An example is:
    CREATE OR REPLACE
    PACKAGE BODY MY_PACKAGE AS
    PROCEDURE MY_PROCEDURE
    BEGIN
    my_variable := &&my_function_from_live_or_dev_database
    END MY_PROCEDURE
    Can anyone tell me if there is a way of defining a compiler variable within the IDE widow while editing a package body stored in the database, without manually copying the code into the Worksheet and running it as a script?
    Thanks,
    AM

    953104 wrote:
    Thanks for the reply, the code was just quickly typed to show the sort of thing I am doing, it wasn't actual code form my project.
    I've come from a C background so what I would have done would be create a #define and changed to when on live or development - or passed the variable to the build environment from the IDE or makefiles and the change would have reflected through my whole project.
    What I want to be able to do is alter a definition of some sort that will reflect throughout my whole project, so I can change it in one location to minimize code changes before going live. I don't really want to be prompted at all. On one system it needs to be DEV_10 and on the other it needs to be LIVE_10.Is there a possibility to elimiante this difference at all?
    For example if DEV_10 is the oracle schemauser on the development database and LIVE_10 would be the one on the production system. THen you could just remove all references to the schema from your code.
    IF you are already connected to this schema, then you don't need to specify the schema name anymore.
    example
    instead of
    create or replace package dev_10.myPackage
    ...you can simply use
    create or replace package myPackage
    ...If needed you can alter the cuurently connected user just before you run the script.
    alter session set current_schema = LIVE10;
    create or replace package myPackage
    ...This would be a different working window in the developer (script worksheet, instead of direct pl/sql editor).
    Substitution variables are allowed there.

  • 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
    chris

    Frank 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.

  • Substitution variables in stored procedures

    Help, anybody! I want to create a procedure that updates a column of a table, however I want that column and the new data specified at run time. I've tried writing a procedure that has substitution variables for the column and new_data values:
    CREATE OR REPLACE PROCEDURE update_client(v_account_id IN VARCHAR2)
    IS
    v_column varchar2(50);
    v_new_data varchar2(50);
    last_name varchar2(20);
    BEGIN
    v_column:=&v_column;
    if v_column=last_name then
    UPDATE Client set last_name='&v_new_data' where account_id=v_account_id;
    end if;
    end;
    but that's not working, and I also tried to pass v_column and v_new_data as parameters but that won't work either.
    CREATE OR REPLACE PROCEDURE update_client (v_account_id IN VARCHAR2, v_column IN VARCHAR2, v_new_data IN VARCHAR2) AS
    BEGIN
    UPDATE client set v_column=v_new_data where v_account_id=account_id;
    END;
    I get the error: unable to resolve "V_COLUMN" as a column
    Is there anyway at all to do this via a stored procedure? I'm all out of ideas.
    Thanks

    In Oracle8i you can use dinamic nebeded SQL. In previous versions you need DBMS_SQL.
    Regards
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Lori Fortner ([email protected]):
    Help, anybody! I want to create a procedure that updates a column of a table, however I want that column and the new data specified at run time. I've tried writing a procedure that has substitution variables for the column and new_data values:
    CREATE OR REPLACE PROCEDURE update_client(v_account_id IN VARCHAR2)
    IS
    v_column varchar2(50);
    v_new_data varchar2(50);
    last_name varchar2(20);
    BEGIN
    v_column:=&v_column;
    if v_column=last_name then
    UPDATE Client set last_name='&v_new_data' where account_id=v_account_id;
    end if;
    end;
    but that's not working, and I also tried to pass v_column and v_new_data as parameters but that won't work either.
    CREATE OR REPLACE PROCEDURE update_client (v_account_id IN VARCHAR2, v_column IN VARCHAR2, v_new_data IN VARCHAR2) AS
    BEGIN
    UPDATE client set v_column=v_new_data where v_account_id=account_id;
    END;
    I get the error: unable to resolve "V_COLUMN" as a column
    Is there anyway at all to do this via a stored procedure? I'm all out of ideas.
    Thanks<HR></BLOCKQUOTE>
    null

  • Substitution variable maxl from batch dynamic

    Hi,
    I have set up a batch file which is calling .msh file which changes my substitution variables.
    I am running this command: "alter database App2.Plan1 set variable 'ActMonth1' 'Jul';"
    "alter database App2.Plan1 set variable 'ActMonth2' 'Aug';"
    "alter database App2.Plan1 set variable 'ActMonth3' 'Sep';"
    I want my values Jul. Aug and Sep to change dynamically. E.g. In Database i will say this forecast starts in Sep so i will get values Sep, Oct, and Nov to my values for ActMonth1, ActMonth2, ActMonth3
    Is this possible? Or how can i make it automatically?

    Hi,
    Would it be alright just to pass the values into to maxl script from a batch script.
    essmsh var.mxl Jul Aug Sep
    Then your maxl script picks up the values e.g
    alter database App2.Plan1 set variable 'ActMonth1' $1;
    alter database App2.Plan1 set variable 'ActMonth2' $2;
    alter database App2.Plan1 set variable 'ActMonth3' $3;
    Then you would just change the values being passed into the maxl.
    The values being passed in could be generated by some logic in the batch script.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Outline Order, Calc Script Performance, Substitution Variables

    Hi All,
    I am currently looking in to the performance side.
    This is mainly about the calculation script performance.
    There are lot of questions in my mind and as it is said you can get the results only by testing.
    1. Outline order should be from least sparse to most sparse
    (other reason : to accomodate as many sparse members in to calculator cache) correct me if I am wrong
    2. Is Index entry created based on the outline order. For example I have outline order as Scenarios, Products, Markets then does my index entry be like scenario -> Products -> Markets ?
    3. Does this order has to match with the order of members in FIX Statement of calculation script?
    4. I have 3 sparse dimensions. P (150 members), M (8 members), V (20 members).
    I use substitution variables for these three in the calculation script. And these three are the mandotary things in my calculation script. Now when I see the fix statement, these three are the first 3 parameters of the fix statemtn and since I am fixing on a specific member, placing these three members as the first 3 sparse dimensions in the outline, ill it improve performance?
    In one way, I can say that a member from P, M,V becomes my key for the data.
    Theoritically if I think, may be it will...but in practical terms I don't see any of such thing.. Correct me If my thinking is wrong.
    One more thing, I have a calc script with say around 10 FIX statements and this P,M,V is being used in every FIX statemnts. Since my entire calculation will be only on one P, one M, one V. Can I put everything in one FIX at the beginning and exclude it from remaining FIX statememts?
    5. I have a lot of cross dimensional operations in my calc scripts for accounts dimension (500 + ) members.
    Is there a way to reduce these?
    6. My cube statistics..
    Cube size : 80 GB +
    Block Size : 18 KB (Approx)
    Block density : 0.03 . This is what I am more worried about. This really hurts me.
    This is one of the reason why my calculation time is > 7 hours and some times it is horrible when there is huge amount of data (it takes aound 20 + hours) for calculation.
    I would be looking forward for your suggestions.
    It would be really apprecialble if It is Ok to share your contact number so that I can get in touch with you. That could be of great help from your side.

    I have provided some answers below:
    There are lot of questions in my mind and as it is said you can get the results only by testing.
    ----------------------------You are absolutely right here but it helps to understand the underlying principles and best practices as you seem to understand.
    1. Outline order should be from least sparse to most sparse
    (other reason : to accomodate as many sparse members in to calculator cache) correct me if I am wrong
    ----------------------------This is one reason but another is to manage disk I/O during calculations. Especially when performing the intial calculation of a cube, the order of sparse dimensions from smallest to largest will measurably affect your calc times. There is another consideration here though. The smallest to largest (or least to most) sparse dimension argument assumes single threading of the calculations. You can gain improvements in calc time by multi-threading. Essbase will be able to make more effective use of multi-threading if the non-aggregating sparse dimensions are at the end of the outline.
    2. Is Index entry created based on the outline order. For example I have outline order as Scenarios, Products, Markets then does my index entry be like scenario -> Products -> Markets ?
    ----------------------------Index entry or block numbering is indeed based on outline order. However, you do not have to put the members in a cross-dimensional expression in the same order.
    3. Does this order has to match with the order of members in FIX Statement of calculation script?
    ----------------------------No it does not.
    4. I have 3 sparse dimensions. P (150 members), M (8 members), V (20 members).
    I use substitution variables for these three in the calculation script. And these three are the mandotary things in my calculation script. Now when I see the fix statement, these three are the first 3 parameters of the fix statemtn and since I am fixing on a specific member, placing these three members as the first 3 sparse dimensions in the outline, ill it improve performance?
    --------------------------This will not necessarily improve performance in and of itself.
    In one way, I can say that a member from P, M,V becomes my key for the data.
    Theoritically if I think, may be it will...but in practical terms I don't see any of such thing.. Correct me If my thinking is wrong.
    One more thing, I have a calc script with say around 10 FIX statements and this P,M,V is being used in every FIX statemnts. Since my entire calculation will be only on one P, one M, one V. Can I put everything in one FIX at the beginning and exclude it from remaining FIX statememts?
    --------------------------You would be well advised to do this and it would almost certainly improve performance. WARNING: There may be a reason for the multiple fix statements. Each fix statement is one pass on all of the blocks of the cube. If the calculation requires certain operations to happen before others, you may have to live with the multiple fix statements. A common example of this would be calculating totals in one pass and then allocating those totals in another pass. The allocation often cannot properly happen in one pass.
    5. I have a lot of cross dimensional operations in my calc scripts for accounts dimension (500 + ) members.
    Is there a way to reduce these?
    -------------------------Without knowing more about the application, there is no way of knowing. Knowledge is power. You may want to look into taking the Calculate Databases class. It is a two day class that could help you gain a better understanding of the underlying calculation principles of Essbase.
    6. My cube statistics..
    Cube size : 80 GB +
    Block Size : 18 KB (Approx)
    Block density : 0.03 . This is what I am more worried about. This really hurts me.
    This is one of the reason why my calculation time is > 7 hours and some times it is horrible when there is huge amount of data (it takes aound 20 + hours) for calculation.
    ------------------------Your cube size is large and block density is quite low but there are too many other factors to consider to simply say that you should make changes based solely on these parameters. Too often we get focused on block density and ignore other factors. (To use an analogy from current events, this would be like making a decision on which car to buy solely based on gas mileage. You could do that but then how do you fit all four kids into the sub-compact you just bought?)
    Hope this helps.
    Brian

Maybe you are looking for

  • R6025 Runtime Error when starting Photoshop Elements Organizer 12

    I installed Photoshop Elements 12 a couple of weeks ago.  When I run the Photo Editor, everything is fine.  But when I try to run the Organizer, I get the Microsoft Visuall C++ Runtime Library dialog that specifies a Runtime Error! for Program: C:\Pr

  • I cannot open Firefox at all!!!

    I really hope someone can help me with this it's driving me crazy to have to use Internet Explorer. All of a sudden yesterday when I booted the laptop up, I have been unable to open Firefox. I click on it, and just nothing happens whatsoever. I've tr

  • Is it possible to create box plots in illustrator? If yes, then how?

    Is it possible to create box plots in illustrator? If yes, then how?

  • How can I get rid of the "Reset Search" app?

    I have a Macbook Pro and I run Mavericks OS X 10.9.5. There's an application in Launchpad called "Reset Search".See picture 1. I know this is part of the "Install Mac" adware, but I still can't find a way to get rid of it. I downloaded Adware Medic t

  • View open references

    Hi, Are there any NI or third party tools that show open application, vi, control, etc. references? There are a few times when I forget to close a reference and my built application will not close but debugging is painful sometimes. Thanks!