Focal Point
[SOLVED] Maintain problem writing to the dataSource

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9291009382

May 12, 2008, 07:14 PM
brjohnson
[SOLVED] Maintain problem writing to the dataSource
Hi everyone,

I was wondering if someone could shed some light on a confusing problem I have run into. The following function is supposed to copy all the records from the VOUCHERS table to the VOUCHER_HISTORY table, and then delete all the records in the VOUCHERS table. When I run the function I have verified, by using the debugger, that GetVoucherHistoryStack is populated, but for some reason the records do not write to datasource. The records are deleted from the VOUCHERS table, but nothing is written to VOUCHER_HISTORY table. I have also verified that I can write to the VOUCHER_HISTORY table by hard coding a record and adding it. I've added the code and the corresponding master files below. Maybe someone will see something that I have overlooked.

 CASE EoY
STACK CLEAR GetVouchersStack;
STACK CLEAR GetVoucherHistoryStack;
REPOSITION vouchers.VOUCHERS.VCHRID;
FOR ALL NEXT vouchers.VOUCHERS.VCHRID INTO GetVouchersStack;
REPEAT 5; i=1;
	COMPUTE GetVoucherHistoryStack(i).VCHRID = GetVouchersStack(i).VCHRID;
	COMPUTE GetVoucherHistoryStack(i).HFCCID = GetVouchersStack(i).HFCCID;
	COMPUTE GetVoucherHistoryStack(i).H_VCHRSEMCODE = GetVouchersStack(i).VCHRSEMCODE;
	COMPUTE GetVoucherHistoryStack(i).H_DATEENTERED = GetVouchersStack(i).DATEENTERED;
	COMPUTE GetVoucherHistoryStack(i).H_VCHRCODE = GetVouchersStack(i).VCHRCODE;
	COMPUTE GetVoucherHistoryStack(i).H_BOOKCODE = GetVouchersStack(i).BOOKCODE;
	COMPUTE GetVoucherHistoryStack(i).H_EFC = GetVouchersStack(i).EFC;
	COMPUTE GetVoucherHistoryStack(i).H_UNMETNEED = GetVouchersStack(i).UNMETNEED;
	COMPUTE GetVoucherHistoryStack(i).H_CLASS = GetVouchersStack(i).CLASS;
	COMPUTE GetVoucherHistoryStack(i).H_CRHRS = GetVouchersStack(i).CRHRS;
	COMPUTE GetVoucherHistoryStack(i).H_CRHRAMT = GetVouchersStack(i).CRHRAMT;
	COMPUTE GetVoucherHistoryStack(i).H_TUITION = GetVouchersStack(i).TUITION;
	COMPUTE GetVoucherHistoryStack(i).H_SERVFEE = GetVouchersStack(i).SERVFEE;
	COMPUTE GetVoucherHistoryStack(i).H_REGFEE = GetVouchersStack(i).REGFEE;
	COMPUTE GetVoucherHistoryStack(i).H_LABFEE = GetVouchersStack(i).LABFEE;
	COMPUTE GetVoucherHistoryStack(i).H_TECHFEE = GetVouchersStack(i).TECHFEE;
	COMPUTE GetVoucherHistoryStack(i).H_VOUCHERAMT = GetVouchersStack(i).VOUCHERAMT;
	COMPUTE GetVoucherHistoryStack(i).H_BOOKAMT = GetVouchersStack(i).BOOKAMT;
	COMPUTE GetVoucherHistoryStack(i).H_BOOKSTORE = GetVouchersStack(i).BOOKSTORE;
	COMPUTE GetVoucherHistoryStack(i).H_PROGRESSRPT = GetVouchersStack(i).PROGRESSRPT;
	COMPUTE GetVoucherHistoryStack(i).H_PROBATIONLTR = GetVouchersStack(i).PROBATIONLTR;
	COMPUTE GetVoucherHistoryStack(i).H_CHECKED = GetVouchersStack(i).ENTERED;
	COMPUTE GetVoucherHistoryStack(i).NOTES = GetVouchersStack(i).NOTES;
	COMPUTE i=i+1;
ENDREPEAT
FOR ALL INCLUDE voucher_history.VOUCHER_HISTORY.VCHRID FROM GetVoucherHistoryStack;
DELETE vouchers.VOUCHERS.VCHRID FROM GetVouchersStack;
ENDCASE 


FILENAME=VOUCHERS, SUFFIX=SQLMSS , $
SEGMENT=VOUCHERS, SEGTYPE=S0, $
FIELDNAME=VCHRID, ALIAS=VchrID, USAGE=I11, ACTUAL=I4, $
FIELDNAME=HFCCID, ALIAS=HFCCID, USAGE=D7cL, ACTUAL=D8,
MISSING=ON, $
FIELDNAME=VCHRSEMCODE, ALIAS=VchrSemCode, USAGE=A10V, ACTUAL=A10V, $
FIELDNAME=DATEENTERED, ALIAS=DateEntered, USAGE=YYMD, ACTUAL=DATE,
MISSING=ON, $
FIELDNAME=VCHRCODE, ALIAS=VchrCode, USAGE=A5V, ACTUAL=A5V,
MISSING=ON, $
FIELDNAME=BOOKCODE, ALIAS=BookCode, USAGE=A5V, ACTUAL=A5V,
MISSING=ON, $
FIELDNAME=EFC, ALIAS=EFC, USAGE=I6, ACTUAL=I4,
MISSING=ON, $
FIELDNAME=UNMETNEED, ALIAS=UnmetNeed, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=CLASS, ALIAS=Class, USAGE=A40V, ACTUAL=A40V,
MISSING=ON, $
FIELDNAME=CRHRS, ALIAS=CrHrs, USAGE=D20, ACTUAL=D8,
MISSING=ON, $
FIELDNAME=CRHRAMT, ALIAS=CrHrAmt, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=TUITION, ALIAS=Tuition, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=SERVFEE, ALIAS=ServFee, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=REGFEE, ALIAS=RegFee, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=LABFEE, ALIAS=LabFee, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=TECHFEE, ALIAS=TechFee, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=VOUCHERAMT, ALIAS=VoucherAmt, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=BOOKAMT, ALIAS=BookAmt, USAGE=P21.2, ACTUAL=P10,
MISSING=ON, $
FIELDNAME=BOOKSTORE, ALIAS=Bookstore, USAGE=I11, ACTUAL=I4, $
FIELDNAME=PROGRESSRPT, ALIAS=ProgressRpt, USAGE=I11, ACTUAL=I4, $
FIELDNAME=PROBATIONLTR, ALIAS=ProbationLtr, USAGE=I11, ACTUAL=I4, $
FIELDNAME=RECONCILED, ALIAS=Reconciled, USAGE=I11, ACTUAL=I4, $
FIELDNAME=NOTES, ALIAS=Notes, USAGE=TX50, ACTUAL=TX,
MISSING=ON, $
FIELDNAME=ENTERED, ALIAS=Entered, USAGE=HYYMDI, ACTUAL=HYYMDI,
MISSING=ON, $



FILENAME=VOUCHER_HISTORY, SUFFIX=SQLMSS , $
SEGMENT=VOUCHER_HISTORY, SEGTYPE=S0, $
FIELDNAME=VCHRID, ALIAS=VchrID, USAGE=I11, ACTUAL=I4, $
FIELDNAME=HFCCID, ALIAS=HFCCID, USAGE=D8cL, ACTUAL=D8,
MISSING=ON, $
FIELDNAME=H_VCHRSEMCODE, ALIAS='H-VchrSemCode', USAGE=A10V, ACTUAL=A10V,
TITLE='H-VchrSemCode', $
FIELDNAME=H_DATEENTERED, ALIAS='H-DateEntered', USAGE=YYMD, ACTUAL=DATE,
MISSING=ON,
TITLE='H-DateEntered', $
FIELDNAME=H_VCHRCODE, ALIAS='H-VchrCode', USAGE=A5V, ACTUAL=A5V,
MISSING=ON,
TITLE='H-VchrCode', $
FIELDNAME=H_BOOKCODE, ALIAS='H-BookCode', USAGE=A5V, ACTUAL=A5V,
MISSING=ON,
TITLE='H-BookCode', $
FIELDNAME=H_EFC, ALIAS='H-EFC', USAGE=I6, ACTUAL=I4,
MISSING=ON,
TITLE='H-EFC', $
FIELDNAME=H_UNMETNEED, ALIAS='H-UnmetNeed', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-UnmetNeed', $
FIELDNAME=H_CLASS, ALIAS='H-Class', USAGE=A40V, ACTUAL=A40V,
MISSING=ON,
TITLE='H-Class', $
FIELDNAME=H_CRHRS, ALIAS='H-CrHrs', USAGE=D20, ACTUAL=D8,
MISSING=ON,
TITLE='H-CrHrs', $
FIELDNAME=H_CRHRAMT, ALIAS='H-CrHrAmt', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-CrHrAmt', $
FIELDNAME=H_TUITION, ALIAS='H-Tuition', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-Tuition', $
FIELDNAME=H_SERVFEE, ALIAS='H-ServFee', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-ServFee', $
FIELDNAME=H_REGFEE, ALIAS='H-RegFee', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-RegFee', $
FIELDNAME=H_LABFEE, ALIAS='H-LabFee', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-LabFee', $
FIELDNAME=H_TECHFEE, ALIAS='H-TechFee', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-TechFee', $
FIELDNAME=H_VOUCHERAMT, ALIAS='H-VoucherAmt', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-VoucherAmt', $
FIELDNAME=H_BOOKAMT, ALIAS='H-BookAmt', USAGE=P21.2, ACTUAL=P10,
MISSING=ON,
TITLE='H-BookAmt', $
FIELDNAME=H_BOOKSTORE, ALIAS='H-Bookstore', USAGE=I11, ACTUAL=I4,
TITLE='H-Bookstore', $
FIELDNAME=H_PROGRESSRPT, ALIAS='H-ProgressRpt', USAGE=I11, ACTUAL=I4,
TITLE='H-ProgressRpt', $
FIELDNAME=H_PROBATIONLTR, ALIAS='H-ProbationLtr', USAGE=YYMD, ACTUAL=DATE,
MISSING=ON,
TITLE='H-ProbationLtr', $
FIELDNAME=H_CHECKED, ALIAS='H-Checked', USAGE=I11, ACTUAL=I4,
TITLE='H-Checked', $
FIELDNAME=NOTES, ALIAS=Notes, USAGE=TX50, ACTUAL=TX,
MISSING=ON, $



Thanks all

This message has been edited. Last edited by: brjohnson,


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
May 12, 2008, 10:38 PM
Waz
Bryan, acouple of questions

What are the Keys to the history table?

Have you checked the FocError after the include to see if there has been an error?

Also, if there is an error, you should not do the delete as well.

Your process of include and delete should be a logical unit of work, then committed.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

May 13, 2008, 09:27 AM
brjohnson
Hi Waz, Thanks for your reply.

The key to both tables is VCHRID.

I checked the FocError and it is returning -22, and the FocErrorRow is 1.
I'm not sure what that means, is there a list of what the various error codes mean because I couldn't find it in the documentation.

Thanks

This message has been edited. Last edited by: brjohnson,


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
May 13, 2008, 10:55 AM
brjohnson
Hi,

After more closely inspecting the data it turns out that there were records that had the same VCHRID in both tables. Although this was not supposed to happen(it's tough to write a good application with bad data), I was able to find a workaround. The function works now. I would assume that the focError -22 must have been referring to adding a record that has the same key value as a record already in the table, but it would be helpful to see if IB has a list of possible causes for the various FocError codes. Anyway, thanks for your help Waz.

The people in this forum are the best!


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
May 13, 2008, 05:38 PM
Waz
Not knowing your data, I assume that VCHRID will always be unique for the history table. If not you may need a time stamp to keepp it unique.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

May 14, 2008, 11:09 AM
Dave Ayers
quote:
it would be helpful to see if IB has a list of possible causes for the various FocError codes.


I strongly agree with Bryan on this. I have seen many questions arise on this board about the meaning of these error codes without a clear resolution.

It is far past time for IBI to address this issue and give us a list of the FocError code and their meaning , so Maintain coders have a fighting chance of debugging their applications.

It would be adequate to post them here in the WebFocus forum, in lieu of a formal document, at least they would be available to the community.

Thanks,


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server