Passing variables to a SQL script within GC

Does anyone know if it is possible to pass in a variable to a SQL script job within Grid Control? I don't see that I can but I wanted to ask a larger group before cloing the loop on this.
For example, I have a few different databases which contain schemas which contain date-range daily partitioned tables. I have a single code block which normally accepts the table_owner as a variable then loops through to analyze the current day partition. I'd love for OEM to be able to have the job submitted to different database targets whilst passing in a different schema name.
Thank you in advance!

This can be done in two steps, but first create a table containing 1 field in all the target databases (something like table_owner) you want to analyze. Before running the analyze script change in all the to be analyzed databases the table_owner (as a job?). Then run the analyze script that contains a statement that first reads the table_owner and use this table_owner as the variable you want.
Even more simple would be to use a database link from the to be analyzed db's to a central db so you only have to change the table_owner in one table.
Eric

Similar Messages

  • How to define variables in toad sql script editor - newbie

    I have just pull out the script of a Function and want to run it on toad SQL editor.
    I am little bit confused how to define the VARIABLEs here in toad SQL editor to run my script.
    SELECT
    NVL(SUM(debit), 0) - NVL(SUM(credit), 0)
    INTO l_accountBalance
    FROM
    GLP_VoucherMaster vm
    INNER JOIN GLP_VoucherDetail vd ON vm.GLP_VoucherMaster_ID = vd.GLP_VoucherMaster_ID
    INNER JOIN GLP_ChartOFAccounts coa ON vd.GLP_ChartOfAccounts_ID = coa.GLP_ChartOfAccounts_ID
    WHERE
    vm.isActive = 'Y' AND vd.isActive = 'Y'
    -- *** how to define variables in toad sql script editor ***
    AND vm.voucherDate < p_cDate
    AND coa.AccountCode LIKE p_accountCode || '%';
    Thanks
    w\

    Just prefix with a colon (:)
    SELECT   NVL (SUM (Debit), 0) - NVL (SUM (Credit), 0)
      INTO   L_accountbalance
      FROM           Glp_vouchermaster Vm
                 INNER JOIN
                     Glp_voucherdetail Vd
                 ON Vm.Glp_vouchermaster_id = Vd.Glp_vouchermaster_id
             INNER JOIN
                 Glp_chartofaccounts Coa
             ON Vd.Glp_chartofaccounts_id = Coa.Glp_chartofaccounts_id
    WHERE       Vm.Isactive = 'Y'
             AND Vd.Isactive = 'Y'
             AND Vm.Voucherdate < :P_cdate
             AND Coa.Accountcode LIKE :P_accountcode || '%';
    /:p

  • Using &variables in a SQL Script scheduled job within OEM

    Hi...I've been searching through the forum looking for any examples of setting up a job within OEM, using the SQL Script job type, where I can basically use a WHERE clause that says 'where column_name = &variable_name' and somehow provide that at run time, as if I were in a SQL*Plus session and using a PROMPT and ACCEPT command. I thought there might be a way to emulate that situation by placing the value I'd like to qualify on within some placeholder in the Parameter section of the job. We have a few users who have limited access to OEM and need to run queries on GRANTS and ROLES for various users etc. I realize there are other ways to do this, however I'm wondering if OEM has a capability like this. Any info is appreciated! Tks!

    Looks like you're missing the schema name and you'll want to use QUOTENAME to add delimiters to the objects
    e.g. 
    DECLARE @DATABASE AS VARCHAR(50)
    DECLARE @SchemaName as SYSNAME;
    DECLARE @TABLE AS VARCHAR(50)
    DECLARE @QUERY AS VARCHAR(MAX)
    SELECT @DATABASE = '602'
    SELECT @SchemaName = 'dbo' --change as appropriate
    SELECT @TABLE = 'Items'
    SET @QUERY = 'SELECT TOP 10 * FROM ' + QUOTENAME(@DATABASE)+'.' + QUOTENAME(@SchemaName) + '.'+QUOTENAME(@TABLE)
    print @query
    EXEC( @QUERY)

  • Passing UNIX command in SQL Script

    Hi,
    I am writing a sql-script in unix.
    The logic is as below:
    SELECT flag FROM dummy_table;
    If flag = Y Then
    cp ./abc.txt $HOME/abc.txt
    Else
    SELECT id, roll FROM employees;
    Please help me out.
    Thanks and Regards,
    Tony

    I did that way:
    Under SYS create the following procedure:
    CREATE OR REPLACE PROCEDURE SYS.LINUX_RUN (PATH     IN     VARCHAR2,
                                               result      OUT VARCHAR2)
    IS
       script_file   VARCHAR2 (40) := 'my-temp-script.sh';
       script_data   VARCHAR2 (4000);
       MyFile        UTL_FILE.file_type;
       d             VARCHAR2 (4000);
       dump_file     VARCHAR2 (40) := '/tmp/my-temp-file.dat';
       dump_type     UTL_FILE.file_type;
    BEGIN
       pms.post_calls;
       -- Open file
       MyFile := UTL_FILE.fopen ('TMP', script_file, 'w');
       -- Write data to file
       script_data := PATH || ' > ' || dump_file;
       UTL_FILE.put_line (MyFile, script_data, FALSE);
       -- Close file
       UTL_FILE.fflush (MyFile);
       UTL_FILE.fclose (MyFile);
       -- Purge old logs, no fun anyway
       DBMS_SCHEDULER.purge_log (JOB_NAME => 'TEST');
       -- Execute script
       -- The job is created as disabled as
       -- we execute it manually and will
       -- drop itself once executed.
       DBMS_SCHEDULER.create_job (job_name              => 'TEST',
                                  job_type              => 'EXECUTABLE',
                                  job_action            => '/bin/sh',
                                  number_of_arguments   => 1,
                                  start_date            => SYSTIMESTAMP,
                                  enabled               => FALSE);
       DBMS_SCHEDULER.set_job_argument_value ('TEST', 1, '/tmp/' || script_file);
       DBMS_SCHEDULER.enable ('TEST');
       -- Wait for the job to be executed
       -- usually done within 1 second but
       -- I set it to 2 just in case.
       DBMS_LOCK.sleep (2);
       -- Open the output file and
       -- print the result.
       dump_type := UTL_FILE.fopen ('TMP', dump_file, 'r');
       UTL_FILE.get_line (dump_type, d);
       result := d;
       LOOP
          BEGIN
             UTL_FILE.get_line (dump_type, d);
             DBMS_OUTPUT.put_line (d);
          EXCEPTION
             WHEN OTHERS
             THEN
                EXIT;
          END;
       END LOOP;
       UTL_FILE.fclose (dump_type);
       -- Clean up our temp files
       UTL_FILE.fremove ('TMP', script_file);
       UTL_FILE.fremove ('TMP', dump_file);
    END;
    /And grant execute on this procedure to end user.
    Then under granted user you can use this procedure in your PL/SQL code.
    It works just fine for me :)
    Good luck.

  • Error produced when trying to pass variables to a Matlab script

    For some reason, LabVIEW produces an Error 1047 (Unable to pass variable to the script server) whenever I create an input variable to a Matlab code block.
    Outputs work fine (for example, connecting an output "a" to a Matlab code block that says "a=rand(50)" correctly produces a 50x50 array of random numbers that can be displayed in LabVIEW). However, creating any kind of input node, whether or not the associated variable is mentioned in the MATLAB script, brings up an error 1047.
    Any ideas what could be causing this? I'm using LabVIEW 7.0 and MATLAB 7 (R14). I've read the article
    >here and that's not the problem, and I've also updated my matscript.dll to the latest version, 7.0.0.2, which also made no difference.

    For what its worth,
    I work in a company with a lot of Matlab users, and I,m programming in Labview and Matlab.
    When I create a testrig measurement I always have to convert data into Malab format, so I used the script server a lot... exept we have a limited pool of Matlab
    licenses so my work was halted whenever the licences where gone.
    So I wrote a Write2Matlab vi.
    This vi can log data from a measurement and write it in a Matlab readable file format (Matlab6 R12).
    After logging you can append more data. It works with(Double,Single,Int32,Int16,U16,U8,String) matrix see for yourself in an example (Write2matlab_test.vi).
    Perhaps this is an alternative solution for your problem.
    Please send me a reply if you find it usefull.
    John
    Attachments:
    Write2Matlab.llb ‏1145 KB

  • Passing Multiple Parameters to SQL Script from a Shell Script

    Hi Friends,
    I have SQL script which accepts 6 parameters.
    I am calling this from a shell script as shown below:
    sqlplus -s  ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the six parameters, item_number is not a mandatory parameter.
    When i pass all six parameters, there is no issue.
    But when i leave item_number blank, i am getting the below error
    Enter value for 6:
    User requested Interrupt or EOF detected.Based on the error, it seems that the NULL values for item_number is ignored and SQL*PLUS is waiting for one more input from user.
    How can i overcome this issue?
    Regards,
    Sreekanth

    Hi,
    I am calling the shell script from concurrent program and below is the log file of the concurrent program.
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    KORONT_041_SH module: KORONT - Daily Item Master Update
    +---------------------------------------------------------------------------+
    Current system time is 29-JUN-2011 10:09:35
    +---------------------------------------------------------------------------+
    REQUEST_ID: 68510795
    USER_ID: 4219
    PDC:    85
    Item Number:
    KORDC:    124
    PDCSET:   1100000003
    last_updated_in_hours: 24
    EMAIL_ID: [email protected],[email protected]
    SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
    RPTDIR:  /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
    RPTFILE: o68510795.out
    Table truncated.
    *Enter value for 6: User requested Interrupt or EOF detected.*
    Table truncated.
    old  15:       AND ic.organization_id   = &&4
    new  15:       AND ic.organization_id   = 1100000003
    0 rows created.
    Input truncated to 9 characters
    old   8:                AND organization_id   = &&4
    new   8:                AND organization_id   = 1100000003
    0 rows created.
    End of SQL
    No record.
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PRINT   -------------+
    Printing output file.
                   Request ID : 68510795      
             Number of copies : 0      
                      Printer : noprint
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 29-JUN-2011 10:09:38
    +---------------------------------------------------------------------------+Regards,
    Sreekanth

  • Passing Variable back to batch script

    I need to pass the result of a sql script back to the calling batch script. How would I do this? This is what I have tried
    Batch Script
    return_code = 'sqlplus loginname/pass@database path/sqlscript.sql'
    echo $return_code
    sqlscript
    Declare
    v_locked varchar2(1);
    Begin
    SELECT locked into v_locked FROM program_lock
    WHERE program = 'xxx';
    end;
    exit v_locked;

    I already tried the option you suggested.
    This is what I have in my dynamic script:
    PROMPT(SELECT,PR_CTR,,"Select the Profit Center","%ENTITY_DIM%")
    INFO(EQU,=)
    INFO(TAB,;)
    TASK(ZBPC_REVAL_SCRIPT_RUN,SUSER,%USER%)
    TASK(ZBPC_REVAL_SCRIPT_RUN,SAPPSET,%APPSET%)
    TASK(ZBPC_REVAL_SCRIPT_RUN,SAPP,%APP%)
    TASK(ZBPC_REVAL_SCRIPT_RUN,LOGICFILENAME,COPY_ACTUALS.LGX)
    TASK(ZBPC_REVAL_SCRIPT_RUN,REPLACEPARAM,PR_CTR%EQU%%PR_CTR%)
    This is what I have in script logic
    *SELECT(%CURRENT_CYCLE%, "[ID]", "PLAN_CYCLE", "[COMPARISON] ='CURRENT' ")
    *XDIM_MEMBERSET ACCOUNT=BPC711000
    *XDIM_MEMBERSET CURRENCY=LC
    *XDIM_MEMBERSET DATASOURCE=ACTUALS
    *XDIM_MEMBERSET EMPLOYEE=BAS(<ALL>)
    *XDIM_MEMBERSET TIME=BAS(2010.TOTAL)
    *XDIM_MEMBERSET PLAN_CYCLE=%CURRENT_CYCLE%
    *XDIM_MEMBERSET PROFIT_CTR=$PR_CTR$
    *START_BADI  FILTER_PLAN
      QUERY = ON
      WRITE = ON
    *END_BADI
    When I run the DM Package I get the error Memebr  :$PR_CTR$ not exist
    Regards,
    Deepti

  • Calling set of sql scripts within a sqlscript

    Hi i tried running set of scripts as follows
    SQL>@c:\c1 which connects to the DB
    and i have two more scripts within c1 as follows
    connect usrname/pwd
    @c:\i1
    @c:\i2
    exit
    While running this i get the following error
    SP2-0310: unable to open file "@c:\i1.sql"
    SP2-0310: unable to open file "@c:\i2.sql"
    however if i run as SQL>@i1 SQL>@i2 my execution seems to be fine, it errors out if i wrap it into c1 as mentione above, am i doing something wrong or missing something.

    I see that in your script you run @c:\i1 and in SQLPlus you run SQL>@i1. What happens when in SQLPlus you run SQL>@c:\i1.
    I see that you are working on Windows. Usually the starting directory for SQLPlus on Windows is $ORACLE_HOME\bin and not c:\.

  • Passing variables to a shell script

    Hello all,
    I have an applescript that is passing two variables to a shell script. Both variables are being passed, but the script isn't running as I would expect and I can't figure out what it's doing and why.
    Here is the applescript:
    delay 5
    tell me to activate
    display dialog "Please enter the following information."
    property RoomNumber : ""
    display dialog "Enter the room number and building (ie 1312CAC):" default answer RoomNumber
    set the RoomNumber to text returned of the result
    property StationNumber : ""
    display dialog "Enter the Station Number:" default answer StationNumber
    set the StationNumber to text returned of the result
    do shell script ("echo " & RoomNumber & StationNumber & " | /Users/labadmin/Desktop/labbuild.sh")
    and here is the shell script
    #!/bin/sh
    RoomNumber="$1"
    StationNumber="$2"
    compname=($RoomNumber$StationNumber)
    scutil --set ComputerName $compname
    scutil --set LocalHostName $compname
    scutil --set HostName $compname
    echo "Done setting the computer name"
    The only name it sets is the ComputerName. LocalHost is blank and hostname is set to Localhost
    Can someone see what I'm doing wrong here?
    Thank you in advanced.

    The line
    do shell script ("echo " & RoomNumber & StationNumber & " | /Users/labadmin/Desktop/labbuild.sh")
    should be
    do shell script ("/Users/labadmin/Desktop/labbuild.sh " & quoted form of RoomNumber & " " & quoted form of StationNumber)
    In your original code, you are using echo to pass the variables to stdin of the script instead of as command-line parameters. You also don't handle the case where a value is left blank.

  • Pass variable into execute sql task

    hi
    i want to execute my stored proc, in ssis package . i have 2 parameter, so i need pass values from another table one by one.
    i need to execute stored proc for each from another table, by passing values
    how to do it

    hi
    i want to execute my stored proc, in ssis package . i have 2 parameter, so i need pass values from another table one by one.
    i need to execute stored proc for each from another table, by passing values
    how to do it
    You can do it as follows
    1. Add a variable of type object in SSIS
    2. Add a execute sql task with query as
    SELECT field1,field2
    FROM Table
    Set resultset option as Full resultset and in resultset tab map the resultset to object variable.
    3. Add a ForEach loop with ADO enumerator and map it to object variable. Inside loop add two variable to get each iterative values for field1 and field2
    4. Inside loop add a execute sql task and set command as
    EXEC ProcedureName ?,?
    Map the parameters to two variables created inside the loop.
    On executing package the procedure gets executed for each record in the table.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Passing Variables to a SQL Query

    I have a select box with multiple choices allowed in
    form1.ASP. I want =
    to pass the form on submit using request.form ("variable")
    and process =
    data and a query string for an SQL select where statement.
    The form =
    data is in the format of "E123 B456 X789" . What is the best
    means of =
    processing that for my Access database?
    Thanks.
    Ross

    Well, here's the answer:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=3Dtn_15906&slic=
    eId=3D1
    "ross m. greenberg" <[email protected]> wrote in
    message =
    news:gb5reg$714$[email protected]..
    I have a select box with multiple choices allowed in
    form1.ASP. I want =
    to pass the form on submit using request.form ("variable")
    and process =
    data and a query string for an SQL select where statement.
    The form =
    data is in the format of "E123 B456 X789" . What is the best
    means of =
    processing that for my Access database?
    Thanks.
    Ross

  • SQL script within my query

    I'm in dire need for some help. I'm creating a report in Oracle Reports Builder 10.1 and I'm having some issue with retrieving data with the script I wrote. The report I have is filitered by cont_type = 'SC'. One field that I am trying to get has a cont_type of something other then SC or it is NULL. That field is called revised amount. I want to be able to see the results for the revised amt field (revised_amt) even though i'm filitering them out. Is there a way to do that? The other part to it is that the revised amt field will need to be summarized and reset after each contract #. For example...
    Contract #_______Contract Amt_____Revised Amt
    1455-001-SC_____1,023,560.00
    1455-002________________________56,236.00
    1455-003________________________789,653.00
    1356-001-SC_____23,563,566.00
    1356-002________________________25,666.00
    1289-001-SC_____5,222,659.00
    1289-002________________________15,456.00
    1289-003________________________123,456.00
    So for the end result i would like to see the totals of the revised amount for each contract #. It would look something like this
    Contract #______Contract Amt______Revised Amt
    1455-001-SC_____1,023,560.00______845,889.00
    1356-001-SC_____23,563,566.00_____25,666.00
    1289-001-SC_____5,222,659.00______138,912.00
    I'm new to SQL so please be patient with me. Thanks!
    This is my SELECT statement below. Just to clarify, sccont_cont_code's format is 0033-0001. I have to concatenate the '9' onto the beginning of it because the cont_codes have a 9 in front. I apologize in advance for my limited knowledge of SQL and PL/SQL. I am in the process of learning it as we speak. I'm being put into a tough position in my current job and in order for me to succeed I must learn this valuable tool. I appreciate any help for yall and maybe a possible tip here and there. Thanks again!
    SELECT '9' || sccont_cont_code, NVL(sccont_cont_amt, '0.00'), fl2030_ven_bp_name, fl2030_job_code, fl2030_job_name, NVL(sccont_hldbk_amt, '0.00'), NVL(sccont_bill_amt, '0.00'), NVL(sccont_paid_amt, '0.00'), sccont_chg_amt
    FROM flpm2030_v
    ,sccont
    WHERE fl2030_job_code = sccont_job_code
    AND fl2030_comp_code = sccont_comp_code
    AND fl2030_chg_code = sccont_chg_code
    AND fl2030_ven_code = sccont_ven_code
    AND fl2030_comp_code != 'ZZ'
    AND fl2030_cont_type LIKE 'SC'
    ORDER BY fl2030_ven_bp_name
    Edited by: House on Jul 22, 2010 1:44 PM

    So for the end result i would like to see the totals of the revised amount for each contract #. It would look something like this
    Contract #______Contract Amt______Revised Amt
    1455-001-SC_____1,023,560.00______845,889.00
    1356-001-SC_____23,563,566.00_____25,666.00
    1289-001-SC_____5,222,659.00______138,912.00  Hello,
    If you looks for the above result, then you can try with below code
    SELECT SUBSTR(CONT_NO,1,4), SUM(CONT_AMT),SUM(REVS_AMT) FROM TBLCONTRACT
    GROUP BY SUBSTR(CONT_NO,1,4)and in order to get the main contract number, you can write a function in report, which will accept the first 4 digit of the contract number and return the concatenation string of -001-SC. Hence this function output you can use as the first column value
    If my post is helpful mark accordingly.
    Regards
    Manoj
    Edited by: ManojP on Jul 23, 2010 7:41 AM

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • Passing parameters to SQL Script

    I'm trying to pass a parameter to SQL Script like
    sqlplus hr/my_password @myscript.sql King
    but everytime sqlplus is started the system is asking me for this parameter.
    I would like too use this principe in combination with forms. (host user/passwrd@test @test.sql King)
    kind regards,
    Menk

    Your variable name in SQL script must be called &1.
    Eg. SELECT value FROM table WHERE name = '&1.' ;
    So, if you have more than one argument, the followed must be &2. &3. ...
    If you use another name, Oracle always requests the value.
    I hope help you

  • Script fails when passing values from pl/sql to unix variable

    Script fails when passing values from pl/sql to unix variable
    Dear All,
    I am Automating STATSPACK reporting by modifying the sprepins.sql script.
    Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
    I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
    From the sprepins.sql script
    variable bid number;
    variable eid number;
    begin
    select begin_snap into :bid from db_snap;
    select end_snap into :eid from db_snap;
    end;
    This fails with the following error:
    DB Name DB Id Instance Inst Num Release Cluster Host
    RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
    :ela := ;
    ERROR at line 4:
    ORA-06550: line 4, column 17:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    &lt;a string literal with character set specification&gt;
    &lt;a number&gt; &lt;a single-quoted SQL string&gt; pipe
    The symbol "null" was substituted for ";" to continue.
    ORA-06550: line 6, column 16:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev su
    But when I change the select statements below the report runs successfully.
    variable bid number;
    variable eid number;
    begin
    select '46' into :bid from db_snap;
    select '47' into :eid from db_snap;
    end;
    Even changing the select statements to:
    select TO_CHAR(begin_snap) into :bid from db_snap;
    select TO_CHAR(end_snap) into :eid from db_snap;
    Does not help.
    Please Help.
    TIA,
    Nischal

    Hi,
    could it be the begin_ and end_ Colums of your query?
    Seems SQL*PLUS hs parsing problems?
    try to fetch another column from that table
    and see if the error raises again.
    Karl

Maybe you are looking for

  • How do i find the answers to my security questions?

    How do I find the answers to the security questions that I must have answered some time ago?

  • Help with "unchecked conversion" warning

    Hello, following line Vector devices = SomeDeviceManager.getDeviceList(); gives a warning (when compiled in java 1.5 with -Xlint): found raw type: java.util.Vector missing type parameters for generic class java.util.Vector<E> When I change code to Ve

  • Case Sensitive URI's / Paths

    Hi, I am currently runing IP 6.4 sp5 on a windows 2003 Server. I have several additoinal document directory paths setup on my domain to take people to differnent sections of my website. The problem I have is that people sometimes are typing the URL i

  • BTE for F-44

    Hi I am trying to find a BTE for F-44 in which I need the 'clearing date should not be greater than the system date'. Could someone tell me which BTE should be used. regards Jimmy

  • Reset Play count on ipod ?

    Hi - Can you reset the play count on the iPod Touch? (I know you can do it for iTunes) Thanks....