Page 1 of 1

DBFIELDINFO() Return and optionally change information about a field

Posted: Sun Jul 19, 2020 1:11 am
by AUGE_OHR
hi,

is 3rd. Parameter available under harbour :?:
<expNewSetting> is reserved for CA-Clipper future use.
It can be omitted or specified as NIL.
---

using PgRDD as USRRDD i got Type "U" for all Fields using DbStruct() so i like to change Type
but it is not like MODI STRUC while DBF / SQL-Connection is open.

Re: DBFIELDINFO() Return and optionally change information about a field

Posted: Sun Jul 19, 2020 3:15 am
by danielmaximiliano
Jimmy:
this is what is found in Harbour https://github.com/vszakats/hb/blob/096 ... d53.c#L347

Code: Select all

HB_FUNC( DBFIELDINFO )
{
   AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer();

   if( pArea )
   {
      HB_USHORT uiFields, uiIndex;
      PHB_ITEM pType;

      pType = hb_param( 1, HB_IT_NUMERIC );
      uiIndex = ( HB_FIELDNO ) hb_parni( 2 );
      if( pType && SELF_FIELDCOUNT( pArea, &uiFields ) == HB_SUCCESS &&
          uiIndex > 0 && uiIndex <= uiFields )
      {
         PHB_ITEM pInfo = hb_itemNew( hb_param( 3, HB_IT_ANY ) );

         SELF_FIELDINFO( pArea, uiIndex, ( HB_USHORT ) hb_itemGetNI( pType ), pInfo );
         hb_itemReturnRelease( pInfo );
      }
      else
         hb_errRT_DBCMD( EG_ARG, EDBCMD_DBCMDBADPARAMETER, NULL, HB_ERR_FUNCNAME );
   }
   else
      hb_errRT_DBCMD( EG_NOTABLE, EDBCMD_NOTABLE, NULL, HB_ERR_FUNCNAME );
}

Re: DBFIELDINFO() Return and optionally change information about a field

Posted: Sun Jul 19, 2020 4:49 am
by AUGE_OHR
hi,
danielmaximiliano wrote: Sun Jul 19, 2020 3:15 am this is what is found in Harbour https://github.com/vszakats/hb/blob/096 ... d53.c#L347
thx for Tip.

i can "see" 3rd Parameter

Code: Select all

         PHB_ITEM pInfo = hb_itemNew( hb_param( 3, HB_IT_ANY ) );
so i guess it work ... but how :idea:

Code: Select all

#include "hmg.ch"
#include "Dbstruct.ch"
#include "DbInfo.ch"
#require "hbpgsql"
#require "rddsql"
#command USE <(db)> [VIA <rdd>] [ALIAS <a>] [<nw: NEW>] ;
            [<ex: EXCLUSIVE>] [<sh: SHARED>] [<ro: READONLY>] ;
            [CODEPAGE <cp>] [CONNECTION <nConn>] [INDEX <(index1)> [, <(indexN)>]] => ;
         dbUseArea( <.nw.>, <rdd>, <(db)>, <(a)>, ;
                    if(<.sh.> .or. <.ex.>, !<.ex.>, NIL), <.ro.>,  [<cp>], [<nConn>] ) ;
         [; dbSetIndex( <(index1)> )] ;
         [; dbSetIndex( <(indexN)> )]

   nConnectionHandle := dbPGConnection( cServer + ";" + cDataBase + ";" + cUser + ";" + cPassWord )
   USE "SELECT * FROM TEST ;" ALIAS TESTPG NEW VIA "pgrdd" CONNECTION nConnectionHandle
   ChangeType(1)

Code: Select all

PROCEDURE ChangeType(nWa)
LOCAL aStruct := DBSTRUCT()
LOCAL aWAData := USRRDD_AREADATA(nWa)
LOCAL ii,iMax, cName, nPosi, cType
LOCAL oTPQ, aPG, xRet
ALTD()
   oTPQ := aWAData[1]
   aPG := ACLONE( oTPQ:aStruct )

   iMax := LEN(aStruct)
   FOR ii := 1 TO iMax
      cName := aStruct[ii][DBS_NAME]
      nPosi := ASCAN(aPG, {|e| UPPER(e[1]) = cName } )
      IF nPosi > 0
         cType := aPG[nPosi][2]
         xRet := DbFieldInfo( DBS_TYPE , ii, cType )
      ENDIF
   NEXT

   aStruct := DBSTRUCT()
RETURN
but Type have not change :(