Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / Кирилические названия полей в DB Paradox / 5 сообщений из 5, страница 1 из 1
30.06.2010, 12:43
    #36715103
K@miK@dz@
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Кирилические названия полей в DB Paradox
Короче проблема такая имеются две таблики парадоксовых, имена полей в них русские, TQuery отказывается выполнять запрос с русскими названиями полей(при этом сделал аналоги на Ibase всё проходит на ура). Эти обе таблички надо открыть в связке. Как переименовать поля на латиницу из Delphi? Переименовывать вручную не вариант т.к. это надо будет делать ежемесячно, а кактаться к клиенту каждый раз больно геморойно. Ни каких индексов и ключей в таблицах нет.
форма таблиц:

K_KST_OS.DB
Индекс_издания: Alpha
Индекс_ОС: Alpha
Название_ОС: Alpha
Трактовка: Alpha
Комплектов:Number

K_KAT.DB
Индекс: Alpha
Наименование: Alpha
Периоди4ность: Short
Ед_измер: Short


Как переименовать поля на латиницу из Delphi? Либо как научить Delphi, а именно TQuery понимать кирилические названия полей?

P.S. Дозвонюсь до разработчика программы генерирующей эти файлы, он о себе много нового узнает!!!
...
Рейтинг: 0 / 0
30.06.2010, 13:06
    #36715183
Мимопроходящий
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Кирилические названия полей в DB Paradox
Hello, K@miK@dz@!
You wrote on Wed, 30 Jun 10 09:43:21 GMT:

Kd> Как переименовать поля на латиницу из Delphi?

This example will alter an existing field in a Paradox or dBASE table.
NOTE: You must fill in all options in the ChangeRec with 0 or ''
if the option is not used in the restructure.
FillChar can be used to do this:
Код: plaintext
Fillchar(MyChangeRec, sizeof(MyChangeRec),  0 );

This example uses the following input:

Код: plaintext
ChangeField(Table1, Table1.FieldByName('FOO'), MyChangeRec)

ChangeRec is defined as follows:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
 type 

  ChangeRec =  packed   record 
    szName: DBINAME;
    iType: Word;
    iSubType: Word;
    iLength: Word;
    iPrecision: Byte;
   end ;

The function is defined as follows:

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
 procedure  ChangeField(Table: TTable; Field: TField; Rec: ChangeRec);
 var 
  Props: CURProps;
  hDb: hDBIDb;
  TableDesc: CRTblDesc;
  pFields: pFLDDesc;
  pOp: pCROpType;
  B: Byte;
 begin 
   // Initialize the pointers... 
  pFields :=  nil ;
  pOp :=  nil ;
   // Make sure the table is open exclusively so we can get the db handle... 
   if   not  Table.Active  then 
     raise  EDatabaseError.Create('Table must be opened to restructure');
   if   not  Table.Exclusive  then 
     raise  EDatabaseError.Create('Table must be opened exclusively to restructure');
  Check(DbiSetProp(hDBIObj(Table.Handle), curxltMODE, Integer(xltNONE)));
   // Get the table properties to determine table type... 
  Check(DbiGetCursorProps(Table.Handle, Props));
   // Make sure the table is either Paradox or dBASE... 
   if  (Props.szTableType <> szPARADOX)  and  (Props.szTableType <> szDBASE)  then 
     raise  EDatabaseError.Create('Field altering can only occur on Paradox or dBASE tables');

   // Allocate memory for the field descriptor... 
  pFields := AllocMem(Table.FieldCount * sizeof(FLDDesc));
   // Allocate memory for the operation descriptor... 
  pOp := AllocMem(Table.FieldCount * sizeof(CROpType));
   try 
     // Set the pointer to the index in the operation descriptor to put 
     // crMODIFY (This means a modification to the record is going to happen)... 
    Inc(pOp, Field.Index);
    pOp^ := crMODIFY;
    Dec(pOp, Field.Index);
     // Fill the field descriptor with the existing field information... 

    Check(DbiGetFieldDescs(Table.Handle, pFields));
     // Set the pointer to the index in the field descriptor to make the 
     // midifications to the field 
    Inc(pFields, Field.Index);
     // If the szName portion of the ChangeRec has something in it, change it... 
     if  (Length(Rec.szName) >  0 )  then 
      pFields^.szName := Rec.szName;
     // If the iType portion of the ChangeRec has something in it, change it... 
     if  (Rec.iType >  0 )  then 

      pFields^.iFldType := Rec.iType;
     // If the iSubType portion of the ChangeRec has something in it, change it... 
     if  (Rec.iSubType >  0 )  then 
      pFields^.iSubType := Rec.iSubType;
     // If the iLength portion of the ChangeRec has something in it, change it... 
     if  (Rec.iLength >  0 )  then 
      pFields^.iUnits1 := Rec.iLength;
     // If the iPrecision portion of the ChangeRec has something 
     // in it, change it... 
     if  (Rec.iPrecision >  0 )  then 

      pFields^.iUnits2 := Rec.iPrecision;
    Dec(pFields, Field.Index); 
     for  B :=  1   to  Table.FieldCount  do   begin 
      pFields^.iFldNum := B;
      Inc(pFields,  1 );
     end ;
    Dec(pFields, Table.FieldCount);
                          
     // Blank out the structure... 
    FillChar(TableDesc, sizeof(TableDesc), # 0 );
     //  Get the database handle from the table's cursor handle... 
    Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE, hDBIObj(hDb)));

     // Put the table name in the table descriptor... 
    StrPCopy(TableDesc.szTblName, Table.TableName);
     // Put the table type in the table descriptor... 
    StrPCopy(TableDesc.szTblType, Props.szTableType);
     // The following three lines are necessary when doing any field restructure 
     // operations on a table... 
     
     // Set the field count for the table 
    TableDesc.iFldCount := Table.FieldCount;
     // Link the operation descriptor to the table descriptor... 

    TableDesc.pecrFldOp := pOp;
     // Link the field descriptor to the table descriptor... 
    TableDesc.pFldDesc := pFields;
     // Close the table so the restructure can complete... 
    Table.Close;
     // Call DbiDoRestructure... 
    Check(DbiDoRestructure(hDb,  1 , @TableDesc,  nil ,  nil ,  nil , False));
   finally 
     if  (pFields <>  nil )  then 
      FreeMem(pFields);
     if  (pOp <>  nil )  then 
      FreeMem(pOp);
   end ;
 end ;

--
With best regards, Мимопроходящий.
...
Рейтинг: 0 / 0
30.06.2010, 14:25
    #36715515
K@miK@dz@
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Кирилические названия полей в DB Paradox
Мимопроходящий,

Что - то я не пойму, как это работает
...
Рейтинг: 0 / 0
30.06.2010, 14:29
    #36715532
Мимопроходящий
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Кирилические названия полей в DB Paradox
Hello, K@miK@dz@!
You wrote on Wed, 30 Jun 10 11:25:02 GMT:

K@miK@dz@ Kd> Что - то я не пойму, как это работаетнайми того, кто понимает.

--
With best regards, Мимопроходящий.

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
05.07.2010, 12:31
    #36723096
Prd
Prd
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Кирилические названия полей в DB Paradox
Использовать кавычки. Н-р:
SELECT
T."Индекс_издания",
T."Индекс_ОС",
...
FROM
"K_KST_OS.DB" T
...
...
Рейтинг: 0 / 0
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / Кирилические названия полей в DB Paradox / 5 сообщений из 5, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]