Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Force SQL UPDATE statement before refreshing data.
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Force SQL UPDATE statement before refreshing data.
 Login/Join
 
Gold member
posted
I am having a problem with the following procedure.
What I am trying to do is select records based on an order number and update the order status via SQL UPDATE command. After running the SQL UPDATE which is triggered from a menu drill I am trying to re-display the data with the updated status. The problem I am having is that after the SQL UPDATE I am trying to refresh my HTML table based on the updated data. It appears that the HTML table is based on data before the update. If I close and re-run the procedure then I receive the expected results in the updated table.

Is there a way to force the SQL UPDATE to run before re-selecting the data?

-* report rpt_sql_testing.fex
-DEFAULT &ORDERNO = 1054727;
-DEFAULTH &CONFIRM = 'NO';
-DEFAULTH &STATUS = 28;
-SET &RANDOM = RDUNIF('D12.9') * 1000000;

-IF &CONFIRM EQ 'YES' GOTO UPDATE
- ELSE GOTO SELECT;

-SELECT
ENGINE SQLPSTGR SET DEFAULT_CONNECTION DBTEST
SQL SQLPSTGR PREPARE SQLOUT FOR
SELECT ORDERNO1,PDATE,STOCKID,PARTCODE,SUBADMINID,STATUS FROM TEST.PACKING2 WHERE ORDERNO1 = &ORDERNO;
END

TABLE FILE SQLOUT
PRINT
  orderno1 AS ORDERNO1
  pdate AS PDATE
  stockid AS STOCKID
  partcode AS PARTCODE
  subadminid AS SUBADMINID
  status AS STATUS
ON TABLE HOLD AS HOLDTEMP_SQLOUT FORMAT FOCUS
END

TABLE FILE HOLDTEMP_SQLOUT
PRINT
  ORDERNO1
  PDATE
  STOCKID
  PARTCODE
  SUBADMINID
  STATUS
  COMPUTE CONFIRM_LINK/A100V = 'Click to Update Shipment';
  COMPUTE CONFIRM_VALUE/A3V = 'YES'; NOPRINT
WHERE ORDERNO1 EQ &ORDERNO;
ON TABLE SUBHEAD
""
ON TABLE SET STYLE *
INCLUDE=ENIADefault_combine.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
TYPE=DATA,
     COLUMN=N7,
     DRILLMENUITEM='Confirm Shipment',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='YES' \
     ),
     TARGET='_self',
     DRILLMENUITEM='Refresh Data',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='NO' \
     ),
     TARGET='_self',
$
ENDSTYLE
END
-GOTO EXIT

-UPDATE
ENGINE SQLPSTGR SET DEFAULT_CONNECTION DBTEST_WRITE
SQL SQLPSTGR
UPDATE TEST.PACKING2 SET STATUS = 75 WHERE ORDERNO1 = &ORDERNO AND STATUS = 28;
-*UPDATE TEST.PACKING2 SET STATUS = 28 WHERE ORDERNO1 = &ORDERNO AND STATUS = 75;
SQL COMMIT;
END

-RUN
SLEEP 3

-GOTO SELECT

-EXIT

This message has been edited. Last edited by: FP Mod Chuck,


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
It may be your commit. Maybe it should be coded SQL SQLPSTGR COMMIT;


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 1569 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
Or maybe this (which is essentially the same as what Chuck just suggested):

ENGINE SQLPSTGR COMMIT WORK;
END
-RUN

I found that in this SPS (Symptom/Problem/Solution) that sounded similar in 8009.

Deferred request with SQL passthru fails with COMMIT, but runs when not deferred
https://techsupport.informatio...m/sps/160502041.html

Hope that helps!
Toby
 
Posts: 62 | Registered: October 31, 2006Reply With QuoteReport This Post
Gold member
posted Hide Post
quote:
SQL SQLPSTGR COMMIT;

Thanks for the suggestion but still no change in behavior.

The code is behaving like it is running all the select statements first then running the update last. I can tell the "SLEEP 3" is pausing before receiving the final TABLE FILE PRINT results however it appears that the data is based on the select prior to committing the update.


------------------------------------------
DevStudio 8.2.03
WFS 8.2.03
 
Posts: 86 | Location: Atlanta | Registered: May 10, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
I understand that it will create duplicate code but can you try using the following
Forcing to have a new hold set of data may result the issue. Pay attention that I use another hold file name : HOLDTEMP_SQLOUT2
-* report rpt_sql_testing.fex
-DEFAULT &ORDERNO = 1054727;
-DEFAULTH &CONFIRM = 'NO';
-DEFAULTH &STATUS = 28;
-SET &RANDOM = RDUNIF('D12.9') * 1000000;

-IF &CONFIRM EQ 'YES' GOTO UPDATE
- ELSE GOTO SELECT;

-SELECT
ENGINE SQLPSTGR SET DEFAULT_CONNECTION DBTEST
SQL SQLPSTGR PREPARE SQLOUT FOR
SELECT ORDERNO1,PDATE,STOCKID,PARTCODE,SUBADMINID,STATUS FROM TEST.PACKING2 WHERE ORDERNO1 = &ORDERNO;
END

TABLE FILE SQLOUT
PRINT
  orderno1 AS ORDERNO1
  pdate AS PDATE
  stockid AS STOCKID
  partcode AS PARTCODE
  subadminid AS SUBADMINID
  status AS STATUS
ON TABLE HOLD AS HOLDTEMP_SQLOUT FORMAT FOCUS
END

TABLE FILE HOLDTEMP_SQLOUT
PRINT
  ORDERNO1
  PDATE
  STOCKID
  PARTCODE
  SUBADMINID
  STATUS
  COMPUTE CONFIRM_LINK/A100V = 'Click to Update Shipment';
  COMPUTE CONFIRM_VALUE/A3V = 'YES'; NOPRINT
WHERE ORDERNO1 EQ &ORDERNO;
ON TABLE SUBHEAD
""
ON TABLE SET STYLE *
INCLUDE=ENIADefault_combine.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
TYPE=DATA,
     COLUMN=N7,
     DRILLMENUITEM='Confirm Shipment',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='YES' \
     ),
     TARGET='_self',
     DRILLMENUITEM='Refresh Data',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='NO' \
     ),
     TARGET='_self',
$
ENDSTYLE
END
-GOTO EXIT

-UPDATE
ENGINE SQLPSTGR SET DEFAULT_CONNECTION DBTEST_WRITE
SQL SQLPSTGR
UPDATE TEST.PACKING2 SET STATUS = 75 WHERE ORDERNO1 = &ORDERNO AND STATUS = 28;
-*UPDATE TEST.PACKING2 SET STATUS = 28 WHERE ORDERNO1 = &ORDERNO AND STATUS = 75;
SQL COMMIT;
END

-RUN
SLEEP 3

ENGINE SQLPSTGR SET DEFAULT_CONNECTION DBTEST
SQL SQLPSTGR PREPARE SQLOUT FOR
SELECT ORDERNO1,PDATE,STOCKID,PARTCODE,SUBADMINID,STATUS FROM TEST.PACKING2 WHERE ORDERNO1 = &ORDERNO;
END

TABLE FILE SQLOUT
PRINT
  orderno1 AS ORDERNO1
  pdate AS PDATE
  stockid AS STOCKID
  partcode AS PARTCODE
  subadminid AS SUBADMINID
  status AS STATUS
ON TABLE HOLD AS HOLDTEMP_SQLOUT2 FORMAT FOCUS
END

TABLE FILE HOLDTEMP_SQLOUT2
PRINT
  ORDERNO1
  PDATE
  STOCKID
  PARTCODE
  SUBADMINID
  STATUS
  COMPUTE CONFIRM_LINK/A100V = 'Click to Update Shipment';
  COMPUTE CONFIRM_VALUE/A3V = 'YES'; NOPRINT
WHERE ORDERNO1 EQ &ORDERNO;
ON TABLE SUBHEAD
""
ON TABLE SET STYLE *
INCLUDE=ENIADefault_combine.sty,$
TYPE=REPORT, TITLETEXT=&WF_TITLE.QUOTEDSTRING, SUMMARY=&WF_SUMMARY.QUOTEDSTRING, $
TYPE=DATA,
     COLUMN=N7,
     DRILLMENUITEM='Confirm Shipment',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='YES' \
     ),
     TARGET='_self',
     DRILLMENUITEM='Refresh Data',
          FOCEXEC=rpt_sql_testing.fex( \
     ORDERNO=N1 \
     RANDOM=&RANDOM \
	 CONFIRM='NO' \
     ),
     TARGET='_self',
$
ENDSTYLE
END

-EXIT


WF versions : Prod 8.2.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2165 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Force SQL UPDATE statement before refreshing data.

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.