I have troubling issue where I want to only select the first 2 chunks of every dbspace created.
query used:
SELECT
a.dbsnum,
b.chknum,
a.name,
b.fname
FROM
sysdbspaces a, syschunks b where a.dbsnum = b.dbsnum
GROUP BY
1,2,3,4
ORDER BY 1,2
Output:
dbsnum 1
chknum 1
name rootdbs
fname /dev/informix/rootdbs01
dbsnum 1
chknum 344
name rootdbs
fname /dev/informix/chunk1081
dbsnum 1
chknum 965
name rootdbs
fname /dev/informix/chunk1280
dbsnum 1
chknum 1099
name rootdbs
fname /dev/informix/chunk1281
What I want is:
dbsnum 1
chknum 1
name rootdbs
fname /dev/informix/rootdbs01
dbsnum 1
chknum 344
name rootdbs
fname /dev/informix/chunk1081
I am trying to put logic together to select the first 2 chunks created for example from each dbspace that exists. rootdbs has a total of 4 chunks I only want the first 2.
I can achieve this using a korn shell script:
for i in
echo "output to pipe cat without headings select unique(dbsnum) from sysdbspaces" | dbaccess sysmaster 2> /dev/null | sed '/^$/d'
do
fname=`echo "output to pipe cat without headings select a.fname from (select
first 2
a.dbsnum,
b.chknum,
a.name,
b.fname
FROM
sysdbspaces a, syschunks b where a.dbsnum = b.dbsnum
AND a.dbsnum = '$i'
--AND a.is_temp = 1
GROUP BY
1,2,3,4
ORDER BY 1,2) a" | dbaccess sysmaster 2> /dev/null | sed '/^$/d'`
echo "$fname"
done
Asked by Christopher Karsten
(319 rep)
Feb 9, 2021, 07:36 AM
Last activity: Aug 3, 2022, 08:52 PM
Last activity: Aug 3, 2022, 08:52 PM