Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
APPEND FROM [SQL Cursor]
Message
De
24/12/2008 05:20:36
 
 
À
23/12/2008 19:16:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01369081
Message ID:
01369567
Vues:
50
This is very strange in deed. What happens when you add a browse like this
  IF lnTallyCuDed1Emp > 0
   Select CuDed1Emp && New line
   Browse && New line
    SELECT CuDedEmp
* test--failure expected--start

    APPEND FROM (DBF("CuDed1Emp"))
* test--failure expected--end
One last comment. I have seen, on very fast computers, that the OS caches file writes so the next command won't see the change from the previous line. In those cases a simple INKEY(0.2,'HM') will do the trick.

By the way, both Nofilter and Readwrite will create a "real" cursor if used alone, so you don't need both, although it doesn't hurt. And in your case, since you use aggretate functions, you really don't need any of them to create a "real" cursor.



>Hi Tore,
>
>>But you don't show what I ask for, so please try again. I need the complete code as is is when it fails! I hope that is clear, I want the whole code, EXACTLY as it is when you get the errors. No workarounds, and no commented out lines. Absolutely no code must be commented out, since these lines only cause confusion. In other words, please show me the complete code which fails!
>
>Ok, here it is:
>
>
>* LocalCreateReportDataVoluntaryDeductions
>* export all voluntary deductions
>
>* input:
>*   ThisForm.iRun
>*   table ADeduct
>
>IF glsuspend
>SET STEP ON 
>ENDIF
>
>* step 0A--create cursor CuDedEmp--all deduction data by employee
>  CREATE CURSOR CuDedEmp;
>    (iEmp I,;
>     cNameLast C(25),;
>     cNameFrst C(25),;
>     cNameMI   C(1),;
>     cNameSort C(51),;
>     yDeduct   Y,;
>     cAggType  C(1))
>
>* step 0B--create cursor CuDedGLA--all deduction data by General Ledger Account
>  CREATE CURSOR CuDedGLA;
>    (cAcctCode C(5),;
>     cAcctDesc C(25),;
>     yDeduct   Y,;
>     cAggType  C(1))
>
>* step 0C--create cursor CuDedExp--all deduction data for export
>  CREATE CURSOR CuDedExp;
>    (iEmp I,;
>     cNameLast C(25),;
>     cNameFrst C(25),;
>     cNameMI   C(1),;
>     cAcctCode C(5),;
>     yDeduct   Y,;
>     cAggType  C(1),;
>     cText     C(55))
>
>* startup
>  LOCAL lnTallyCuDed1GLA,lnTallyCuDed1Emp,lnTallyCuDed2,;
>    lnTallyCuDed3EmpGLA,lnTallyCuDed3Emp,lnTallyCuDed3Gla
>  STORE 0 TO lnTallyCuDed1GLA,lnTallyCuDed1Emp,lnTallyCuDed2,;
>    lnTallyCuDed3EmpGLA,lnTallyCuDed3Emp,lnTallyCuDed3Gla
>
>* step 1--Agg Type 1: aggregate deductions by employee by GL account
>  SELECT;
>      ADeduct.iEmp,;
>      LUGLActD.cAccount       AS cAcctCode,;
>      MAX(LUGLActD.cText)     AS cAcctDesc,;
>      SUM(ADeduct.yDeduct)    AS yDeduct,;
>      MAX(Employee.cNameLast) AS cNameLast,;
>      MAX(Employee.cNameFrst) AS cNameFrst,;
>      MAX(Employee.cNameMI)   AS cNameMI;
>    FROM ADeduct JOIN Employee ON Employee.iPK = ADeduct.iEmp;
>                 JOIN LUDeduct ON LUDeduct.iPK = ADeduct.iDeduct;
>                 JOIN DedCmpny ON LUDeduct.iPK = DedCmpny.iDeduct;
>                 JOIN LUGLActD ON LUGLActD.iPK = DedCmpny.iGLAcct;
>    GROUP BY 1,2;
>    WHERE ADeduct.iRun = ThisForm.iRun AND;
>          LUDeduct.cAggType = "1"      AND;
>          LUDeduct.lGL                 AND;
>          DedCmpny.iCompany = ThisForm.iCompany;
>    INTO CURSOR CuDed1EmpGLA NOFILTER READWRITE
>  lnTallyCuDed1GLA = _TALLY    
>
>* step 2--Agg Type 1: aggregate cursor CuDed1EmpGLA by employee
>  IF lnTallyCuDed1GLA > 0
>
>    SELECT;
>        iEmp,;
>        MAX(UPPER(cNameLast + cNameFrst + cNameMI));
>                       AS cNameSort,;
>        MAX(cNameLast) AS cNameLast,;
>        MAX(cNameFrst) AS cNameFrst,;
>        MAX(cNameMI)   AS cNameMI,;
>        SUM(yDeduct)   AS yDeduct,;
>        MAX("1")       AS cAggType;
>      FROM CuDed1EmpGLA;
>      GROUP BY 1;
>      INTO CURSOR CuDed1Emp READWRITE NOFILTER
>    lnTallyCuDed1Emp = _TALLY    
>
>  ENDIF && lnTallyCuDed1GLA > 0
>
>* step 3--aggregate cursor CuDed1EmpGLA by GL account
>  IF lnTallyCuDed1GLA > 0
>    SELECT;
>        cAcctCode,;
>        MAX(cAcctDesc) AS cAcctDesc,;
>        SUM(yDeduct)   AS yDeduct,;
>        "1"            AS cAggType;
>      FROM CuDed1EmpGLA;
>      GROUP BY 1;
>      INTO CURSOR CuDed1GLA NOFILTER READWRITE
>    lnTallyCuDed1GLA = _TALLY
>  ENDIF && lnTallyCuDed1GLA > 0
>
>* step 4--Agg Type 2: get garnishments
>* TODO later
>
>* step 5--Agg Type 3: get agg type 3 (currently Exchange)
>IF glsuspend
>SET STEP ON 
>endif
>  SELECT;
>      ADeduct.iEmp,;
>      LUGLActD.cAccount       AS cAcctCode,;
>      MAX(LUGLActD.cText)     AS cAcctDesc,;
>      SUM(ADeduct.yDeduct)    AS yDeduct,;
>      MAX(Employee.cNameLast) AS cNameLast,;
>      MAX(Employee.cNameFrst) AS cNameFrst,;
>      MAX(Employee.cNameMI)   AS cNameMI,;
>      "3"                     AS cAggType;
>    FROM ADeduct JOIN Employee ON Employee.iPK = ADeduct.iEmp;
>                 JOIN LUDeduct ON LUDeduct.iPK = ADeduct.iDeduct;
>                 JOIN DedCmpny ON LUDeduct.iPK = DedCmpny.iDeduct;
>                 JOIN LUGLActD ON LUGLActD.iPK = DedCmpny.iGLAcct;
>    GROUP BY 1,2;
>    WHERE ADeduct.iRun = ThisForm.iRun AND;
>          LUDeduct.cAggType = "3"      AND;
>          LUDeduct.lGL                 AND;
>          DedCmpny.iCompany = ThisForm.iCompany;
>    INTO CURSOR CuDed3EmpGLA NOFILTER READWRITE
>  lnTallyCuDed3EmpGLA = _TALLY
>
>* step 6--Agg Type 3: aggregate cursor CuDed3EmpGLA by employee
>  IF lnTallyCuDed3EmpGLA > 0
>    SELECT;
>        iEmp,;
>        MAX(UPPER(cNameLast + cNameFrst + cNameMI));
>                       AS cNameSort,;
>        MAX(cNameLast) AS cNameLast,;
>        MAX(cNameFrst) AS cNameFrst,;
>        MAX(cNameMI)   AS cNameMI,;
>        SUM(yDeduct)   AS yDeduct,;
>        "3"            AS cAggType;
>      FROM CuDed3EmpGLA;
>      GROUP BY 1;
>      INTO CURSOR CuDed3Emp NOFILTER READWRITE
>    lnTallyCuDed3Emp = _TALLY
>  ENDIF && lnTallyCuDed3EmpGLA > 0
>
>* step 7--Agg  Type 3: aggregate cursor CuDed3EmpGLA by GL account
>  IF lnTallyCuDed3EmpGLA > 0
>    SELECT;
>        cAcctCode,;
>        MAX(cAcctDesc) AS cAcctDesc,;
>        SUM(yDeduct)   AS yDeduct,;
>        "3"            AS cAggType;
>      FROM CuDed3EmpGLA;
>      GROUP BY 1;
>      INTO CURSOR CuDed3GLA NOFILTER READWRITE
>    lnTallyCuDed3Gla = _TALLY
>  ENDIF && lnTallyCuDed3EmpGLA > 0
>
>* step 8--Agg  Type 1: copy CuDed1Emp to CuDedEmp
>IF glsuspend
>SET STEP ON 
>endif
>  IF lnTallyCuDed1Emp > 0
>
>    SELECT CuDedEmp
>* test--failure expected--start
>    APPEND FROM (DBF("CuDed1Emp"))
>* test--failure expected--end
>
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform