Table is not updating

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Table is not updating
# 22  
Old 03-26-2012
The SQL Plus error message published in your parallel thread is unreadable (because it went into an environment variable) but I can get the gist.
https://www.unix.com/shell-programmin...-script-3.html
Please post exactly what appeared on the screen. I believe that it is the key to this problem.
# 23  
Old 03-26-2012
Are they exported?

What is the output of:

Code:
echo echo \$DB_USER_NAME | ksh

edit: I'm closing the other thread.
# 24  
Old 03-26-2012
Quote:
Originally Posted by Scott
Are they exported?

What is the output of:

Code:
echo echo \$DB_USER_NAME | ksh

edit: I'm closing the other thread.
Code:
/p2k/L10.21A/devlp/root/global/data/usage/DAILY>echo $DB_USER_NAME
secadmin
/p2k/L10.21A/devlp/root/global/data/usage/DAILY> echo $DB_PASSWORD
vivadmin
/p2k/L10.21A/devlp/root/global/data/usage/DAILY> echo $TWO_TASK
ltd121a

# 25  
Old 03-26-2012
That's not what I asked.
# 26  
Old 03-26-2012
Quote:
Originally Posted by methyl
The SQL Plus error message published in your parallel thread is unreadable (because it went into an environment variable) but I can get the gist.
https://www.unix.com/shell-programmin...-script-3.html
Please post exactly what appeared on the screen. I believe that it is the key to this problem.
Arun has suggested another way of executing it:
Code:
nawk '{{print $1,$2,$3}}'  ./$DirectoryName/AuditGroupTableTableData_$TimeStamp.txt | while read a b c
do
  echo $a
  echo $b 
  echo $c
  ret=`sqlplus -s  $db_user/$db_pwd@$db_sid  $a $b $c <<EOF > ./${DirectoryName}/Query.sql
SET HEADING OFF
SET SERVEROUTPUT ON
SET FEEDBACK OFF
DECLARE
CNT  NUMBER(5);
DROPCNT NUMBER(5);
ERRORCNT NUMBER(5);
BEGIN
  SELECT COUNT(*) INTO CNT FROM USAGE_INTRNL_ERROR WHERE AUDIT_GROUP_ID='&1';
  IF ( CNT != &3) THEN
    Dbms_Output.put_line('SELECT INTRL_DROP_QTY,INTRL_ERROR_QTY INTO DROPCNT,ERRORCNT FROM USAGE_AUDIT_GROUP WHERE AUDIT_GROUP_NBR=''&1'';';
    SELECT INTRL_ERROR_QTY INTO DROPCNT FROM USAGE_AUDIT_GROUP WHERE AUDIT_GROUP_NBR = '&1';
    SET DROPCNT=DROPCNT-CNT;
    Dbms_Output.put_line('UPDATE USAGE_AUDIT_GROUP SET INTRL_DROP_QTY='||DROPCNT||' ,INTRL_ERROR_QTY='||CNT||'  WHERE  AUDIT_GROUP_NBR=''&1'';'
  END IF;
END;
/
EXIT;
EOF`
  touch ./$DirectoryName/SELECTQuery_$TimeStamp.sql
  touch ./$DirectoryName/UPDATEQuery_$TimeStamp.sql
  for stmt in `cat ./${DirectoryName}/Query.sql`
  do
    is_select=`echo ${stmt} | grep "^SELECT" | wc -l`
    if [ ${is_select} -ne 0 ]
    then
      echo ${stmt} >> ./$DirectoryName/SELECTQuery_$TimeStamp.sql
    else
      echo ${stmt} >> ./$DirectoryName/UPDATEQuery_$TimeStamp.sql
    fi
  done
done

This is what apeared on the screen
Code:
1LK81JVDE2HRNDG
3
0
1LMXTJJD0W28TX2
3
0
1LS1XJGDEVWAC5T
7
1

the files Query.sql,Update.sql were filled up with sqlplus usage which I have posted inthat parallel thread and select sql file is created with 0 bytes.
Code:
-rw-rw-r--   1 atlvivd  dvlpmnt     2214 Mar 26 15:46 Query.sql
-rw-rw-r--   1 atlvivd  dvlpmnt        0 Mar 26 15:46 SELECTQuery_20120326154525.sql
-rw-rw-r--   1 atlvivd  dvlpmnt     6078 Mar 26 15:46 UPDATEQuery_20120326154525.sql

---------- Post updated at 02:54 PM ---------- Previous update was at 02:49 PM ----------

Quote:
Originally Posted by Scott
That's not what I asked.
It also displayed the same:
Code:
 /p2k/L10.21A/devlp/root/global/data/usage/DAILY> echo echo  \ $DB_USER_NAME |ksh
secadmin
 /p2k/L10.21A/devlp/root/global/data/usage/DAILY> echo echo \  $DB_PASSWORD | ksh
vivadmin
 /p2k/L10.21A/devlp/root/global/data/usage/DAILY> echo echo \ $TWO_TASK|ksh
ltd121a

# 27  
Old 03-26-2012
Quote:
I thnk the problem is with the statement :

sqlplus $db_user/$db_pwd@$db_sid $a $b $c <<EOF
I agree, but why not post the error message? The message in the parallel post is too difficult to read because each word is on a separate line.

Quote:
Arun has suggested another way of executing it:
Please post what you used to type and what you typed this time to produce the posted output.

For diagnostic purposes we need you to modify the script to make any error output visible. Don't redirect to a file. Don't capture in a pointless environment variable ($ret). Don't use the "-s" (silent) parameter to sqlplus.

If all else fails, use the "set -x" diagnostic variable in Shell.


Later research:

It would appear that passing parameters to the SQL program using the sqlplus command syntax is not valid:

http://ss64.com/ora/connect.html

http://docs.oracle.com/cd/B10501_01/...h4.htm#1005759

This may be the time for a redesign of the script.

Last edited by methyl; 03-26-2012 at 06:03 PM.. Reason: research into the sqlplus command. Added Oracle link to syntax
# 28  
Old 03-27-2012
Quote:
Originally Posted by methyl
I agree, but why not post the error message? The message in the parallel post is too difficult to read because each word is on a separate line.


Please post what you used to type and what you typed this time to produce the posted output.

For diagnostic purposes we need you to modify the script to make any error output visible. Don't redirect to a file. Don't capture in a pointless environment variable ($ret). Don't use the "-s" (silent) parameter to sqlplus.

If all else fails, use the "set -x" diagnostic variable in Shell.


Later research:

It would appear that passing parameters to the SQL program using the sqlplus command syntax is not valid:

Connect

Starting SQL*Plus

This may be the time for a redesign of the script.
This is what printed over the screen with out backticks,ret and -s options.

Code:
ModifyUsgAuditGroupTable.ksh 120318
********Started processing at 20120327024927**********
 log file path is : ./AuditGroupLogs_20120327024927/AuditUpdate_20120327024927.LOG
1LK81JVDE2HRNDG
3
0

SQL*Plus: Release 10.2.0.4.0 - Production

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Usage 1: sqlplus -H | -V

    -H             Displays the SQL*Plus version and the
                   usage help.
    -V             Displays the SQL*Plus version.

Usage 2: sqlplus [ [<option>] [<logon>] [<start>] ]

  <option> is: [-C <version>] [-L] [-M "<options>"] [-R <level>] [-S]

    -C <version>   Sets the compatibility of affected commands to the
                   version specified by <version>.  The version has
                   the form "x.y[.z]".  For example, -C 10.2.0
    -L             Attempts to log on just once, instead of
                   reprompting on error.
    -M "<options>" Sets automatic HTML markup of output.  The options
                   have the form:
                   HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text]
                   [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
    -R <level>     Sets restricted mode to disable SQL*Plus commands
                   that interact with the file system.  The level can
                   be 1, 2 or 3.  The most restrictive is -R 3 which
                   disables all user commands interacting with the
                   file system.
    -S             Sets silent mode which suppresses the display of
                   the SQL*Plus banner, prompts, and echoing of
                   commands.

  <logon> is: (<username>[/<password>][@<connect_identifier>] | /)
              [AS SYSDBA | AS SYSOPER] | /NOLOG

    Specifies the database account username, password and connect
    identifier for the database connection.  Without a connect
    identifier, SQL*Plus connects to the default database.

    The AS SYSDBA and AS SYSOPER options are database administration
    privileges.

    The /NOLOG option starts SQL*Plus without connecting to a
    database.

  <start> is: @<URL>|<filename>[.<ext>] [<parameter> ...]

    Runs the specified SQL*Plus script from a web server (URL) or the
    local file system (filename.ext) with specified parameters that
    will be assigned to substitution variables in the script.

When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run.  The files may
contain SQL*Plus commands.

Refer to the SQL*Plus User's Guide and Reference for more information.


code used:
Code:
nawk '{{print $1,$2,$3}}'  ./$DirectoryName/AuditGroupTableTableData_$TimeStamp.txt | while read a b c
do
echo $a
echo $b 
echo $c
sqlplus  $db_user/$db_pwd@$db_sid  $a $b $c <<EOF

SET HEADING OFF
SET SERVEROUTPUT ON
SET FEEDBACK OFF
DECLARE
CNT  NUMBER(5);
DROPCNT NUMBER(5);
ERRORCNT NUMBER(5);
BEGIN
SELECT COUNT(*) INTO CNT FROM USAGE_INTRNL_ERROR WHERE AUDIT_GROUP_ID='&1';

IF ( CNT != &3) THEN
  SELECT INTRL_DROP_QTY,INTRL_ERROR_QTY INTO DROPCNT,ERRORCNT 
     FROM USAGE_AUDIT_GROUP WHERE AUDIT_GROUP_NBR='&1'; 

     DROPCNT :=DROPCNT-CNT;

     UPDATE USAGE_AUDIT_GROUP 
      SET INTRL_DROP_QTY='DROPCNT' ,INTRL_ERROR_QTY='CNT'  
      WHERE  AUDIT_GROUP_NBR='&1' ;
COMMIT;

END IF;
END;
EXIT;
EOF
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Getting Rid of Annoying Bootstrap Table Borders and Wayward Table Lines

Bootstrap is great; but we have had some issues with Bootstrapped <tables> (and legacy <fieldset> elements) showing annoying, wayward lines. I solved that problem today with this simple jQuery in the footer: <script> $(function(){ $('tr, td, fieldset,... (0 Replies)
Discussion started by: Neo
0 Replies

2. Shell Programming and Scripting

Run the Script from any stage by updating data from Oracle Table.

I have 100 Scripts, each containing 10-15 SQL's in them. Each Script run for 40 mins to 1 hour 30 mins. In the event of Failure in any step, if i re-start the Script, it will start running from the beginning. Which is waste of time. So in order handle this, i made the script to run from the... (7 Replies)
Discussion started by: kiran1992
7 Replies

3. Shell Programming and Scripting

Build a table from a list by comparing existing table entries

I am new to this shell scripting.... I have a file which contains list of users. This files get updated when new user comes into the system. I want to create script which will give a table containing unique list of users. When I say unique, it means script should match table while parsing... (3 Replies)
Discussion started by: dchavan1901
3 Replies

4. UNIX for Dummies Questions & Answers

Creating a condensed table from a pre-existing table in putty

Hello, I'm working with putty on Windows 7 professional and I'd like to know if there's a way to gather specific lines from a pre-existing table and make a new table with that information. More specifically, I'd like the program to look at a specific column, say column N, and see if any of the... (5 Replies)
Discussion started by: Deedee393
5 Replies

5. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

6. Shell Programming and Scripting

updating a column in a unix table for a particular row

Hi, I have the following requirement. I have a unix table as below progname par1 par2 par3 par4 PROG1 abc def 0012 ooo PROG2 wed xas 0100 xxx PROG3 kkk ppp 0004 ppp Different programs(ex:PROG1,PROG2..) accesses this table and update... (5 Replies)
Discussion started by: thanuman
5 Replies

7. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

8. Shell Programming and Scripting

script for updating table using file(

Hi, Data file path (.txt) Control file(.ctl) I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me... (1 Reply)
Discussion started by: unihp1
1 Replies

9. UNIX for Dummies Questions & Answers

Updating table on UNIX server using SFTP

Hi, I have a requirement where in I have to connect to an Unix database server using SFTP. After connecting I have to write some data to one of the tables in UNIX. Can anyone tell me the UNIX commands to open and update database table. Thanks, Pallavi (1 Reply)
Discussion started by: Pallavi_gondkar
1 Replies

10. Shell Programming and Scripting

updating a column in oracle table using shell script

Hi friends, i am having a variable declared in .profile.i am changing its value in a shell script and then i am connecting to oracle and then from there i am calling a .sql called update.sql STATUS is the variable declared in the .profile =============================== if sqlplus <<END... (3 Replies)
Discussion started by: sveera
3 Replies
Login or Register to Ask a Question