error while updating rows in sql with values in array variable
Hi,
I need to update rows in a table based on the values in an array variable.
code is :
Code:
while read line
do
error_msg[$index]="$(echo $line)"
index=`expr $index+1`
done <"logs/$ffile"
rows_count=${#error_msg[*]}
i=0
while [ $i -lt $rows_count ]
do
echo "error msgs is ${error_msg[i]}"
err_msg=`echo ${error_msg[i]}`
i=`expr $i + 1`
rec_num=`echo ${error_msg[i]}| cut -d: -f2`
echo "record number - $rec_num"
oput=`sqlplus -s mig/mig@dev01<<END
set linesize 200
set pagesize 200
SET NEWPAGE 0
SET SPACE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
set termout off
WHENEVER SQLERROR EXIT 1;
update mass_upload set error_msg = '$err_msg' ,status_flag = 'ER' where srl_num = to_number($rec_num);
commit;
exit;
END`
i=`expr $i + 1`
echo "${error_msg[i]}"
i=`expr $i + 1`
done
In the above code, SQL connection is made for every update. is there any way to update all the rows in one sql connection instead of opening it multiple times?
kindly please help.
Last edited by Franklin52; 07-24-2012 at 08:32 AM..
Reason: Please use code tags for data and code samples, thank you
i have these values inside variable $blah
BUNGA TERATAI 3 5055 ITH 1 0 0 0 1 1
JADE TRADER 143W ITH 4 0 0 0 4 4
MOL SPLENDOR 0307A ITH 3 0 0 0 3 3
so how do I split them into array with the... (4 Replies)
hi folks
i am facing problom while trying to access sql variable as array index ina unix shell script....script goes as below..
#!/bin/ksh
MAX=3
for elem in alpha beeta gaama
do
arr=$elem
((x=x+1))
Done
SQL_SERVER='servername'
/apps/sun5/utils/sqsh -S $SQL_SERVER -U user -P pwd -b -h... (1 Reply)
I have a array as
CArray=( a1 a2 )
and a1,a2,a3 are also array as:
a1=(1 2 3)
a2=(3 4 5)
now I have this in my code:
for i in `echo "${CArray}"`
do
echo ${$i}
done
It is giving error as :"bad substitution"
It should give me value as
1 2 3
3 4 5
how can I get this...Can u please... (2 Replies)
Dear All,
I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with:
#! /bin/bash
ch=`cut -f10 tmp.txt`
counter=0
for p in $pid
do
c=${ch}
echo "$c ..$counter"
counter=$((counter+1))... (2 Replies)
Am using a find command in my script .The output may be one or more. I need to store those values in a array and need to access those. Am unable to find the solution . Any help on this will be helpful.
if
< code>
else a=<find command output which gives the file name either 1 or more>
if 1... (1 Reply)
I am new to ksh scripting, specially array. How do i get values from an array and set the value as variable and pass those variables to the different functions??
someone taught me how to get input from a file with have columns i need to read, but now i doesnt know how to set those value to be a... (7 Replies)
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
Hi All,
Need a help. I am just learning Shell scripting. Need a requirement like to attach variable to array values. Value of from is AF and to is AD.
froml=$(echo $from | tr '' '')
tol=$(echo $to | tr '' '')
Schemas=(AWQM WFCONTROLLER PROVCO PRISM)
for s in "${Schemas}"
do
... (3 Replies)
Hi,
I'm trying to asign to ksh varible some values of a sql query. The output query would be:
xxxx 1
yyyy 2
I do:
values=`$PATH_UTI/query_sh "
select think1||'------'||think2 from some_table
where think3 = '$1';
... (2 Replies)
Discussion started by: mierdatuti
2 Replies
LEARN ABOUT PHP
db2_statistics
DB2_STATISTICS(3) 1 DB2_STATISTICS(3)db2_statistics - Returns a result set listing the index and statistics for a tableSYNOPSIS
resource db2_statistics (resource $connection, string $qualifier, string $schema, string $table-name, bool $unique)
DESCRIPTION
Returns a result set listing the index and statistics for a table.
PARAMETERS
o $connection
- A valid connection to an IBM DB2, Cloudscape, or Apache Derby database.
o $qualifier
- A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string.
o $schema
- The schema that contains the targeted table. If this parameter is NULL, the statistics and indexes are returned for the schema
of the current user.
o $table_name
- The name of the table.
o $unique
- An integer value representing the type of index information to return.
o $0
- Return only the information for unique indexes on the table.
o $1
- Return the information for all indexes on the table.
RETURN VALUES
Returns a statement resource with a result set containing rows describing the statistics and indexes for the base tables matching the
specified parameters. The rows are composed of the following columns:
+--------------+---------------------------------------------------+
| Column name | |
| | |
| | Description |
| | |
+--------------+---------------------------------------------------+
| TABLE_CAT | |
| | |
| | The catalog that contains the table. The value is |
| | NULL if this table does not have catalogs. |
| | |
| TABLE_SCHEM | |
| | |
| | Name of the schema that contains the table. |
| | |
| TABLE_NAME | |
| | |
| | Name of the table. |
| | |
| NON_UNIQUE | |
| | |
| | An integer value representing whether the index |
| | prohibits unique values, or whether the row rep- |
| | resents statistics on the table itself: |
| | |
| | box, tab (|); c | c | . T{ Return value |
| | |
| | Parameter type |
| | |
+--------------+---------------------------------------------------+
|0 (SQL_FALSE) | |
| | |
| | The index allows duplicate values. |
| | |
|1 (SQL_TRUE) | |
| | |
| | The index values must be unique. |
| | |
| | |
| NULL | |
| | |
| | This row is statistics information for the table |
| | itself. |
| | |
+--------------+---------------------------------------------------+
T} T{ INDEX_QUALIFIER
T} |T{ A string value representing the qualifier that would have to be prepended to INDEX_NAME to fully qualify the index.
T} T{ INDEX_NAME
T} |T{ A string representing the name of the index.
T} T{ TYPE
T} |T{
An integer value representing the type of information contained in this row of the result set:
+------------------------+---------------------------------------------------+
| Return value | |
| | |
| | Parameter type |
| | |
+------------------------+---------------------------------------------------+
| 0 (SQL_TABLE_STAT) | |
| | |
| | The row contains statistics about the table |
| | itself. |
| | |
|1 (SQL_INDEX_CLUSTERED) | |
| | |
| | The row contains information about a clustered |
| | index. |
| | |
| 2 (SQL_INDEX_HASH) | |
| | |
| | The row contains information about a hashed |
| | index. |
| | |
| 3 (SQL_INDEX_OTHER) | |
| | |
| | The row contains information about a type of |
| | index that is neither clustered nor hashed. |
| | |
+------------------------+---------------------------------------------------+
T} T{ ORDINAL_POSITION
T} |T{ The 1-indexed position of the column in the index. NULL if the row contains statistics information about the table itself.
T} T{ COLUMN_NAME
T} |T{ The name of the column in the index. NULL if the row contains statistics information about the table itself.
T} T{ ASC_OR_DESC
T} |T{
A if the column is sorted in ascending order, D if the column is sorted in descending order, NULL if the row contains statistics informa-
tion about the table itself.
T} T{ CARDINALITY
T} |T{
If the row contains information about an index, this column contains an integer value representing the number of unique values in the
index. If the row contains information about the table itself, this column contains an integer value representing the number of rows in
the table.
T} T{ PAGES
T} |T{
If the row contains information about an index, this column contains an integer value representing the number of pages used to store the
index. If the row contains information about the table itself, this column contains an integer value representing the number of pages used
to store the table.
T} T{ FILTER_CONDITION
T} |T{ Always returns NULL.
T}
SEE ALSO db2_column_privileges(3), db2_columns(3), db2_foreign_keys(3), db2_primary_keys(3), db2_procedure_columns(3), db2_procedures(3), db2_spe-
cial_columns(3), db2_table_privileges(3), db2_tables(3).
PHP Documentation Group DB2_STATISTICS(3)