Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
MicroStation
  • Product Communities
  • More
MicroStation
MicroStation Wiki Unleashing Database Linkages In MicroStation [CS]
    • Sign in

    • -MicroStation Wiki
      • +Learning Tips
      • -MicroStation
        • +3D Printing - MicroStation
        • +Animation - MicroStation
        • +Archive / Backup - MicroStation
        • +Base Geometry - MicroStation
        • +Batch Processing - MicroStation
        • +CONNECT Advisor - MicroStation
        • CONNECT Integration - MicroStation
        • +CONNECTION Client
        • +Cells - MicroStation
        • +Change Tracking - MicroStation
        • +Configuration - MicroStation
        • +Coordinate Systems - MicroStation
        • +Curves - MicroStation
        • +Custom Linestyles - MicroStation
        • +DGN - MicroStation
        • +DWG - MicroStation
        • -Database - MicroStation
          • +Access - Database - MicroStation
          • -General - Database - MicroStation
            • Inability to connect to database from ProjectWise Managed Workspace session: _USTN_DATABASE
            • MicroStation CONNECT Supported Databases
            • MicroStation V8 2004 Supported Databases [FAQ]
            • MicroStation V8 XM Supported Databases [FAQ]
            • MicroStation V8i Supported Databases [FAQ]
            • Unable to Fill a Shape 'Type 6' that has DMRS Linkages
            • Unleashing Database Linkages In MicroStation [CS]
            • Verify Linkages dialog appears every time I start MicroStation
            • Working With Displayable Attributes [CS]
          • Informix - Database - MicroStation
          • +ODBC - Database - MicroStation
          • +Oracle - Database - MicroStation
          • RIS - Database - MicroStation
          • Sybase - Database - MicroStation
          • +VSQL - Database - MicroStation
          • Xbase - Database - MicroStation
        • +Detailing Symbols - MicroStation
        • +Dimensions - MicroStation
        • +Documentation & Help - MicroStation
        • +Drawing Aids - MicroStation
        • +Exception - MicroStation
        • +FAQ - MicroStation
        • +Feature Based Solids Modeling - MicroStation
        • +File Access - MicroStation
        • +GUI - MicroStation
        • +General - MicroStation
        • +Graphics Display - MicroStation
        • +Groups - MicroStation
        • +Hardware / Input Devices - MicroStation
        • +Import/Export - MicroStation
        • +Installation - MicroStation
        • +Interchange - MicroStation
        • +Interference - MicroStation
        • +Internationalization - MicroStation
        • +Levels - MicroStation
        • +Licensing - MicroStation
        • +Manipulation - MicroStation
        • +Markup / Redline - MicroStation
        • +Measure - MicroStation
        • +Mesh - MicroStation
        • +Models - MicroStation
        • +Multi-Lines - MicroStation
        • +OLE - MicroStation
        • +Other - MicroStation
        • +Parametrics - MicroStation
        • +Patterning - MicroStation
        • +Point Cloud - MicroStation
        • +Printing - MicroStation
        • +Programming - MicroStation
        • +Project Navigation - MicroStation
        • +Properties - MicroStation
        • +RSS Feeds - MicroStation
        • +Reference - MicroStation
        • +Security - MicroStation
        • +Selection - MicroStation
        • +Settings - MicroStation
        • +Sheet Composition - MicroStation
        • +Solids - MicroStation
        • +Standards - MicroStation
        • +Surfaces - MicroStation
        • +Tables - MicroStation
        • +Text - MicroStation
        • +UI Customization - MicroStation
        • +Units - MicroStation
        • +View - MicroStation
        • +Visualization - MicroStation
        • Welcome Page - MicroStation
        • +Accreditation - MicroStation
        • +i.Models - MicroStation
        • +ProjectWise Integration
        • +Raster - MicroStation
    • +Administration Wiki
    • +Annotations Wiki
    • +Bentley View Wiki
    • +MicroStation PowerDraft
    • +Programming Wiki
    • +Visualization Wiki

     
     Questions about this article, topic, or product? Click here. 

    Unleashing Database Linkages In MicroStation [CS]


      

    This Client Server article is republished in its entirety from 2002 for reference purposes.

    By By Kees van Prooijen, Support Manager, Geographic Applications Bentley Hoofddorp
    13 February 2002

    MicroStation makes it possible to link elements with database records. For every database linkage, a few words are added to an element, in the form of an entity number and a mslink number. The entity number refers to a database table. The number is cross-referenced with the table name in the Mscatalog table. The mslink number refers to the record in a table. It is stored in the Mslink column and is unique per table.


    Figure 1: Entity and Mslink number

    Beside an entity and mslink number, (Figure 1) a linkage contains more information. To reach this additional information, key-in Analyze or select the Information icon from the Primary toolbox and then select the graphic element. Scroll the vertical bar until you see the database linkages in the dialog.

    The linkages can be represented in an eight-word format (following the format used in ODBC, Oracle, Informix and other database management software). The eight-word (or two-byte) format contains the entity number in the fourth word and the mslink in the fifth and sixth words (see Figure 2).

    Using older versions of MicroStation, linkages of four-word format (the DMRS format) might occur. The four-word format contains the entity number in the second word, the mslink in the third word, and the high order byte in the fourth word (see Figure 3).


    Figure 2: ODBC Data Linkage Example (using the Analyze tool of MicroStation V8)

    The database linkages are represented as hexadecimal numbers and must be converted to decimal prior to using the numbers to perform SQL queries on the database. This can be accomplished using a scientific calculator, as illustrated in Figure 7.

    Eight-word format for database linkage

    The first word of the eight-word data linkage contains the following information:
    4 bits with: I The linkage is informational ("read-only") or non-informational ("read/write")
    R Remote linkage ID
    M Indicates linkage has been modified
    U Linkage is a user data linkage and the Linkage Class (4 bits) and the Type (8 bits).


    In practice only the I-bit is used to determine whether the linkage is informational or not. Possible values are:

    9007-Indicates that the linkage is informational (read-only).
    1007-Indicates that the linkage is non-informational (read-write).

    Figure 3: DMRS Linkage Example (using the Analyze tool of MicroStation V7)

    The second word indicates the type of database linkage (ODBC, RIS, Oracle, Informix, etc.). Predefined types are:

    6091-Oracle
    1971-dBASE (or Xbase)
    3948-Informix
    3A77-Ingres
    4F58-Sybase
    5E62-ODBC
    71FB-RIS (Used in the example shown in Figures 1 and 2.)


    The third word is a secondary ID that is not used and will always be 0F81.

    The fourth word is the entity number value in the mscatalog table. For example.


    Figure 4: Database Setting

    0002 (decimal 2) and 00012 (decimal 18)-The values of the entitynum column in the mscatalog table for the user tables.

    select * from mscatalog where entitynum = 2
    select * from mscatalog where entitynum = 18

    The fifth and sixth words are used for the mslink value of the user attribute table. Swap the order of the fifth and sixth columns to get the hexadecimal number. For example:

    009C 0000-In this example 9C forms the hexadecimal number for the mslink number 156 in decimal.

    select * from where mslink = 156

    3501 000C-Precede 3501 with a C to form the hexadecimal number C3501, which converts to a decimal number of 800001.

    select * from

    where mslink = 800001


    Figure 5: Results of the command Last Attribute

    After converting hexadecimal numbers to decimal using a scientific calculator and combining the fifth or sixth word, the mslink number can be used to perform SQL queries on the database.

    The seventh and eighth words are used for the dastype or displayable attribute number from the corresponding displayable attribute table (DAS) table. The dastype is a number assigned to a specific SQL statement contained in a DAS table.

    Four-word format for database linkage

    As with the eight-word format, the first word in the four-word format indicates whether the linkage is read/write or read only (Figure 3).

    8000 (32768 decimal)-Indicates that the linkage is informational.
    0000 (0 decimal) Indicates that the linkage is non-informational.

    The second word represents the entity number value in the mscatalog table.

    0004 (4 decimal) and 07D0 (2000 decimal)-The entitynum column has a value of 4 and 2000 in the mscatalog table.

    select * from mscatalog where entitynum = 4
    select * from mscatalog where entitynum = 2000


    Figure 6: Results of the command GeoScripts Show_dblinks

    The third word and high order byte of the fourth word are used for mslink values in the table specified in the second word. For example:

    OD42 0103-In this example, precede OD42 with a 03 (the high order byte of the forth word) to form the hexadecimal number 30D42 which converts to a decimal number of 200002

    select * from

    where mslink =200002  

    Range of valid mslink values

    With the eight-word format, four bytes are available for storing the mslink number: 232 = 0 - 4,294,967,295.

    With the four-word format, three bytes are available for storing the mslink number: 224 = 0 - 16,777,215.

    Creating Informational linkage

    An informational linkage is created when the Linkage Mode is set to Informational in the database dialog. The dialog is opened from MicroStation's pull-down menu by going to Settings > Database.


    Figure 7: Scientific Calculator

    When an element with an informational linkage is copied, the new element will be linked to the same record in the database. A new record will be not created. However, when an element with a non-informational linkage is copied, the Linkage Mode controls whether an existing record is used or a new record is created. When set to New, all columns from the record linked to the original element are copied and a new Mslink is generated for the new element.

    Controlling the database linkage type

    The MicroStation and MicroStation GeoGraphics database tools supports a number of database linkage types (Figure 4). The linkage type identifies what database server was used to generate the linkages. The linkage type for newly created linkages is controlled by the MS_LINKTYPE variable. This variable is set in the [database].cfg . The files are located in the

    \Bentley\Program\MicroStation\config\database\ directory. An example of this variable setting is:

    MS_LINKTYPE = ORACLE
    MS_LINKTYPE > ODBC
    MS_LINKTYPE > DMRS
    MS_LINKTYPE > XBASE
    MS_LINKTYPE > IX
    MS_LINKTYPE > RIS

    When copying elements with 4 word DMRS linkages an 8 word linkage will be created (assuming the current linkage type is not DMRS).

    Tools on DeveloperWare

    In the DeveloperWare section of Select Services Online (selectservices.bentley.com/index.htm) several examples in both MDL and MicroStation BASIC are available to reformat a database linkage. The utilities include:

    Chgent.bas Changes the entity number of a database linkage of an element.

    CgDbLn.ma and Chgelnk.bas Changes the type of database linkage of existing graphic elements.

    Infolink.bas Sets the database linkage type to non-informational.

    Additional MicroStation GeoGraphics tools

    For those who are using MicroStation GeoGraphics, some additional tools are available for working with attached database linkages. They are:

    List Attributes-A key-in that shows the linkage with entity and mslink number (Figure 5).

    GeoScripts Show_dblinks-A key-in available when GeoSELECTools is installed (Figure 6).

    Note that the MicroStation GeoGraphics features are always informational. When you copy a featurized element, the record in the feature table is not copied.

    The macro Infolink.bas available on the DeveloperWare section of SelectServices Online checks whether feature linkages are informational and sets them to informational if needed. The macro Featrpt.bas creates a report of all features in a DGN file.

    Converting hexadecimal numbers to decimal

    A calculator can be opened from the Windows menu bar by going to Program > Accessories. You can use one of the electronic calculators in scientific mode to convert hexadecimal to decimal. Select Hex and key in the hexadecimal number. Then select Dec to convert the hexadecimal number to decimal.

    See Also

    Client Server Archive

    MicroStation Desktop TechNotes and FAQs

    Comments or Corrections?

    Bentley's Technical Support Group requests that you please confine any comments you have on this Wiki entry to this "Comments or Corrections?" section. THANK YOU!

    • client server 2002
    • Archived Client Server
    • client server
    • Share
    • History
    • More
    • Cancel
    • Elisa McGraw Created by Elisa McGraw
    • When: Mon, Jul 13 2009 4:26 PM
    • Leonard Jones Last revision by Bentley Colleague Leonard Jones
    • When: Mon, Mar 30 2020 5:07 AM
    • Revisions: 19
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies