Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alphabetical Order.

Status
Not open for further replies.

Slackerksg5

Programmer
Feb 5, 2008
4
US
My problem is retrieving data from a sql table called "section". The portion that I want is s_name(Section Name), but I am attempting to grab them one at a time using an increment of which ever page I am on.

So my attempt at doing this is as follows...

SELECT s_name INTO :inspectionName FROM section WHERE s_id = :index ORDER BY s_name USING sqlca;

index is the page I am on and the row I need to grab, but obviously this doesn't work, because it gives me the name for whichever index I am at. Therefore if I had a,c,b,d,g,f,e in the database that would be the way in which I retrieved it even though what I was looking for was a,b,c,d,e,f,g any help is appreciated. Thanks in advance.

Oh I also attempted to use that above query and load the values into an array, but was unable to sort the array... Maybe I simply over looked something.
 
Have you tried to sort the data in the datawindow rather than the SQL?

Matt

"Nature forges everything on the anvil of time
 
Actually I have, and I can't seem to do it alphabetically. Here is my code maybe I am doing something fine, but it does work for Numerical values which would have been nice to know when I was garbing ID's rather than names =/.

And actually I did a datastore, which you should know is practically a datawindow that isn't drawn on the painter.

datastore lds_temp
string ls_err

string ll_array[] = { "A","B","C" }
string ls_dsdef = &
'release 6; datawindow() table(column=(type=varchar name=a dbname="a") )'

lds_temp = CREATE datastore
lds_temp.Create(ls_dsdef, ls_err)
lds_temp.object.a.current = ll_array
lds_temp.SetSort("a ASC")
lds_temp.Sort()
ll_array = lds_temp.object.a.current

FOR i = 1 to Upperbound(ll_array)
MessageBox("", string(ll_array))
NEXT

DESTROY lds_temp
 
As far as I can see in your code

SELECT s_name INTO :inspectionName FROM section WHERE s_id = :index ORDER BY s_name USING sqlca;

this will retrieve only one row.

create a datawindow with the following retrieve:

select "s_name" from "section" where "s_id" = :arg1 order by "s_name"

use the datawindow painter in Ide to create the datawindow. it is the easiest way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top