tags:

views:

23

answers:

1

INFORMIX-SQL 7.3 Perform Screens:

According to documentation, in an "after editadd editupdate of table" control block, its instructions are executed before the row is added or updated to the table, whereas in an "after add update of table" control block, its instructions are executed after the row has been added or updated to the table. Supposedly, this would mean that any instructions which would alter values of field-tags linked to table.columns would not be committed to the table, but field-tags linked to displayonly fields will change?

However, when using "after add update of table", I placed instructions which alter values for field-tags linked to table.columns and their displayed and committed values also changed! I would have thought that an "after add update of table" would only alter displayonly fields.


TABLES
    customer
    transaction
    branch
    interest
    dates

ATTRIBUTES
[...]
q  = transaction.trx_type, INCLUDE=("E","C","V","P","T"), ...;
tb = transaction.trx_int_table,     
     LOOKUP f1   = ta_days1_f,
            t1   = ta_days1_t,
            i1   = ta_int1,
            [...]
      JOINING *interest.int_table, ...;
[...]

INSTRUCTIONS

customer MASTER OF transaction
transaction MASTER OF customer
delimiters ". ";

AFTER QUERY DISPLAY ADD UPDATE OF transaction 

    if z = "E" then let q = "E"
    if z = "C" then let q = "C" 
    if z = "1" then let q = "E"

[...]
END
+2  A: 
  • Is 'z' a column in the transaction table?
  • Is the trouble that the value in 'z' is causing a change in the value of 'q' (aka transaction.trx_type), and the modified value is being stored in the database?
  • Is the value in 'z' part of the transaction table?
  • Have you verified that the value in the DB is indeed changed - using the Query Language option or a simple (default) form?

It might look as if it is because the instruction is also used AFTER DISPLAY, so when the values are retrieved from the DB, the value displayed in 'q' would be the mapped values corresponding to the value stored in 'z'. You would have to inspect the raw data to hide that mapping.

If this is not the problem, please:

  1. Amend the question to show where 'z' comes from.
  2. Also describe exactly what you do and see.
  3. Confirm that the data in the database, as opposed to on the screen, is amended.

Please can you see whether this table plus form behaves the same for you as it does for me?

Table Transaction

CREATE TABLE TRANSACTION
(
    trx_id        SERIAL  NOT NULL,
    trx_type      CHAR(1) NOT NULL,
    trx_last_type CHAR(1) NOT NULL,
    trx_int_table INTEGER NOT NULL
);

Form

DATABASE stores
SCREEN SIZE 24 BY 80
{
trx_id              [f000]
trx_type            [q]
trx_last_type       [z]
trx_int_table       [f001       ]
}
END
TABLES
    transaction
ATTRIBUTES
f000 = transaction.trx_id;
q    = transaction.trx_type,      UPSHIFT, AUTONEXT,
                                  INCLUDE=("E","C","V","P","T");
z    = transaction.trx_last_type, UPSHIFT, AUTONEXT,
                                  INCLUDE=("E","C","V","P","T","1");
f001 = transaction.trx_int_table;

INSTRUCTIONS
AFTER ADD UPDATE DISPLAY QUERY OF transaction
    IF z = "E" THEN LET q = "E"
    IF z = "C" THEN LET q = "C" 
    IF z = "1" THEN LET q = "E"
END

Experiments

[The parenthesized number is automatically generated by IDS/Perform.]

  • Add a row with data (1), V, E, 23.
  • Observe that the display is: 1, E, E, 23.
  • Exit the form.
  • Observe that the data in the table is: 1, V, E, 23.
  • Reenter the form and query the data.
  • Update the data to: (1), T, T, 37.
  • Observe that the display is: 1, T, T, 37.
  • Exit the form.
  • Observe that the data in the table is: 1, T, T, 37.
  • Reenter the form and query the data.
  • Update the data to: (1), P, 1, 49
  • Observe that the display is: 1, E, 1, 49.
  • Exit the form.
  • Observe that the data in the table is: 1, P, 1, 49.
  • Reenter the form and query the data.
  • Observe that the display is: 1, E, 1, 49.
  • Choose 'Update', and observe that the display changes to: 1, P, 1, 49.

I did the 'Observe that the data in the table is' steps using:

sqlcmd -d stores -e 'select * from transaction'

This generated lines like these (reflecting different runs):

1|V|E|23
1|P|1|49

That is my SQLCMD program, not Microsoft's upstart of the same name. You can do more or less the same thing with DB-Access, except it is noisier (13 extraneous lines of output) and you would be best off writing the SELECT statement in a file and providing that as an argument:

$ echo "select * from transaction" > check.sql
$ dbaccess stores check

Database selected.



     trx_id trx_type trx_last_type trx_int_table 

          1 P        1                        49

1 row(s) retrieved.


Database closed.

$

Conclusions

This is what I observed on Solaris 10 (SPARC) using ISQL 7.50.FC1; it matches what the manual describes, and is also what I suggested in the original part of the answer might be the trouble - what you see on the form is not what is in the database (because of the INSTRUCTIONS section).

Do you see something different? If so, then there could be a bug in ISQL that has been fixed since. Technically, ISQL 7.30 is out of support, I believe. Can you upgrade to a more recent version than that? (I'm not sure whether 7.32 is still supported, but you should really upgrade to 7.50; the current release is 7.50.FC4.)


Transcribing commentary before deleting it:

Up to a point, it is good that you replicate my results. The bad news is that in the bigger form we have different behaviour. I hope that ISQL validates all limits - things like number of columns etc. However, there is a chance that they are not properly validated, given the bug, or maybe there is a separate problem that only shows with the larger form. So, you need to ensure you have a supported version of the product and that the problem reproduces in it. Ideally, you will have a smaller version of the table (or, at least, of the form) that shows the problem, and maybe a still smaller (but not quite as small as my example) version that shows the absence of the problem.

With the test case (table schema and Perform screen that shows the problem) in hand, you can then go to IBM Tech Support with "Look - this works correctly when the form is small; and look, it works incorrectly when the form is large". The bug should then be trackable. You will need to include instructions on how to reproduce the bug similar to those I gave you. And there is no problem with running two forms - one simple and one more complex and displaying the bug - in parallel to show how the data is stored vs displayed. You could describe the steps in terms of 'Form A' and 'Form B', with Form A being Absolutely OK and Form B being Believed to be Buggy. So, add a record with certain values in Form B; show what is displayed in Form B after; show what is stored in the database in Form A after too; show that they are not different when they should be.

Please bear in mind that those who will be fixing the issue have less experience with the product than either you or me - so keep it as simple as possible. Remove as many attributes as you can; leave comments to identify data types etc.

Jonathan Leffler
@Jonathan - z = transaction.trx_last_type [char(1)]. Depending on z's value, it can change q's value. There's no other place in the instructions where I'm telling z to change q, only in AFTER ADD UPDATE DISPLAY.. Yes, I have a default (generated) form for transactions which I regulary use to verify stored values and Yes, 'z' is being altered and stored, according to my IF statements in after add update display.
Frank Computer
@Jonathan - This is a Pawnshop application where merchandise can be initially pawned and interest payments made by customer, who could opt to convert pawn by selling it to pawnshop, which in turn could later sell it to another customer = tran type started out as type 'L'(Loan), converted to a 'P'(Purchase), converted to an 'I'(Inventory), then to converted to an 'S'(Sale), Depending on the tran type, I'm re-using the same columns for different things, whenever possible, example: for Loans, transaction.main_amount is used for the Principal; for Purchase, Purchase Price; for Sale, Sale Price.
Frank Computer
@Jonathan-Although my ISQL app is entirely in Spanish, you can view a video-demo of the app by visiting www.frankcomputer.com so you can get a more or less feel. The video-demo version is the current version where Loan, Purchase and Sale tables are separate. I'm trying to merge all these types of transactions into one table, thus added the tran type column and re-using as many columns possible so that one screen handles it all plus making it easier to morph from one tran type to another. Whenver a new tran is performed, the tran number (boleto) is incremented and a ticket printed.
Frank Computer
@Jonathan- OK, I created your test table, form and ran the experiment, obtaining your same results! I generated a default form instead of using your SQLCMD to view the stored values, but I think this test is a lot simpler than the actual .per that I'm having trouble with. It's a form (180k) which does so many things, I have carefully checked to see if I had conflicting before and after blocks on columns, but couldn't find any. Soemtimes I get strange results when I have too many table lookup labels. The transaction table schema has over 170 columns!
Frank Computer