ds.Fields[0].Name Error

Issue #164 resolved
0r0 created an issue

Example:

“SELECT FIRST_NAME AS PERSON_NAME FROM TABLE_NAME”;

Error1: Fields[0].Name resulting “FIRST_NAME” error.

ds.FieldByName('PERSON_NAME').Name => Runtime Error: Field 'PERSON_NAME' not found

Comments (7)

  1. Eric Grange repo owner

    Do you have any code or details that would help reproducing the issue?

    I tried with the following snippet and it worked:

    var db := new DataBase('SQLite');

    db.Exec('create table TABLE_NAME (FIRST_NAME text)');

    var ds := db.Query('SELECT FIRST_NAME AS PERSON_NAME FROM TABLE_NAME');

    db.Exec("insert into TABLE_NAME VALUES ('test')");

    PrintLn(ds.Fields[0].Name);

    PrintLn(ds.FieldByName('PERSON_NAME').Name);

  2. 0r0 reporter

    fbclient.dll UIB

    Print(DataBase.Create('UIB', ['192.168.1.28/3050:K:\bd\producao\separar\DIGIPONTOVAZIO.fdb', 'SYSDBA', 'masterkey','NONE','C:\Windows\SysWOW64\fbclient25_32.dll'])
                    .Query(SqlQuery)
                    .StringifyAll);
    

    <?pas
    Print( #'{
    "fields":[
    {"name":"PERSON_NAME","label":"Empresa"}
    ,{"name":"PERSO_NAME","label":"Cidade"}
    ,{"name":"PERSON_ID","label":"ID"}
    ]
    ,"data":
    ');

    const SqlQuery ="
                select 
                NM_EMPRESA AS PERSON_NAME
                , NM_CIDADE AS PERSO_NAME
                , CD_EMPRESA as PERSON_ID 
                from 
                sysempresa
                ";
    
    Print(DataBase.Create('UIB', ['192.168.1.28/3050:K:\bd\producao\separar\DIGIPONTOVAZIO.fdb', 'SYSDBA', 'masterkey','NONE','C:\Windows\SysWOW64\fbclient25_32.dll'])
                    .Query(SqlQuery)
                    .StringifyAll);
    
      Print("}");
    

    exit;

    case WebRequest.Authentication of
    WebAuthentication.None :
    WebResponse.RequestAuthentication(WebAuthentication.Negotiate);
    WebAuthentication.NTLM .. WebAuthentication.Kerberos :
    Print(DataBase.Create('UIB', ['192.168.1.28/3050:K:\bd\producao\separar\DIGIPONTOVAZIO.fdb', 'SYSDBA', 'masterkey','WIN1252','C:\Windows\SysWOW64\fbclient.dll'])
    .Query(WebRequest.QueryFields)
    .StringifyAll);
    else
    WebResponse.StatusCode := 401;
    end;

    ?>

  3. Log in to comment