tables. manipulation and display..

tables. manipulation and display..

Post by Tonis Kasva » Thu, 10 Nov 1994 00:47:37



   Hello,
    I'm using 4GL/SQL and have limited references in table fields.

    Is there an efficient way to:
display table information in a table field and manipulate the rows?
    Here is a small example of what I have...

     check_out.serve_table := repeated select srvctypes.s.srvctypes ,
                 cost=s.cost, srvccode=s.srvccode
                from services s, transactions t
             where t.roomno=:roomno and t.srvccode=s.srvccode;

inquire_ingres (row_count = rowcount);
scroll serve_table to 0;     /* scroll to row 0 */
s.cost = :total * days ;
full_total = :s.cost + past_cost ;

       check_out    -   .osq frame/form used  
       serve_table  -   table field
       srvctypes, cost, srvccode      - column fields in serve_table
       total   -   a field in check_out   ( i4 )
       days,past_cost    -   variables i4 in check_out.osq

   The problem is I cannot seem to circulate through the rows to obtain
information on each row.  Is there a simple procedure to hop around the
rows in my table field serve_table?
   I tried to scroll through the rows using    scroll serve_table to nn;
  (where nn is a row number between 1 and row_count). I contiually
received errors like 'Cursor must be on a specific row of table field
'serve_table'  ' .  In my form, I want the table to be 'Display Only'
for each of the columns.  Are these two conditions related to my error?
  I also have to go through 3 repetitions of this error.
    Does the table field include the column names and box lines as a row
number?

   Does anyone has a better suggestion to scroll, display, and manipulate
table field information (but not write to tables) ?

Thanks in Advance.

Tonis

--

BOX 5201                    Fax: (613) 226-3230  
Ottawa, Ont.                /-----------------------------------------\
CANADA    K2C 3H5          [  Seeing the future through chaos theory...]

 
 
 

tables. manipulation and display..

Post by David Tondre » Wed, 09 Nov 1994 19:52:35



Quote:nd) writes:
>   Hello,
>    I'm using 4GL/SQL and have limited references in table fields.

>    Is there an efficient way to:
>display table information in a table field and manipulate the rows?
>    Here is a small example of what I have...

>     check_out.serve_table := repeated select srvctypes.s.srvctypes ,
>                 cost=s.cost, srvccode=s.srvccode
>                from services s, transactions t
>             where t.roomno=:roomno and t.srvccode=s.srvccode;

>inquire_ingres (row_count = rowcount);
>scroll serve_table to 0;     /* scroll to row 0 */
>s.cost = :total * days ;
>full_total = :s.cost + past_cost ;

this simple construct should be what you are looking for:

i = 1;
while (i <= serve_table.LastRow()) do
    serve_table[i].srvctypes = ...
    total = total + serve_table[i].whatever_field...
    any other manipulations....
    i = i + 1;
endwhile;

- Show quoted text -

Quote:

>       check_out    -   .osq frame/form used  
>       serve_table  -   table field
>       srvctypes, cost, srvccode      - column fields in serve_table
>       total   -   a field in check_out   ( i4 )
>       days,past_cost    -   variables i4 in check_out.osq

>   The problem is I cannot seem to circulate through the rows to obtain
>information on each row.  Is there a simple procedure to hop around the
>rows in my table field serve_table?
>   I tried to scroll through the rows using    scroll serve_table to nn;
>  (where nn is a row number between 1 and row_count). I contiually
>received errors like 'Cursor must be on a specific row of table field
>'serve_table'  ' .  In my form, I want the table to be 'Display Only'
>for each of the columns.  Are these two conditions related to my error?
>  I also have to go through 3 repetitions of this error.

using the constructs you did you are telling 4GL to process the 'current'
row on there is none if the user is not currently sitting on some field in
the table.

Quote:>    Does the table field include the column names and box lines as a row
>number?

No, but they are elements of the class structure.

Quote:

>   Does anyone has a better suggestion to scroll, display, and manipulate
>table field information (but not write to tables) ?

>Thanks in Advance.

>Tonis

Not to be rude, Tonis, but I think its time to go back to the manual.
Much (all) of what you covered is in there.

Regards,

David



LCT, Inc.              |         (202) 554-0115          | The first time.

 
 
 

tables. manipulation and display..

Post by Karl Schend » Fri, 11 Nov 1994 16:11:02


Quote:uunet!MATH.AMS.ORG!alpha06!ug930111 writes:
> ....
> ....
>    The problem is I cannot seem to circulate through the rows to obtain
> information on each row.  Is there a simple procedure to hop around the
> rows in my table field serve_table?
> ....
> ....

You have two basic choices: UNLOADTABLE and a WHILE / SCROLL TO loop.

UNLOADTABLE table_name
BEGIN
    table_name.cost = ...
    total = table_name.cost + ....
    ....
END;

Or,

INQUIRE_FORMS TABLE '' (i = DATAROWS(table_name));
WHILE i >= 1 DO
    SCROLL table_name TO i;
    table_name.cost = ....
    ....
    i = i - 1;
END;

You may also need tests on table_name._STATE to make sure you aren't
working with undefined rows.  (RTFM to learn about tablefield row states).

UNLOADTABLE is easier, but you can't nest them, and there are various
bugs and misfeatures associated with calling local procedures inside
UNLOADTABLE contexts.

By the way, uunet!nhqvax.hq.nasa.gov!ars_mgr suggests:

Quote:> this simple construct should be what you are looking for:

> i = 1;
> while (i <= serve_table.LastRow()) do
>     serve_table[i].srvctypes = ...
>     total = total + serve_table[i].whatever_field...
>     any other manipulations....
>     i = i + 1;
> endwhile;

The above may be correct in W4GL (which I don't know, yet), but it's wrong
in ABF/4GL.  Remember the following mantra:

        tablefield[i] refers to the DISPLAY
        UNLOADTABLE/SCROLL TO refers to the DATASET

You can't access tablefield dataset rows with indexing.  This is the
most common tablefield mistake I've seen.  You can only access displayed
rows with indexing.  To get at the entire dataset, you must either SCROLL TO
or UNLOADTABLE.  It's a real plausible mistake, and it often seems to
work at first - until your tablefield dataset gets longer than the displayed
tablefield.

One other tip: you don't need colons (eg, total = :tablefield.cost) nearly
as often as I see them in many 4gl examples.  I suggest you only use the
colon when you need it: inside SQL and when using a variable as a 4gl-name.
total = cost works just as well as total = :cost.

Karl Schendel
Telesis Computer Corp

 
 
 

tables. manipulation and display..

Post by David Tondre » Fri, 11 Nov 1994 12:21:26



writes:

Quote:>uunet!MATH.AMS.ORG!alpha06!ug930111 writes:

>By the way, uunet!nhqvax.hq.nasa.gov!ars_mgr suggests:

>> this simple construct should be what you are looking for:

>> i = 1;
>> while (i <= serve_table.LastRow()) do
>>     serve_table[i].srvctypes = ...
>>     total = total + serve_table[i].whatever_field...
>>     any other manipulations....
>>     i = i + 1;
>> endwhile;

>The above may be correct in W4GL (which I don't know, yet), but it's wrong
>in ABF/4GL.  

I did assume the poster was asking about Windows4GL which is indeed the
solution my post was aimed at.  Funny, I never really though of OSL as

Regards



LCT, Inc.              |         (202) 554-0115          | The first time.

 
 
 

1. Help with Table Manipulation

I have a fairly simple task for drawing up a graph I need to have my
query
display 3 columns ReportDate, PDL, PDLAverage.
Here is the table data.
ReportDate                            PDL
--------------------------- -----------
2001-01-01 00:00:00.000     308
2001-01-02 00:00:00.000     350
2001-01-03 00:00:00.000     214
2001-01-04 00:00:00.000     259
2001-01-05 00:00:00.000     272

Now assuming the average over those 5 days is 311 here is what my output
should look like
Here's what I wold like it to look like
ReportDate                            PDL        Average
--------------------------- ----------- -----------
2001-01-01 00:00:00.000     308         311
2001-01-02 00:00:00.000     250         311
2001-01-03 00:00:00.000     214         311
2001-01-04 00:00:00.000     259         311
2001-01-05 00:00:00.000     272         311

Thanks in advance.
Pete J.

2. Recordsets?

3. help on table manipulation

4. svrmgrl ORA-12154: TNS:could not resolve service name

5. SQL 6.5 table manipulation

6. Pick Programmer Needed - Canton Ohio

7. Table Manipulation

8. Time fields on crystal report?

9. Row Manipulation in a ODBC linked to MS Access Table

10. Table Manipulation

11. TABLE manipulation

12. Paradox4.5 Table manipulation

13. Manipulation of tables