mORMot and Open Source friends
Check-in [2a0a34c5bc]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{2082} fixed TODBCConnectionProperties.GetProcedureParameters
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a0a34c5bc411866ad94a4a5b1f9374d2ad0c7a9
User & Date: ab 2015-11-20 12:35:06
Context
2015-11-20
15:30
{2083} another fix for TODBCConnectionProperties.GetFields and GetProcedureParameters methods check-in: 5fdc9eae5c user: ab tags: trunk
12:35
{2082} fixed TODBCConnectionProperties.GetProcedureParameters check-in: 2a0a34c5bc user: ab tags: trunk
2015-11-19
22:00
{2081} avoid blank cell drawing for huge content in mORMot UI grid component check-in: 343f200652 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynDBODBC.pas.

1839
1840
1841
1842
1843
1844
1845


1846
1847
1848
1849
1850
1851
1852
....
1945
1946
1947
1948
1949
1950
1951
1952

1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
....
1973
1974
1975
1976
1977
1978
1979


1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
      status := ODBC.ColumnsA(fStatement,nil,0,pointer(Schema),SQL_NTS,
        pointer(Table),SQL_NTS,nil,0);
      if (status<>SQL_SUCCESS) or (not Step) then begin
        // e.g. driver does not support schema
        DeallocStatement;
        AllocStatement;
        status := ODBC.ColumnsA(fStatement,nil,0,nil,0,pointer(Table),SQL_NTS,nil,0);


      end;
      ODBC.Check(Connection,nil,status,SQL_HANDLE_STMT,fStatement);
      BindColumns;
      FA.Init(TypeInfo(TSQLDBColumnDefineDynArray),Fields,@n);
      FA.Compare := SortDynArrayAnsiStringI; // FA.Find() case insensitive
      fillchar(F,sizeof(F),0);
      if fCurrentRow>0 then // Step done above
................................................................................
    on Exception do ; // just ignore errors here
  end;
end;

procedure TODBCConnectionProperties.GetProcedureParameters(const aProcName: RawUTF8;
  out Parameters: TSQLDBProcColumnDefineDynArray);
var Schema, Package, Proc: RawUTF8;
    F: TSQLDBProcColumnDefine;

    n,DataType: integer;
    status: SqlReturn;
    FA: TDynArray;
    Stmt: TODBCStatement;
begin
  inherited; // first try from SQL, if any (faster)
  if Parameters<>nil then
    exit; // already retrieved directly from engine
  SQLSplitProcedureName(aProcName,Schema,Package,Proc);
  Proc := SynCommons.UpperCase(Proc);
................................................................................
        pointer(Schema),SQL_NTS,pointer(Proc),SQL_NTS,nil,0);
      if (status<>SQL_SUCCESS) or (not Stmt.Step) then begin
        // e.g. driver does not support schema
        Stmt.DeallocStatement;
        Stmt.AllocStatement;
        status := ODBC.SQLProcedureColumnsA(Stmt.fStatement,nil,0,
          nil,0,pointer(Proc),SQL_NTS,nil,0);


      end;
      ODBC.Check(Stmt.Connection,nil,status,SQL_HANDLE_STMT,Stmt.fStatement);
      Stmt.BindColumns;
      FA.Init(TypeInfo(TSQLDBColumnDefineDynArray),Parameters,@n);
      fillchar(F,sizeof(F),0);
      if Stmt.fCurrentRow>0 then // Stmt.Step done above
      repeat
        F.ColumnName := Trim(Stmt.ColumnUTF8(3)); // Column*() should be in order
        case Stmt.ColumnInt(4) of
          SQL_PARAM_INPUT:        F.ColumnParamType := paramIn;
          SQL_PARAM_INPUT_OUTPUT: F.ColumnParamType := paramInOut;
          else                    F.ColumnParamType := paramOut;
        end;
        DataType := Stmt.ColumnInt(5);
        F.ColumnTypeNative := Trim(Stmt.ColumnUTF8(6));
        F.ColumnLength := Stmt.ColumnInt(7);
        F.ColumnScale := Stmt.ColumnInt(8);
        F.ColumnPrecision := Stmt.ColumnInt(9);
        F.ColumnType:= ODBCColumnToFieldType(DataType,F.ColumnPrecision,F.ColumnScale);
        FA.Add(F);
      until not Stmt.Step;
      SetLength(Parameters,n);
    finally
      Stmt.Free; // TODBCStatement release
    end;
  except
    on Exception do






>
>







 







|
>


<







 







>
>



|
|
|

|

|
|
|


|
|
|
|
|
|







1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
....
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957

1958
1959
1960
1961
1962
1963
1964
....
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
      status := ODBC.ColumnsA(fStatement,nil,0,pointer(Schema),SQL_NTS,
        pointer(Table),SQL_NTS,nil,0);
      if (status<>SQL_SUCCESS) or (not Step) then begin
        // e.g. driver does not support schema
        DeallocStatement;
        AllocStatement;
        status := ODBC.ColumnsA(fStatement,nil,0,nil,0,pointer(Table),SQL_NTS,nil,0);
        if status=SQL_SUCCESS then
          Step;
      end;
      ODBC.Check(Connection,nil,status,SQL_HANDLE_STMT,fStatement);
      BindColumns;
      FA.Init(TypeInfo(TSQLDBColumnDefineDynArray),Fields,@n);
      FA.Compare := SortDynArrayAnsiStringI; // FA.Find() case insensitive
      fillchar(F,sizeof(F),0);
      if fCurrentRow>0 then // Step done above
................................................................................
    on Exception do ; // just ignore errors here
  end;
end;

procedure TODBCConnectionProperties.GetProcedureParameters(const aProcName: RawUTF8;
  out Parameters: TSQLDBProcColumnDefineDynArray);
var Schema, Package, Proc: RawUTF8;
    P: TSQLDBProcColumnDefine;
    PA: TDynArray;
    n,DataType: integer;
    status: SqlReturn;

    Stmt: TODBCStatement;
begin
  inherited; // first try from SQL, if any (faster)
  if Parameters<>nil then
    exit; // already retrieved directly from engine
  SQLSplitProcedureName(aProcName,Schema,Package,Proc);
  Proc := SynCommons.UpperCase(Proc);
................................................................................
        pointer(Schema),SQL_NTS,pointer(Proc),SQL_NTS,nil,0);
      if (status<>SQL_SUCCESS) or (not Stmt.Step) then begin
        // e.g. driver does not support schema
        Stmt.DeallocStatement;
        Stmt.AllocStatement;
        status := ODBC.SQLProcedureColumnsA(Stmt.fStatement,nil,0,
          nil,0,pointer(Proc),SQL_NTS,nil,0);
        if status=SQL_SUCCESS then
          Stmt.Step;
      end;
      ODBC.Check(Stmt.Connection,nil,status,SQL_HANDLE_STMT,Stmt.fStatement);
      Stmt.BindColumns;
      PA.Init(TypeInfo(TSQLDBColumnDefineDynArray),Parameters,@n);
      fillchar(P,sizeof(P),0);
      if Stmt.fCurrentRow>0 then // Step done above
      repeat
        P.ColumnName := Trim(Stmt.ColumnUTF8(3)); // Column*() should be in order
        case Stmt.ColumnInt(4) of
          SQL_PARAM_INPUT:        P.ColumnParamType := paramIn;
          SQL_PARAM_INPUT_OUTPUT: P.ColumnParamType := paramInOut;
          else                    P.ColumnParamType := paramOut;
        end;
        DataType := Stmt.ColumnInt(5);
        P.ColumnTypeNative := Trim(Stmt.ColumnUTF8(6));
        P.ColumnLength := Stmt.ColumnInt(7);
        P.ColumnScale := Stmt.ColumnInt(8);
        P.ColumnPrecision := Stmt.ColumnInt(9);
        P.ColumnType:= ODBCColumnToFieldType(DataType,P.ColumnPrecision,P.ColumnScale);
        PA.Add(P);
      until not Stmt.Step;
      SetLength(Parameters,n);
    finally
      Stmt.Free; // TODBCStatement release
    end;
  except
    on Exception do

Changes to SynopseCommit.inc.

1
'1.18.2081'
|
1
'1.18.2082'