Hi,
I have a table in Db2 with data say
id_1 phase1
id_1 phase2
id_1 phase3
id_2 phase1
id_2 phase2
I need to concatenate the values like
id_1 phase1,phase2,phase3
id_2 phase1,phase2
I tried recursive query but in vain as the length of string to be concatenated in quite long. ... (17 Replies)
hi,
I have a requirement where in I read the values from a file using awk. The resulting data should be converted into row format from column format.
For ex: My log file login.lst contains the following
SERVER1 DB1
SERVER2 DB2
SERVER3 DB3
SERVER4 DB4
I use awk to grep only the server... (6 Replies)
Hi All,
I needd to convert values in a row to a column.
eg: Input is as: value1,value2,value3,value4,.........,value N
Required Output:
Value1
Value2
Value3
.
.
.
Value N
Please help.... (3 Replies)
I have file which as 12 columns and values like this
1,2,3,4,5
a,b,c,d,e
b,c,a,e,f
a,b,e,a,h
if you see the first column has duplicate values, I need to identify (print it to console) the duplicate value (which is 'a') and also remove duplicate values like below. I could be in two... (5 Replies)
Hello,
I have a very large file for which I would like to remove all rows for which the value of columns 2-5 is zero.
For instance I would like this file:
contig1, 0, 0, 0, 0
contig2, 1, 3, 5, 0
contig3, 0, 0, 0, 0
contig4, 0, 5, 6, 7
To become this file:
contig2, 1, 3, 5,0 ... (17 Replies)
Hello guys.
Please can you help me with this.. Thanks in advance:b:
Input file
2134 6371 N
2150 6371 M
2166 6371 S
2138 6417 N
2154 6417 M
2170 6417 S
2157 6603 N
2173 6603 M
2189 6603 S
desired uotput
6371 2134N 2150M 2166S
6417 2138N 2154M 2170S... (2 Replies)
Hi ,
I have been trying to write a awk script which will have the following Output
1. Append the last Characters of the lines matching pattern xxxxxxxxx & then a space & then Append the last Characters of the lines matching pattern yyyyyyyyy
2. the process will continue till end of file &... (10 Replies)
Hi would like to ask you guys any advise regarding my problem
I have this kind of data
file.txt
111111111,20
111111111,50
222222222,70
333333333,40
444444444,10
444444444,20
I need to get this
file1.txt
111111111,70
222222222,70
333333333,40
444444444,30
using this code I can... (6 Replies)
Dear Folks
Hello
I have a column of numbers, say:
26
79
68
I want to add one to each row value and get this desire column:
26
27
79
80
68
69 (6 Replies)
Discussion started by: sajmar
6 Replies
LEARN ABOUT PHP
db2_fetch_array
DB2_FETCH_ARRAY(3) 1 DB2_FETCH_ARRAY(3)db2_fetch_array - Returns an array, indexed by column position, representing a row in a result setSYNOPSIS
array db2_fetch_array (resource $stmt, [int $row_number = -1])
DESCRIPTION
Returns an array, indexed by column position, representing a row in a result set. The columns are 0-indexed.
PARAMETERS
o $stmt
- A valid stmt resource containing a result set.
o $row_number
- Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a
forward-only cursor.
RETURN VALUES
Returns a 0-indexed array with column values indexed by the column position representing the next or requested row in the result set.
Returns FALSE if there are no rows left in the result set, or if the row requested by $row_number does not exist in the result set.
EXAMPLES
Example #1
Iterating through a forward-only cursor
If you call db2_fetch_array(3) without a specific row number, it automatically retrieves the next row in the result set.
<?php
$sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed";
$stmt = db2_prepare($conn, $sql);
$result = db2_execute($stmt);
while ($row = db2_fetch_array($stmt)) {
printf ("%-5d %-16s %-32s %10s
",
$row[0], $row[1], $row[2], $row[3]);
}
?>
The above example will output:
0 Pook cat 3.20
5 Rickety Ride goat 9.70
2 Smarty horse 350.00
Example #2
Retrieving specific rows with db2_fetch_array(3) from a scrollable cursor
If your result set uses a scrollable cursor, you can call db2_fetch_array(3) with a specific row number. The following example
retrieves every other row in the result set, starting with the second row.
<?php
$sql = "SELECT id, name, breed, weight FROM animals ORDER BY breed";
$result = db2_exec($stmt, $sql, array('cursor' => DB2_SCROLLABLE));
$i=2;
while ($row = db2_fetch_array($result, $i)) {
printf ("%-5d %-16s %-32s %10s
",
$row[0], $row[1], $row[2], $row[3]);
$i = $i + 2;
}
?>
The above example will output:
0 Pook cat 3.20
5 Rickety Ride goat 9.70
2 Smarty horse 350.00
SEE ALSO db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_object(3), db2_fetch_row(3), db2_result(3).
PHP Documentation Group DB2_FETCH_ARRAY(3)