#18 Problem with the function MetaPrimaryKeys in Firebird 1.5.2

closed-later
nobody
None
5
2005-05-19
2005-03-31
Anonymous
No

When the primary key of the table it is created with
some constraint as for instance:

ALTER TABLE XXXY ADD CONSTRAINT PK_XXXY PRIMARY KEY
(ID_XXXY);

The function MetaPrimaryKeys doesn't work!

My config: Windows XP PRO BR SP1, Firebird 1.5.2,
Apache/1.3.29 (Win32) PHP/4.3.6, Adodb 4.60

djalmafilho@gmail.com

Discussion

  • Fuinion
    Fuinion
    2005-04-11

    Logged In: YES
    user_id=1251115

    Hi:
    I'm fuinion.
    Change this sql
    $sql = 'SELECT S.RDB$FIELD_NAME AFIELDNAME
    FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON
    I.RDB$INDEX_NAME=S.RDB$INDEX_NAME
    WHERE I.RDB$RELATION_NAME=\''.$table.'\' and
    I.RDB$INDEX_NAME like \'RDB$PRIMARY%\'
    ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION';

    in adodb-ibase.inc.php in drivers directory, for this sql

    $sql = "SELECT RDB\$FIELD_NAME";
    $sql .= " FROM RDB\$RELATION_CONSTRAINTS INNER JOIN
    RDB\$INDEX_SEGMENTS ON (RDB\$INDEX_SEGMENTS.RDB\$INDEX_NAME
    = RDB\$RELATION_CONSTRAINTS.RDB\$INDEX_NAME)";
    $sql .= " WHERE
    RDB\$RELATION_CONSTRAINTS.RDB\$RELATION_NAME = '" . $table .
    "'";
    $sql .= " AND
    RDB\$RELATION_CONSTRAINTS.RDB\$CONSTRAINT_TYPE = 'PRIMARY KEY'";
    $sql .= " ORDER BY
    RDB\$RELATION_CONSTRAINTS.RDB\$INDEX_NAME,
    RDB\$INDEX_SEGMENTS.RDB\$FIELD_POSITION";

    And this do the magic for you

     
  • John Lim
    John Lim
    2005-05-19

    • status: open --> closed-later
     
  • John Lim
    John Lim
    2005-05-19

    Logged In: YES
    user_id=724867

    Kindly supply a patch.