Re: Unix shell script to notify if an array has reached a number of lines

Looking to write a script to send an alert notification when an Oracle database table object reaches a certain value of line number. If anyone has the logic "If this while" for a script shell unix would be great.

With the logic of control and check on the table when it reaches the total line number can be added to the script and on-demand via cron.

Thank you.

Thus, you must periodically (how often?) a COUNT (*) on the target table?  Is this acceptable overhead?

/Korn Bourne shell scripts can compare numbers and check if one is greater than another.  See "-gt" UNIX - Shell basic operators

Hemant K Collette

Tags: Database

Similar Questions

  • How to validate SQL * MORE connection in Unix shell script

    I wrote the following function in unix shell script to validate SQL * MORE connection and throw a user-defined message.

    function check_db_conn

    {

    output | sqlplus-s-L $User/$Password@$SID >/dev/null

    If [[$?-no 0]]; then

    echo 'credentials incorrect DB.

    FI

    }

    However, I would like to change this feature so that the user has entered a good connection and that there is a problem with TNS listener must display the appropriate message.

    Hello

    Try adding:

    lsnrctl status $listener_name > /dev/null
    if [[ $? -ne 0 ]]; then
      echo "Issue with Listener"
    fi
    
  • Call the OBIEE Unix Shell Script

    Hi all

    Is it possible to make a call to a Unix Shell Script with the framework of the Action of OBIEE.

    Thanks in advance

    I don't think, but we can go for it instead side BI. Try to transfer the same features side shell script so that the script can identify your report using the tail of the log nqquery and execute the rest of your lines in shell script.

    This can done and works as expected. If you identify your report instead of this long logical query at all with my suggestion that you can go for a little keyword.

    Score pls help if

  • How2 validate the chain of connection in unix shell script

    I am writing a shell script unix which removes the instance user/passwd/user, form a connection string and pass it to sqlplus. Now, I want to validate if a valid/clean connection string was formed. Basically, I want to do something like below

    sqlplus-s $CONN_STR

    and disconnect if valid string and always disconnect and return to guest if it's not a string valid.

    Is there a clean way, I can check if the return has been after a successful login and how disconnect it in script and check if a string is not valid.

    Create a file name test.sql containing only the OUTPUT and use-L option to SQL * more (attempts to connect only once, instead of reprompting error.)

    D:\>sqlplus -L hr/ko@XE @test.sql
    
    SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:48:37 2010
    
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    
    ERROR:
    ORA-01017: invalid username/password; logon denied
    
    SP2-0751: Unable to connect to Oracle.  Exiting SQL*Plus
    
    D:\>echo %errorlevel%
    1
    
    D:\>sqlplus -L hr/hr@XE @test.sql
    
    SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:48:49 2010
    
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    
    D:\>echo %errorlevel%
    0
    
    D:\>sqlplus -L hr/hr@KO @test.sql
    
    SQL*Plus: Release 11.1.0.6.0 - Production on Wed Feb 17 08:52:22 2010
    
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    
    ERROR:
    ORA-12154: TNS:could not resolve the connect identifier specified
    
    SP2-0751: Unable to connect to Oracle.  Exiting SQL*Plus
    D:\>echo %errorlevel%
    1
    
  • Get PLSQL stored procedure in unix shell script

    Hi Experts,

    I have a PLsql procedure with the specification below-

    PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2);

    I can pass two parameters of SHELL script and it works fine-

    # By calling the PLSQL procedure

    sqlplus-s $APPS_USER < < EOSQL

    SET SERVEROUTPUT SIZE 1000000

    whenever sqlerror exit 1;

    run MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", "ARCHIVE");

    "exit";

    EOSQL

    But now I want to have an output in the plsql procedure parameter-

    PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2, p_return_status IN OUT VARCHAR2);

    based on this I want to determine the concurrent request completion status since the shell script is called via the simultaneous program.

    How will pass parameter out of the shell and how do I use this parameter in the SHELL script to determine completion status?

    Thank you very much.

    Vikrant

    Something like this:

    # By calling the PLSQL procedure
    sqlplus-s $APPS_USER<>
    SET SERVEROUTPUT SIZE 1000000
    whenever sqlerror exit 1;
    declare
    rstatus varchar2 (100) - or however long, it must be
    Start
    MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", 'ARCHIVE', rstatus);
    dbms_output.put_line (' status = ' | rstatus);
    end;
    /
    "exit";
    EOSQL
    grep 'Return status =' somefile

  • DBMS_SCHEDULER - trying to create and run a UNIX shell script from Oracle

    How can I run Script Shell Unix from Oracle using DBMS_SCHEDULER?

    After reading many examples online, I finished the 3 steps below.
    Create program, create jobs, run task. On my 3rd stage, I get the following error.
    How can I make sure that the work was created?

    ORA-27475: "APPS. POSPAY_FILE_CHECK_JOB' must be work

    (1) create the program
    BEGIN
      dbms_scheduler.create_program(
         program_name => 'POSPAY_FILE_CHECK_PROG',
         program_type => 'EXECUTABLE',
         program_action => '/home/ldcgroup/ldccbc/POSPAY_USC2_CHECK.sh',
         number_of_arguments => 0,
         enabled => TRUE,
         comments => 'Test Program'
         );
    END;
    (2) create jobs
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
       job_name          =>  'POSPAY_CHECK_FILE_JOB',
       program_name      =>  'POSPAY_CHECK_FILE_PROG',
       enabled           =>   TRUE);
    END;
    /
    (3) the job (not calendar, I'll run this a concurrent request of EBS)
    BEGIN
       DBMS_SCHEDULER.run_job (
         job_name => 'POSPAY_FILE_CHECK_JOB');
    END;
    /

    Of [documentation | http://download.oracle.com/docs/cd/E11882_01/server.112/e10595/scheduse002.htm#i1009668]

    The job is created disabled. You must enable it with DBMS_SCHEDULER.ENABLE before the Scheduler will automatically run it.
    
    Jobs are set to be automatically dropped by default after they complete. Setting the auto_drop attribute to FALSE causes the job to persist.
    
  • OEDQ 9.0.8 - external task - execution of Shell Script

    Hello Disqualification Experts.

    I am looking for your expert advise on this... With the help of the external task I am able to call the .bat (batchfiles) but I'm not able to run .ksh (UNIX shell script file), attached is the example script I am trying to run via the external task.

    File name: testfile.ksh

    #! / usr/bin/ksh

    Set - x

    $ORACLE_HOME/bin/sqlplus - s edq_test/edqtest@edqd < < EOF

    WHENEVER SQLERROR EXIT SQL. SQLCODE

    EXECUTE SP_TRUNCATE_TABLE ('ABC_OWN', 'ABC_TABLE');

    COMMIT;

    quit smoking;

    EXPRESSIONS OF FOLKLORE

    output

    Disqualification-> Manager-> External tasks-> Creates a new task called TestTask who has the below...

    Command: testfile.ksh

    Working directory: \opt\local\software\edq\config\commandarea

    Get this error Message:

    The external task (Execute testfile.ksh) failed because of the following exception: cannot run program "/ opt/local/software/edq/config/commandarea/testfile.ksh": error = 2. No such file or directory

    Thanks in advance!

    BG

    Dear Richard, thank you for your prompt response.

    # / bin/bash helped and I also have to export the ORACLE_HOME in the script, somehow the $ORACLE_HOME is not recognized by the external task.

    Example of Script working:

    #! / bin/bash

    export ORACLE_HOME=/ora02/oracle/product/11.2.0.4/client

    $ORACLE_HOME/bin/sqlplus - s edq_test/edqtest@edqdev<>

    WHENEVER SQLERROR EXIT SQL. SQLCODE

    EXECUTE SP_TRUNCATE_TABLE ('ABC_SCHEMA', 'ABC_TABLE');

    COMMIT;

    QUIT SMOKING;

    EXPRESSIONS OF FOLKLORE

    output

    Thanks for your help!

    BG

  • Query does not not in shell scripts

    Hi Experts,

    I created a query to check the temp tablespace use in production servers and I wanted to run the query using shell scripts, but when I run the query in the script I get no error or output I am unale to correct where exactly, I make the mistake

    This is the query

    SELECT A.tablespace_name 'space', D.gb_total, ROUND (SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) "gb_used", ROUND (D.gb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) 'gb_free' v$ \sort_segment A, (SELECT B.name, C.block_size, ROUND(SUM (C.bytes) / 1024 / 1024/1024,2) 'gb_total' v$ \tablespace B, v$ \tempfile C WHERE B.ts #= C.ts # GROUP BY B.name, C.block_size) D WHERE A.tablespace_name = D.name GROUP by A.tablespace_name D.gb_total

    You can help in this.

    Thank you...

    Basic Linux/Unix shell script format

    #! / bin/sh

    oracle set environment #.

    Export ORACLE_HOME =...

    export of SID =... or TWO_TASK = export

    .. etc.

    # launch sqlplus

    sqlplus-s/nolog<>

    Connect scott/tiger

    together... environment of sqlplus

    -execution of script sql (or sql query)

    @script.sql

    output

    EXPRESSIONS OF FOLKLORE

    #end script

    Character $ is interpreted by the shell as environment variables, you must escape the $ character is as well as it not assimilated to the variable approx.

    For example, v$ instance should be written as v$ instance.

  • Component sql through shell script

    How to call a sql through UNIX shell script file?

    Rahul India wrote:

    export ORACLE_HOME=$ORACLE_BASE/product/10g
    
    cd $ORACLE_HOME
    set `sqlplus -s / <
    

    THIS SCRIPT IS OK?

    You will also need to set ORACLE_SID

    And I don't know why everyone puts the reference to sqlplus context of a 'set' assessment, nor why they put the reference to Scripture in a redirected input stream. What you need is

    sqlplus -s user/password  @r_100.sql
    

    And to make sure the environment is set correctly:

    export ORACLE_SID=whatever
    export ORAENV_ASK=NO
    . oraenv
    unset ORAENV_ASK=NO
    sqlplus -s user/password  @r_100.sql
    
  • Shell scripts

    I am new to shell scripting, I've heard of him, but that's all.

    Can a DBA, someone recommend me to websites that I can learn UNIX shell script from the point of view of Oracle DBA?

    I would like to see what I can do with UNIX Shell script as a DBA.

    http://www.orafaq.com/wiki/scripts#Unix_Shell_Scripts

    A good collection of Shell script for oracle dba.

    HTH
    Girish Sharma

  • sqlplus from a shell script with the variable in unix

    I'm having some trouble calling sqlplus from a shell script... I am basically asking for a path/name of file which I attribute to one to a variable called $code. Then use cp to move the file ($code) to a new directory. I think that there is something wrong with my sqlplus below. echo $code does not work yet. I thought that $code was variable, which I could see, but rather it seems that the script is trying to rerun the SQL command each time.

    Any help would be greatly appreciated... condensed version of the code is below. Thank you!

    file in $FILES
    do
    Code =""
    code ='sqlplus-s $USER_PWD < < EOF
    Set the off position;
    set pagesize 0;
    Select r.outfile_name OUTFILE
    some paintings
    where file_name = $file;
    EXPRESSIONS OF FOLKLORE"
    echo $code
    CP $code $newdir

    Hello

    I hope code below will help but set feedback off so that he won't be any info if no line selected

    echo ${CODE}
    if [ -z "${CODE}" ]
    then
    echo "No rows returned"
    else
    echo "Returned"
    fi
    

    Concerning
    CA
    uninstall security tool
    essential elements of the Security window
    Windows startup configuration
    the Award bios update

  • OBIEE-Shell Script

    Hi all

    I'm trying my hands on scripting in OBIEE. I wrote following script

    #!/bin/bash
    export PATH=$PATH::$HOME/bin:/u01/app/oracle/obiee117g/instances/instance1/bin
    . /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl status
    
    

    When I run this script. I get the following error.

    /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 25: =: command not found
    /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 26: =: command not found
    /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: syntax error near unexpected token `('
    /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl: line 28: `%commands = ('
    

    What Miss me?

    Thank you

    V

    TL; DR: this point on the third line of your script is redundant and the origin of the problem. Run this instead:

    /u01/app/oracle/obiee117g/instances/instance1/bin/opmnctl status
    

    Also, since you are using the absolute path (that is the full path to opmnctl, starting with a /) setting the environment variable PATH is redundant.

    Explanation:

    The dot is a shortcut for the command of the source , which has a different behavior to just run the script directly.

    You use source when you are wanting to run a script to set the environment etc. variables (an example of this is the script of bi - init.sh, which implements the OBI environment to run utilities such as nqcmd).

    If you open opmnctl itself, you will see that it is a perl script. The "shebang" on the first line tells linux to run the script using the perl interpreter, and I suppose when you are sourcing it Linux tries to pass under the shell running (bash) - and the perl language throws the bash syntax errors that you see

    More information: executable - different ways to execute a shell script - Unix & Linux change battery source or dot operator Man Page. Bash | SS64.com

  • Passwords in shell scripts

    Hi all

    I'm using Oracle 11 g R2 on AIX 7.1

    I'm developing some shell scripts that connect to the database and run queries.
    My question is that I don't want my password to be hard coded in these shell scripts. What is the best way to do not hard code the password?

    Kind regards

    1 use authenticated OS account.
    create a user identified externally.
    Account authenticated OS have the same name as the account corresponding Unix.
    If you have such an account, you can connect using sqlplus.

    2 using Oracle Wallet (10g or higher)

    Ignore the suggestion of mseberg please, it's very dangerous.

    ----------
    Sybrand Bakker
    Senior Oracle DBA

  • pl/sql to java shell script

    This issue crosses many boundaries, but it begins with PL/SQL, and I hope that there is sufficient expertise here in order to cover the basics.

    System: Oracle 11.2.0.1.0 on Oracle 5, 64 - bit Linux

    I have a PL/SQL, java appeal procedure, which in turn calls a shell script. I put a few diagnostic output in the shell script, the redirection of stdout to a file in / tmp. running the script from the command line works perfectly. When it is called by procedures, no output.

    Here is the 'chain of traceability', somehow...

    In the PL/SQL:
    Host_Command (p_command => v_command||v_control_file||v_orasid);
    where the variable v_command = /opt/u01/app/oracle/admin/control/sqlldr3_test.script


    So this is 'Host_command', the whole procedure procedure:
    CREATE OR REPLACE  PROCEDURE "DW"."HOST_COMMAND" (p_command  IN  
        VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    And the shell script /opt/u01/app/oracle/admin/control/sqlldr3_test.script:
    #!/bin/ksh
    export trcfle=/tmp/edstest.$$
    export ORACLE_SID=$2
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dwdev
    export PATH=$PATH:/u01/app/oracle/product/11.2.0/dwdev/bin
    export ORACLE_BASE=/u01/app/oracle
    export SQLLDR_CONTROLFILE=$1
    #
    echo input parms are $* >> $trcfle
    echo environment is: >> $trcfle
    env|grep -i ORACLE|grep -v grep|sort >> $trcfle
    #
    exit
    but in the end, there is no /tmp/edstest.* file
    oracle$ ls -ltr /tmp/eds*
    ls: /tmp/eds*: No such file or directory
    oracle$
    open to all ideas.

    I cut things down to their bases, but with the exception of the line of the high level process, the code above is finished... is that my test cut original scripts to exactly what is show. Requriement of business is to take existing scripts and remove some of the stuff that is hard coded, allowing procedures move from dev to qa to prod without hardcoded values unique to each environment.

    I'm very comfortable with PL/SQL and more with shell scripts, but the java link is a black hole for me.

    When the proc of Java runs the external command, a child process of Unix/Linux is created for it. This process inherits the environment settings of the parent process - that would be a dedicated server process, a work process or shared in the pool of the MTS server process.

    These processes have parameters of environment of bare bones and something fundamental that + $PATH + should not be approved as being valid and usable.

    If the Java code should fully qualify the path to the executable file to run.

    Java code should do 2 things - stdout (and stderr if possible) back to the appellant to PL/SQL as vacrhar2 of the parameters out. And return the exit code of the child process.

    They help a lot in troubleshooting why an outgoing external call failed.

    We use these external calls widely enough (through a number of interfaces, treatments to distance running and pulling on the release of data by the latter in the database). All driven from PL/SQL using the proc of Java to make an outgoing call. If the basics are working-, but there seems to be a constant learning and troubleshooting curve to follow to get this working in a robust way.

  • How to write the CLOB parameter to a file or a XML using shell script?

    I run an oracle stored procedure using shell script. How can I get the OUT of the procedure (CLOB) parameter and write it to a file or a XML in UNIX environment using shell script?
    Edit/Delete Message
    SQL> var c clob
    SQL>
    SQL> begin
      2          select
      3                  DBMS_XMLGEN.getXML(
      4                          'select rownum, object_type, object_name from user_objects where rownum <= 5'
      5                  ) into :c
      6          from    dual;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> set long 999999
    SQL> set heading off
    SQL> set pages 0
    SQL> set feedback off
    SQL> set termout off
    SQL> set trimspool on
    // following in the script is not echo'ed to screen
    set echo off
    
    spool /tmp/x.xml
    select :c from dual;
    spool off
    
    SQL>
    SQL> --// file size
    SQL> !ls -l /tmp/x.xml
    -rw-rw-r-- 1 billy billy 583 2011-12-22 13:35 /tmp/x.xml
    
    SQL> --// file content
    SQL> !cat /tmp/x.xml
    
    
     
      1
      TABLE
      BONUS
     
     
      2
      PROCEDURE
      CLOSEREFCURSOR
     
     
      3
      TABLE
      DEPT
     
     
      4
      TABLE
      EMP
     
     
      5
      TABLE
      EMPTAB
     
    
    
    SQL> 
    

Maybe you are looking for

  • Is anyone elses iPhone on iOS 10 or above show grey stripes and white when you try to restart the appliance just before it stops?

    I restared my Iphone 7 more because I tried to update 10.0.2 and just before it turned off my entire screen turned stripes gray and white goes horzitonally on the screen then powered back and its been working fine since. I tried this on an Iphone 6s

  • problem with printhead - it's on my Officejet Pro 6830

    All I seem to get on the printer is the message above - problem with printhead and underneath there is a code 0xc19a0042. Could someone tell me how to get this printer working again I tried to turn off, remove the ink cartridges, looking for all the

  • Modulation of pulse in USB OR-6225

    I'm trying to modulate the frequency and the amplitude of the pulse coming out of that Board's PFI lines.  Is it possible to change the amplitude of the pulse?

  • Authorization

    Why do I get the following message appears when I open Microsoft Office Outlook?  It seems quite useless, and even if it's a small thing, I find it very irritating.  What can I do to prevent it? "You want the following program to make changes to this

  • lower half of liquid E3 touch screen does not work

    Yesterday my phone would suddenly work the bit from the bottom menu button, the "back" button and I noticed that it was also like this on the screen a little upward from the bottom, but earlier work touch screen. Managed finally to get to reset, woul