473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Filling ksh array with db2 returns..

I'm trying to fill an array in korn shell with entries from a db2
query. I've tried a straight `set -A <array_name>=`db2 -x <query>`` ,
but that doesn't work.

Can this sort of thing be done?

TIA,
Chris

Nov 12 '05 #1
2 2384
You could do several things short of an array. For example:

for x in $( db2 -x "select...")
do
yada yada yada
done

or

db2 -x "select x, y, z from ..." | read x y z
do
yada yada yada
done
But the problem with ksh arrays I've worked with is knowing how many
elements you'll have so I guess you could do something like this. (
forgive me because I syntax may be off because I'm using windows right
now and don't have access to ksh )

counter=1
for x in $(db2 -x "select y from...")
do
arr[${counter}]=$x
counter=$(($counter+1))
done

The problem with this approach would be only being able to select one
column with the query.

HTH

Nov 12 '05 #2
> The problem with this approach would be only being able to select one
column with the query.

Yeah, with multiple columns it can get easier to export to a delimited
file and read it back in and parse. Alternatively, the inclusion of
literal columns like '|' in the output can help facilitate parsing.

And at this point running from within python/ruby/perl - where you can
more easily capture the output to an easily-manipulated array can help
as well.

ken

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: SilverWolf | last post by:
I need some help with sorting and shuffling array of strings. I can't seem to get qsort working, and I don't even know how to start to shuffle the array. Here is what I have for now: #include...
8
by: Tweaxor | last post by:
Hey, I was trying to figure out was it possible in C to pass the values in an array from one function to another function. Is the possible in C? ex. y is the array that holds seven values If...
1
by: rkmoray | last post by:
I have created a Multi Dimentional array, but having problems filling it. int mCount=0; mCount=ds.Tables.Rows.Count; string arrayppsa = new string ; DataTable myDataTable=ds.Tables;...
3
by: MSDousti | last post by:
Hello I want to write a C# (or VB.NET) program which reads the structure of a PE (odinary win32 executable) file. These files have a long header (512 bytes or so). The definition of the header...
12
by: pjhyett | last post by:
standard 2d array filling with increasing numbers for rows and columns: for(int i=0;i<n;i++) for(int j=0;j<n;j++) a = i + j; problem is it's O(n^2). I'm looking for a method to decrease the...
2
by: drdave | last post by:
Hi All, I'm filling an arraylist with other arraylists within a loop and within the first iteration and addition all is fine.. however when I clear my value holding temporary array I lose the...
3
by: John Espinosa | last post by:
I am new to C#. I am trying to use a for loop of integers to fill up a String array. Actually, I am trying to get a dropdown list of all the days in the current month. This is what I have been...
1
by: Chuy08 | last post by:
Currently I have the following XML document: <Programs> <Program> <ProductTypeName>30 Yr Fixed</ProductTypeName> <Rate>6.250</Rate> <APR>6.274</APR> <InvestorName>Helos</InvestorName>...
12
by: ab12 | last post by:
I'm trying to write a program in C that gets a shape outlined with asterisks from the user, and returns that shape filled with asterisks. It will also get the coordinates of a point inside the shape...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.