Alpha Video Training
Results 1 to 16 of 16

Thread: "No such field" error in an append operation

  1. #1
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default "No such field" error in an append operation

    I modified a correct working function without an argument

    Code:
    FUNCTION stat01 AS C ( )
    .
    .
    append.t_filter = "DocYear=year(date())-1"
    .
    .
    into a function with an argument:

    Code:
    FUNCTION stat01 AS C (vyear as N)
    .
    .
    append.t_filter = "DocYear=vyear"
    .
    .
    I now get the error message: No such field (errorcode = 1003)


    I also tried
    Code:
    append.t_filter = "DocYear=var->vyear"
    but then the errorcode is 1527


    Who can help me with the correct syntax for pointing to the argument?

    Thanks

    Ton
    Most things are simple but unfortunately only after the first time

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: "No such field" error in an append operation

    I think you want

    append.t_filter = "DocYear="+alltrim(str(vyear))

    I don't believe you need the alltrim(str()) due to Alpha's automatic type conversion when appending to a character string but it does make it clearer what you are doing.

  3. #3
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Hi Stan,

    Thanks for your quick reply but unfortunately the syntax is incorrect.

    As you could see in the correct working function, the fields are numeric.
    If the value was in an global variable I could point to var->GlobalNumericValue.

    But I cannot imagine there is no way to point to the argument. Maybe in combination with 'eval'.

    If there is no other way, I must use that intermediate step.

    A curious puzzle.
    I wonder who can solve it.

    Ton
    Most things are simple but unfortunately only after the first time

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: "No such field" error in an append operation

    As you could see in the correct working function, the fields are numeric.
    But the append.filter must be a character expression, n'est pa?

    Code:
    vyear = 2007
    
    append.t_filter = "DocYear=var->vyear"
    ? append.t_filter
    = "DocYear=var->vyear"
    
    append.t_filter = "DocYear="+alltrim(str(var->vyear))
    ? append.t_filter
    = "DocYear=2007"

  5. #5
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Quote Originally Posted by Stan Mathews View Post
    But the append.filter must be a character expression, n'est pas?
    Oui monsieur, tres bien.

    As said this is the intermediate step and will work.

    Code:
    FUNCTION stat01 AS C (vyear as N )
    DIM global myyear as N =  vyear
    .
    .
    append.t_filter =  "Docyear=var->myyear"
    .
    .
    delete global myyear

    I have a similar argument like this for the sum.filter in a summarize function without any problem

    Code:
    sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=vyear"
    Thats why I still want(ed) to find a solution for the append.t_filterexpression to point direct to the argument of the function.
    I am afraid there isn't.

    Merci

    Ton
    Most things are simple but unfortunately only after the first time

  6. #6
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default Re: "No such field" error in an append operation

    Here are 2 more examples both producing error code 1091 field types don't match
    How do you use alltrim etc when multiplying 2 variables within brackets?

    'global variables declared as form variables when form opened
    SSCtemp (should = 121.32 when calculated in code below)
    Var->Uppwemp = 2022 (calculated before running code below)
    var->Ratemp = 6.0 (calculated before running code below)

    This code is called from a script run within xbasic code from a button on a form
    SSCtemp=(Var->Uppwemp*var->Ratemp)/100
    When run error 1091 field types don't match occurs

    Here Ssc_normal is a table field, following code should set the field's value to 121.32
    parentform:Ssc_normal.value = (Var->Uppwemp*var->Ratemp)/100
    again, When run error 1091 field types don't match occurs

  7. #7
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Hi Mike,

    It's a different case what you bring up now.
    Please debug your Xbasic and test the variables and fields with typeof() then you can discover which field has different filetype as you expected.

    ? typeof(SSCtemp)

    If SSCtemp is a Characterfield, then your calculation can be: SSCtemp= alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2))

    In my interactive window:

    dim uppwemp as N = 2022
    dim Ratemp as N = 6.0
    ?? uppwemp
    2022
    ?? Ratemp
    6

    SSCtemp = alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2))
    ?? SSCtemp
    "121.32"

    OR

    SSCtemp = stritran(alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2)),".",",")
    ?? SSCtemp
    "121,32"



    Good luck

    Ton
    Most things are simple but unfortunately only after the first time

  8. #8
    Member
    Real Name
    Mike Vance
    Join Date
    Jun 2004
    Location
    Guernsey, Channel Islands
    Posts
    419

    Default Re: "No such field" error in an append operation

    Many thanks for your advice Ton. I hadn't come across typeof before - very useful

    SSCtemp is a numeric global variable. I think I've got the first example working. I added 'var->' in from of the SSCtemp code and it now seems OK.

    Mike

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: "No such field" error in an append operation

    I opened AlphaSports and duplicated the Customer table, no records, no indexes, etc. (named the duplicate app_cust)
    I entered some records in the duplicate table and gave one of the records a creditrating of 9.
    I created a function to append records from the duplicate table to the customer table with the filter of creditrating > function_parameter.

    Code:
    FUNCTION app_cr AS L (cr_rate AS N )
    app_cr = .F.
    DIM Append as P
    a_tbl = table.open("Customer")
    append.t_db = "app_cust"
    ON ERROR GOTO ERROR23112011073425989
    append.m_key = ""
    append.t_key = ""
    append.m_filter = ""
    append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
    append.type = "All"
    append.m_count = 21
    append.m_field1 = "CUSTOMER_ID"
    append.m_exp1 = "@APP_CUST->CUSTOMER_ID"
    append.m_field2 = "FIRSTNAME"
    append.m_exp2 = "@APP_CUST->FIRSTNAME"
    append.m_field3 = "LASTNAME"
    append.m_exp3 = "@APP_CUST->LASTNAME"
    append.m_field4 = "COMPANY"
    append.m_exp4 = "@APP_CUST->COMPANY"
    append.m_field5 = "PHONE"
    append.m_exp5 = "@APP_CUST->PHONE"
    append.m_field6 = "FAX"
    append.m_exp6 = "@APP_CUST->FAX"
    append.m_field7 = "BILL_ADDRESS_1"
    append.m_exp7 = "@APP_CUST->BILL_ADDRESS_1"
    append.m_field8 = "BILL_ADDRESS_2"
    append.m_exp8 = "@APP_CUST->BILL_ADDRESS_2"
    append.m_field9 = "BILL_CITY"
    append.m_exp9 = "@APP_CUST->BILL_CITY"
    append.m_field10 = "BILL_STATE_REGION"
    append.m_exp10 = "@APP_CUST->BILL_STATE_REGION"
    append.m_field11 = "BILL_POSTAL_CODE"
    append.m_exp11 = "@APP_CUST->BILL_POSTAL_CODE"
    append.m_field12 = "BILL_COUNTRY"
    append.m_exp12 = "@APP_CUST->BILL_COUNTRY"
    append.m_field13 = "SHIP_ADDRESS_1"
    append.m_exp13 = "@APP_CUST->SHIP_ADDRESS_1"
    append.m_field14 = "SHIP_ADDRESS_2"
    append.m_exp14 = "@APP_CUST->SHIP_ADDRESS_2"
    append.m_field15 = "SHIP_CITY"
    append.m_exp15 = "@APP_CUST->SHIP_CITY"
    append.m_field16 = "SHIP_STATE_REGION"
    append.m_exp16 = "@APP_CUST->SHIP_STATE_REGION"
    append.m_field17 = "SHIP_POSTAL_CODE"
    append.m_exp17 = "@APP_CUST->SHIP_POSTAL_CODE"
    append.m_field18 = "SHIP_COUNTRY"
    append.m_exp18 = "@APP_CUST->SHIP_COUNTRY"
    append.m_field19 = "SHIP_SAME"
    append.m_exp19 = "@APP_CUST->SHIP_SAME"
    append.m_field20 = "EMAIL"
    append.m_exp20 = "@APP_CUST->EMAIL"
    append.m_field21 = "CREDITRATING"
    append.m_exp21 = "@APP_CUST->CREDITRATING"
    append.t_count = 0
    a_tbl.append()
    GOTO CONTINUE23112011073425989
    ERROR23112011073425989:
    ON ERROR GOTO 0
    ui_msg_box("Error","Error running Append Operation"+crlf()+error_text_get())
    END
    CONTINUE23112011073425989:
    a_tbl.close()
    app_cr = .T.
    END FUNCTION
    The function is executed like app_cust(6). It works.
    Note that if the filter is stated as

    append.t_filter = "Creditrating > cr_rate"

    it will not work.

    app_cust.zip
    app_cr - 11-23-2011 -1.txt

  10. #10
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Hi Stan,

    Thanks for confirming. Great job to test this case as you did.
    Weird that it is more a quest ' Find the right syntax' than logic programming.
    But I like the workaround you provided. Very elegant.

    Ton
    Most things are simple but unfortunately only after the first time

  11. #11
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,297

    Default Re: "No such field" error in an append operation

    suggesting that this syntax

    Code:
    append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
    is a 'work around' for this syntax

    Code:
    append.t_filter = "Creditrating > cr_rate"
    not working is, in my opinion, misleading because it implies that the second syntax SHOULD have worked.

    the first syntax shown here is correct. it is not a work around because the second syntax should not have worked.

    the append.t_filter property is a character string that contains a filter expression.

    say you want the filter to be: state = "MA"
    and say you have a variable called 'whatState'

    clearly if you write

    Code:
    append.t_filter = "state = \"ma\""
    it is clear what you intend.

    if you write

    Code:
    append.t_filter = "state = var->whatState"
    it is clear that this is not the same as: state = "MA"

    but

    Code:
    append.t_filber = "state = " + s_quote(whatState)
    is obviously the same as

    Code:
    state = "MA"
    which is what you intended the filter to be.

  12. #12
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Quote Originally Posted by Selwyn Rabins View Post
    suggesting that this syntax

    Code:
    append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
    is a 'work around' for this syntax

    Code:
    append.t_filter = "Creditrating > cr_rate"
    not working is, in my opinion, misleading because it implies that the second syntax SHOULD have worked.

    the first syntax shown here is correct. it is not a work around because the second syntax should not have worked.

    the append.t_filter property is a character string that contains a filter expression.
    Selwyn,

    Thank you for your explanation.
    The reason I was thinking it should work is here in this line
    Code:
    sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=vyear"
    where vyear is a numeric variable passed as argument into a function with this append-operation.

    Remaining question: Is (focused on a numeric variable) the syntax of 'sum.filter' different than 'append.t_filter'?

    Ton
    Most things are simple but unfortunately only after the first time

  13. #13
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,297

    Default Re: "No such field" error in an append operation

    in some cases, if the scope of the variable is global or session, a5 will attempt to resolve a filter string that contains a variable. it is possible that the example you are referencing used a global or shared (session) variable.

    however, i don't like this at all - and if it were not for the fact that we don't want to break any existing application that rely on this behavior, i would be tempted to remove this behavior.

    i think it is much more understandable if you resolve the variable reference yourself, as in:

    Code:
    sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=" + s_quote(vyear)
    rather than rely on a5 to try (and sometimes fail) to resolve the variable reference.

  14. #14
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: "No such field" error in an append operation

    in some cases, if the scope of the variable is global or session, a5 will attempt to resolve a filter string that contains a variable. it is possible that the example you are referencing used a global or shared (session) variable.
    Thank you for that.

    I was at a loss to try to explain why sometimes the "Creditrating > cr_rate" syntax would work and sometimes not. I could not resolve whether it was the context or something else that allowed it to work. In this instance, moving from a script where it worked to a function where the passed paramater did not work, further clouded the issue for me.

    I'd be hard pressed to work out how this should be added to the wiki, but it should be.
    Last edited by Stan Mathews; 11-25-2011 at 06:53 PM.

  15. #15
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: "No such field" error in an append operation

    Discovered inconsistencies divide people into two camps. Both prove their right to enjoy the benefits and do not know about the existence of the other.

    Selwyn thanks for your clarification. Very instructive.

    Ton
    Last edited by Ton Spies; 11-25-2011 at 06:31 PM. Reason: better translation
    Most things are simple but unfortunately only after the first time

  16. #16
    "Certified" Alphaholic Ray in Capetown's Avatar
    Real Name
    Ray Hendler
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    2,036

    Default Re: "No such field" error in an append operation

    Quote Originally Posted by Selwyn Rabins View Post
    i think it is much more understandable if you resolve the variable reference yourself, ..
    And I'm dying to add ... the time taken. Every variable lookup requires multiple clock cycles to search the variable registers. Unless processors no longer do this, which I doubt - at machine code level there has to be a fetch. Coming from that world makes me very reluctant about randomly declaring global variables for everything.
    Relevant, because less searching is required at closer to and especially local levels, I'm guessing.
    (Also, I accept that in the big picture that's not very significant)
    Last edited by Ray in Capetown; 11-27-2011 at 06:33 AM.

Similar Threads

  1. Error "Extra characters at end of expression" when LINK field is type "K"
    By RichCPT in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 10-29-2011, 01:11 AM
  2. error - "a5.js" and "'this._keys.length' is null or not an object"
    By eritovs in forum Application Server Version 10 - Web/Browser Applications
    Replies: 3
    Last Post: 10-13-2011, 10:12 PM
  3. copy previous field / record by pressing key ctrl + shift + " f " / " r " problem
    By dannysiu in forum Alpha Five Version 10 - Desktop Applications
    Replies: 3
    Last Post: 10-12-2011, 06:12 AM
  4. "Field Display Formatting" is Lost when "Pre-fetch data for Detailed View = Active"
    By PhillipS in forum Application Server Version 9 - Web/Browser Applications
    Replies: 0
    Last Post: 07-23-2009, 11:02 PM
  5. Append Problem - "invalid operation specified
    By Michael George in forum Alpha Five Version 4
    Replies: 2
    Last Post: 03-29-2002, 04:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •