You are on page 1of 51

GXpublic 9.

0 Manual

December 2005

INTRODUCTION ...................................................................................................................... 5 TECHNOLOGY .............................................................................................................................. 5 USEFULNESS ............................................................................................................................... 5 INSTALLATION AND REQUIREMENTS............................................................................ 6 CONNECTION ........................................................................................................................... 6 GUIDE ......................................................................................................................................... 6 GXPUBLICFACTORY ..................................................................................................................... 7 TABLES ....................................................................................................................................... 7 TABLE: MODEL ............................................................................................................................ 7 TABLE: OBJECT ........................................................................................................................... 8 TABLE: TABLE ............................................................................................................................. 9 TABLE: INDEX ........................................................................................................................... 10 TABLE: IDXATT ........................................................................................................................... 10 TABLE: ATTRIBUTE .................................................................................................................... 11 TABLE: ATTPROP ...................................................................................................................... 11 TABLE: FORMULA ...................................................................................................................... 12 TABLE: TRNSTRUCTURE ............................................................................................................ 13 TABLE: TRNLVL ......................................................................................................................... 14 TABLE: TBLATT ......................................................................................................................... 15 TABLE: GROUP .......................................................................................................................... 15 TABLE: GRPATT ........................................................................................................................ 15 TABLE: VARIABLE ...................................................................................................................... 15 TABLE: DOMAIN ........................................................................................................................ 16 TABLE: DOMPROP ..................................................................................................................... 17 TABLE: TBLSUBOR .................................................................................................................... 17 TABLE: TBLSUBBY .................................................................................................................... 17 TABLE: TBLEXTENDED............................................................................................................... 17 TABLE: DVATT ......................................................................................................................... 18 TABLE: DVPLAT ........................................................................................................................ 18 TABLE: DVIDXPLAT .................................................................................................................. 19 TABLE: CROSSREF .................................................................................................................... 19 TABLE: OBJSOURCE .................................................................................................................. 20 TABLE: OBJFORM ...................................................................................................................... 22 TABLE: OBJPROP ...................................................................................................................... 23 TABLE: PROPERTY ..................................................................................................................... 24 TABLE: FORMCLASS .................................................................................................................. 25 TABLE: GENERATOR .................................................................................................................. 25 TABLE: MSTYLE ......................................................................................................................... 25 TABLE: KBPROP ........................................................................................................................ 26 TABLE: MESSAGE ...................................................................................................................... 26 TABLE: TRANSLATION ............................................................................................................... 26 STATEMENTS.......................................................................................................................... 27 DELETE ..................................................................................................................................... 27 OBJECTS ................................................................................................................................... 27 SUBTYPE GROUP ....................................................................................................................... 27 DOMAIN .................................................................................................................................... 27 ATTRIBUTE ................................................................................................................................ 27 INDEXES ................................................................................................................................... 27 UPDATE ..................................................................................................................................... 27 OBJECTS ................................................................................................................................... 27 DOMAIN .................................................................................................................................... 28 ATTRIBUTE ................................................................................................................................ 28

COMMANDS............................................................................................................................. 29 WITH CLAUSE............................................................................................................................ 29 SPECIFY AND GENERATE ....................................................................................................... 29 SPECIFY .................................................................................................................................... 29 Properties ........................................................................................................................... 29 Syntax................................................................................................................................. 29 Output ................................................................................................................................. 31 With Clause........................................................................................................................ 31 DISTRIBUTION AND CONSOLIDATION ....................................................................... 31 DISTRIBUTE .............................................................................................................................. 31 Properties ........................................................................................................................... 32 Syntax................................................................................................................................. 32 Output ................................................................................................................................. 33 With Clause....................................................................................................................... 33 Example.............................................................................................................................. 33 CONSOLIDATE ........................................................................................................................... 34 Syntax................................................................................................................................. 34 Output ................................................................................................................................. 34 With Clause....................................................................................................................... 34 Mapfile................................................................................................................................. 34 MakeBackup....................................................................................................................... 35 IMPACT..................................................................................................................................... 35 UPDATE MODEL .......................................................................................................................... 35 CREATE KB ............................................................................................................................... 35 CREATE MODEL ......................................................................................................................... 35 IMPACT ANALYSIS ...................................................................................................................... 36 GENERATE REORG ..................................................................................................................... 36 GENERATE CREATE DB .............................................................................................................. 37 COPY MODEL ............................................................................................................................. 37 LIST........................................................................................................................................... 37 CONVERT KB ............................................................................................................................ 37 COMPILE ................................................................................................................................... 38 GENERATE HELP ........................................................................................................................ 39 IMPORT HELP ............................................................................................................................ 39 IMPORT WSDL ........................................................................................................................... 39 APPENDIX ............................................................................................................................... 39 ROWSET .................................................................................................................................... 39 Rowset 1 .............................................................................................................................. 39 Rowset 2 .............................................................................................................................. 39 EXTENSIN TO SELECT * .......................................................................................................... 40 GXSERVICE .............................................................................................................................. 40 Functions for GXService interface ....................................................................................... 41 CopyKB ............................................................................................................................... 41 OLE DB PROVIDER .................................................................................................................... 42 PROGRAMMING WITH GXPUBLIC ................................................................................................ 43 With GeneXus ...................................................................................................................... 43 With VB (or VFP) via ADO ................................................................................................... 44 CONNECT METHOD GXPUBLIC FACTORY................................................................................. 47 CONNECTIONSTRING METHOD GXPUBLIC FACTORY ............................................................... 48 WRITING A GXPUBLIC TABLE..................................................................................................... 49 Attprop................................................................................................................................ 49 Objprop............................................................................................................................... 50 DYNQ AND SERVICES ................................................................................................................ 50

CRASH REPORT ......................................................................................................................... 51

Introduction
GXpublic shows and publishes the information of a GeneXus KB. For this, it provides the following: -It shows and allows modifying information on the GeneXus objects. Models Objects (Data, Properties, Events, Methods, Rules, Help) Attributes Indexes Transactions, Indexes Structures Formulas Tables References between objects, attributes Groups, domains Screens - It allows accessing services to be applied on a KB (or a KB element), which enables to perform the full cycle Perform Impact Database. Execute the reorganization (update model). Cause all programs to be specified and generated. Transfer them and cause them to be compiled.

Technology
GXpublic is a Dynamic Link Library (DLL) containing an OLE DB Provider (ADO) that allows publishing in tabular form the information and the access to the services. The Knowledge Base becomes a DataSource, which has a group of tables where the KB information is saved and a group of commands to access the services. There are two ways to access the provider - Programming in GeneXus - programming in native languages (Visual Basic, Visual FoxPro, JAVA, .NET)

Usefulness
In GeneXus, one of the best ways of obtaining a list of the objects header is checking the Folder view. It contains the object name, description, type and modification date. Nevertheless, several times there is more information required, such as the specification date, the object-associated style, the generator where the object will be generated, etc. All this extra information can be seen, although not in tabular form, from the call browser. This mechanism is useful in many cases, but problems may arise when you want to obtain documentation with a specific format of the data contained in the KB, such as when you want an Excel spreadsheet with all the objects belonging to the application core. Even more complex is to make queries such as: what is the table that has more attributes? or what of the attributes do not have domain?, etc. We may enumerate a group of possible applications/tools to be developed with GXpublic, such as:

-Customized Documentation you can access a knowledge base and withdraw valuable information on models, objects and attributes and, with this information, you can create a knowledge base documentation in the desired format (e.g.: Excel spreadsheets, Word documents, etc.). - Handling of Knowledge Bases versions. - Specific Queries to withdraw specific characteristics of a Knowledge Base Attributes without domain. Transaction structures. Lists of objects that were modified after a specific date. Objects data. Obtaining folder structure; e.g.: to show it in tree View. Formula attributes. Checking for possible problems; e.g.: if a subtype and supertype are in the same transactions. - Subordinated Tables - It is possible to perform table charts. - Being able to execute the FullCycle To continue enumerating possibilities is somewhat redundant as we have the tables structure available; to know whether a specific query can be answered you must just check if the information exists in some table.

Installation and requirements


Once the Setup has been installed, you can install all the files required so that GXpublic can work at: <CommonFilesFolder>\Artech\GXPublic 90 As from this version, all the GXpublic version (9.0, 8.0 and 7.5) are distributed in a single setup. To be able to use all the features provided by GXpublic you must have installed the Microsoft Data Access Components (MDAC) version 2.6 or higher These documents are installed by Visual Studio 6.0 Service pack 5. You can also obtain them at http://www.microsoft.com/data Updates: The versions updates are numerated with the 9.X.Z nomenclature: X corresponds to version 9.0 update and Z to version 8.0 updates. E.g.: 9.1.0 corresponds to the first update of the 9.0 version from the release and, in this case, GXpublic 8.0 version was not updated.

Connection
Guide
The class string is GXPublic.GXPublic.5. E.g.: you may open a KB with Cnn.Open(Provider=GXPublic.GXPublic.4) Therefore, if you have the following code: Cnn.Open(Provider=GXPublic.GXPublic.4)

You must change it to: Cnn.Open(Provider=GXPublic.GXPublic.5) This will allow coexistence with previous GXpublic versions (1.0, 7.0, 7.5 y 8.0). Anyway, you may execute the last version by naming the provider as GXPublic.GXPublic (without any version number).

GXpublicFactory
There is a top tier over GXpublic ADO connection. It allows determining with what version you can open the Knowledge Base. The idea is using this to open the KB without having the information of what GX version is in your KB. You will open the Knowledge Base with highest possible version, following the table below: Knowledge Base Version GeneXus 9.0 GeneXus 8.0 GeneXus 7.5 GeneXus 7.0 GeneXus 6.1 GXPublic Version GXPublic 9.0 GXPublic 8.0 GXPublic 7.5 GXPublic 7.5 GXPublic 7.5

Important: This means that, for Knowledge bases previous to 8.0, if you must use a version previous to GXpublic 8.0, you must specify the version number. An example of this is when you use objects distribution and consolidation; in this case, you must keep the Knowledge Base version; otherwise, you would be converting the objects to the Knowledge Base version. Nuevo Class string of the object: "GXPublicFactory.ConnectionFactory" This implies a new connect method similar to open.

Tables
Table: Model
Information of the models of a KB MdlId * MdlNam MdlPath MdlReorgTS MdlAttLen Identifies a model within the KB Model Name Model Path Date and time of last reorganization. Quantity of significant characters in the name of attributes. Quantity of significant Integer String (largo 30) String (largo 30) DATE Integer

MdlTblLen

Integer

characters in the name of tables, indexes and data views. MdlObjLen Quantity of significant characters in the name of GX objects. Date of the last modification made to the model Date the last table was modified Integer

MdlUpdTS MdlTblUpdTS

Date Date

Table: Object
Information of the models of a KB MdlId* ObjCls* ObjId* ObjNam ObjOwner ObjDsc ObjTyp ObjMainGen ObjCreTS ObjUpdTS ObjSpcTS ObjSty ObjTblAssc ObjConsTS Object type. Object identifier. Object name Id of the folder where the object is located. Object description. Object type (DW). Id of the associated Generator if the object is main (0 if it is not main). Object creation. Date of object modification. Date of object specification (Null if there is no specification). Id of the object-associated style (0 if there is no associated style). Id of associated table (0 if there is no table or if it does not apply) Consolidation date Integer Integer (enumerated) Integer String (largo 30) Integer String (largo 30) Integer (enumerated) Integer DATE DATE DATE Integer Integer Date

The possible values for ObjCls are: transaction procedure report menu work panel data view table folder prompt web panel TRN = 0 PRC = 1 RPT = 2 MNU = 3 WKP = 4 DV = 6 TBL = 7 FLD = 8 PMT = 12 WBP = 13

external program menu bar transaction style procedure style report style work panel style prompt style web panel style menu bar style theme structure data type Language

XPG = 14 MBR = 17 STRN = 18 SPRC = 19 SRPT = 20 SWKP = 21 SPMT = 22 SWBP = 23 SMBR = 24 THM = 25 SDT = 26 LNG = 28

ObjCls = 5 represents the attributes. They do not appear in this table but in Attributes. They may be referred to from the Crossref table. Likewise, the values: model MDL = 9 group GRP = 10 domain DOM = 11 they appear as valid ObjCls, for example, in the consolidation output.

The possible values for ObjTyp are: fact table dimension DWH = 2 DIM = 4

The value for every identifier is an integer number higher than zero. ObjUpdTS, ObjCreTS and ObjSpcTS fields are TimeStamps (hence the suffix). They have time and date. In VB, these fields can be directly assigned to a VB DATE type field. In VFP, this field must be stored in a datetime type variable. This value may be transferred to a string using the ttoc function of VFP. The null date is 1899-12-30 00:00:00. Tne ObjTblAsoc field is only applied when the object is a Data View. The possible values for ObjMainGen are: Default Reorg Name 1 2 3

The environments defined by the user in the model are defined from Name.

Table: Table
Information of the tables of a KB You must instantiate the model. MdlId* TblId* Identifier Integer Integer

TblNam TblDsc

Name Description

String String 30) (length:

Table: Index
Information of the indexes of a KB The indexes of a KB may belong to a table or a Data View. MdlId* ObjCls* ObjId* IdxId* IdxNam IdxTyp IdxSrc Identifier Name Type System | User Class (it may be table or DV ) Integer Integer (enumerated) Integer Integer String Integer (enumerated) Integer (enumerated)

The possible values for IdxTyp are: Unique Duplicated GX_UNIQUE = 1 GX_DUPLICATE = 2

The possible values for IdxSrc are: Automatic GX_AUTO = 1 User GX_USER = 2 When the index belongs to a Data View this field value is GX_USER.

Table: IdxAtt
Composition of indexes MdlId* ObjCls* ObjId* IdxId* IdxPos* AttId IdxOrder Position Attribute Order (1=Asc.,0=Desc.) Integer Integer Integer Integer Integer Integer Integer (enumerated)

The possible values for IdxOrder are: Ascending Descending GX_ASC = 1 GX_DESC = 0

Table: Attribute
Information of the attributes of a KB MdlId* AttId* AttNam AttDsc AttTyp AttCls AttLen AttDec AttRng AttSign AttPic AttDom Identifier Name Description Attribute type Attribute class Length Decimal Range Sign Picture Domain it is associated to (0 if it has no associated domain) Id of supertype (0 if it has no supertype) Modification date Formula Attribute Integer Integer String String (length: 30) Integer (enumerated) Integer (enumerated) Integer Integer String (length: 80) Integer String (length: 30) Integer

AttIdSup AttUpdTS AttFrml

Integer Date String

The possible values for AttTyp are: Integer Character Date LongVarChar DateTime VarChar Blob GX_INT = 4 GX_CHAR = 5 GX_DATE = 6 GX_LONGVARCHAR = 8 GX_DATETIME = 12 GX_VARCHAR = 13 GX_BLOB = 14

The possible values for AttCls are: Primary Secondary Inferred Vertical Formula Horizontal Formula GX_PRI_CLASS = 1 GX_SEC_CLASS = 2 GX_INF_CLASS = 3 GX_VERTICAL = 4 GX_HORIZONTAL = 5

Table: AttProp
Information of the properties of a KB attributes MdlId* AttId* Identifier Integer Integer

PropId* PropValue

Identifier Property value

String String (length: 30)

The attribute must be instantiated (AttId) Each attribute property match with one PropId Value. E.g. Propiedad Title Column Title Initial Value PropId HORIZONTAL_DESCRIPTION VERTICAL_DESCRIPTION ATT_INITIAL_VALUE

Table: Formula
Information of the formulas of a KB MdlId* AttId* FmlPos* FmlTknTyp FmlTknVal FmlTknObjCls FmlTknObjId token position in the formula token type token value Class if the toke is ATT or OBJ type Object Id if the token is ATT or OBJ type Integer Integer Integer Integer (enumerated) String (Length: 30) Integer (enumerated) Integer

Formulas are considered as a group of tokes. Each one of these tokens has a specific type, which is stored in FmlTknTyp and may take the following values: Open parenthesis GXOB = 0 Call a function GXFN = 1 Attribute name GXNA, = 2 Constant name GXNC, = 3 Closes parenthesis GXCB,= 4 Operator +, GXPL,= 5 Operator *,/ GXPR, = 6 Comma separator GXCM, = 7 NOT GXNT = 8 AND OR GXAN,= 9 Relational oper. GXRE, = 10 Expression GXEXP, = 11 Sum GXSUM,= 12 Count GXCOU, = 13 Average GXAVE, = 14 Maximum GXMAX,= 15 Minimum GXMIN, = 16 IF ... GXIF, = 17 Semicolon GXSC, = 18 Otherwise GXOT, = 19 Error GXERR_TOKEN = 20 EOExpression GXEN, = 21 Comment GXCO, = 22

User Variable (&) for rules/commands User Variable Array '&xx(' CoNtinuation Line String to replace '&' with '&&' CLass id used for calls Object Id used for calls ConTrol ID/Name Control Type Id Control ID/Name

GXUV, = 23 GXUA, = 24 GXCN, = 25 GXAM, = 26 GXOCL, = 27 GXOI, = 28 GXCT, = 29 GXCI, = 30 GXFMT = 31

SUM(CliSubTot) is a formula made up by 3 tokens SUM( literal type, CliSubTot ATT type and ) literal. Therefore, the second token is saved in FmlTknObjCls, which is an ATT, and the ATT id is saved in FmlTknObjId. The value of literal tokens is obtained in the FmlTknVal field.

Table: TrnStructure
Information of the structure of a transaction MdlId* TrnId* TrnLvlId* TrnItmTyp* TrnItmId* Level ID Item type (att or level) Id of att or level, depending on the Item type If the item is an attribute, it indicates if it is ( with an *) Integer Integer Integer Integer (enumerated) Integer

TrnItmIskey

Integer

How do you save information in this table? Lets say that we have the following transaction: A* B (C* (D* E) ) F (G* H) To save the information in the table, you consider that a transaction level is a group of Items where each Item may be a level or an attribute. Therefore, the first level of the transaction may be seen as follows: A* B (Level 2) F (Level 4)

Level 2 as follows: C* (Level 3) Level 3 as follows: D* E Therefore, we will have the following in the table: MdlId , TrnId, 1, ATT, IdA MdlId, TrnId, 1, ATT, IdB MdlId, TrnId, 1, LVL, IdLvl2 MdlId, TrnId, 1, ATT, IdF MdlId, TrnId, 1, LVL, idLvl4 MdlId, TrnId, 2,ATT, idC MdlId, TrnId, 2, LVL, idLvl3 .. The possible values of TrnItmTyp are: Level Attribute ITM_LEVEL = 0 ITM_ATT = 1

The order of the table records is lineal instead of by primary key. In the example, we would have the following: A, B, LVL2, C, LVL3, D, E, F, LVL4, G, H; i.e.: MdlId , TrnId, 1, ATT, IdA MdlId, TrnId, 1, ATT, IdB MdlId, TrnId, 1, LVL, IdLvl2 MdlId, TrnId, 2, ATT, IdC MdlId, TrnId, 2, LVL, idLvl3 MdlId, TrnId, 3,ATT, idD MdlId, TrnId, 3,ATT, idE MdlId, TrnId, 1,ATT, idF ..

Table: TrnLvl
Levels of a transaction and tables associated to each level MdlId* TrnId* TrnLvlId* TrnLvlIdSup TblId LvlNam LvlTyp LvlDsc LvlDscAttId LvlUsr Level Id Higher level Id Associated table Level Name Elements level type Description attribute Name Description attribute Id User information Integer Integer Integer Integer Integer String String String Integer String

LvlTyp: when using Multi level transaction and Business component, this value is one of the Business components data type names.

Table: TblAtt
Attributes of a table MdlId* TblId* AttId* TblAttIsKey TblAttRed TblAttStd TblAttAllowNulls The attribute is key in the table Redundant Stored Allownulls Integer Integer Integer Integer Integer Integer Integer

The position of an attribute in a table may be determined by the order in which they appear in the table. I.e.: for a table with attributes (A,B), attribute A appears first and attribute B follows it.

Table: Group
Groups of a KB MdlId* GrpId* GrpNam Identifier Name Integer Integer String

Table: GrpAtt
Composition of groups MdlId* GrpId* AttId Integer Integer Integer

Table: Variable
Information: Variables of an object Structure: MdlId* Integer

ObjCls* ObjId* VarId* VarNam VarDsc VarTyp VarLen VarDec VarRng VarSign VarPic VarDom Id de variable Name Description Variable type Length Decimals Range Sign Picture Domain it is associated to (0 if there is no associated domain) Attribute on which it is based (0 if there is no one) 0 Scalar 1 one dimension 2 two dimensions If Dimension > 0 then quantity of rows of the variable; otherwise 0 If Dimension > 1 then quantity of columns of the variable; otherwise 0 Variable-associated Help Variable-associated documentation

Integer (enumerated) Integer Integer String String (length: 30) Integer (enumerated) Integer Integer String (length: 80) Integer String (largo 30) Integer

VarBasedOn

Integer

Dimension

Integer

DimRows

Integer

DimCols

Integer

VarHelp VarDoc

String String

This table may have a high quantity of records if MdlId, ObjCls and ObjId are not instantiated when doing a select on this table. The values of VarTyp are the same values of ATTtyp plus

Table: Domain
Domains of a KB MdlId* DomId* DomNam* DomDsc DomTyp DomLen Identifier Name Description Type Length Integer Integer String String (largo 30) Integer (enumerated) Integer

DomDec DomRng DomSign DomPic DomUpdTS

Decimals Range Sign Picture Modification Date

Integer String (Length: 80) Integer String (Length: 30) Date

The DomTyp type is the same type as AttTyp.

Table: Domprop
Knowledges Base Domain Properties MdlId DomId PropId PropValue Domain Id Property Id Description Integer Integer String String (length: 30)

Table: TblSubor
Tables directly subordinated to a table Table and model must be instantiated. MdlId* TblId* TblSubPos* TblSubId Id of subordinated table Integer Integer Integer Integer

Table: TblSubBy
Attributes of subordination Table and model must be instantiated. MdlId* TblId* TblSubPos* AttId1* AttId2 I Attribute of a superordinated table Attribute of a subordinated table Integer Integer Integer Integer Integer

Table: TblExtended
Tables belonging to an extended table of a table

Table and model must be instantiated MdlId* TblId* TblExPos TblExTblId Identifier of table belonging to the extended table of TblId Integer Integer Integer Integer

Table: DVAtt
Composition of Data Views MdlId* DVId* AttId* Data View Id Id of the attribute corresponding to Internal Name. External Name Integer Integer Integer

AttExtNam

String (length: 30)

Table: DVPlat
Platform of Data Views MdlId* DVId* PlatId* ForMdlId* PropId* PropValue Data View Id Platform Id Model identifier Properties Id (non Default) External Name Integer Integer Integer Integer Integer String (largo 30)

PlatId and ForMdlId values correspond to the platform datasource. One of them has always a null value. If a model datasource is specified, ForMdlId is loaded and PlatId remains empty. If it is a valid DataSource but it is not a model DataSource, only PlatId is loaded. The possible values of PlatId are: DBFCDX DBFIDX Access AS/400 Db2common Oracle Db2/400 Informix Sqlserver 1 2 3 4 5 7 9 11 12

PostgresSQL

15

Table: DVIdxPlat
Indexes of the Data Views Platform MdlId* DVId* IDXId* PlatId* ForMdlId* PropId* PropValue Properties Id (non Default) External Name Data View Id Index Id Platform Id Integer Integer Integer Integer Integer Integer String (largo 30)

Table: CrossRef
References between objects are shown in this table. Queries on this table are valid provided the object referred to or the object making the reference is instantiated in the select statement. Therefore, the following will be valid: Select * From CrossRef Where ObjCls = 0 and ObjId = 3 Select * From CrossRef Where ItmRefCls = 1 and ObjId = 3 MdlId* ObjCls* ObjId* RefTyp* ItmRefCls ItmRefId Class of object making the reference Id of object making the reference Reference type Class of object referred to Id of object referred to Integer Integer Integer Integer Integer Integer

The possible values of RefTyp are: RUL_TYP = 3 EVT_TYP = 4 CND_TYP = 5 SCR_TYP = 6 HLP_TYP = 7 DOC_TYP = 8 DOM_TYP = 10 LAY_TYP = 11 The object is referred The object is referred The object is referred The object is referred in a printblock. The object is referred The object is referred documentation The object is referred (e.g.: Attributes) The object is referred procedure to to to to in the rules in the events in the conditions on the screen or

to in the help to in the to in a domain to in the code of a

PMTSPC = 12 Prompt UDPSPC = 13 formula TPLTYP = 14 COMP_TYP = 30

The object is referred to on system The object is referred to in Udp/Udf The object is referred to in style The object is referred to in a structure (E.g.: an attribute is referred to in a transaction structure)

Table: ObjSource
Querying the source of GX objects is possible The table structure is the following: MdlId* ObjCls* ObjId* SrcTyp* SrcCode Object class TRN, etc) Object Id Code type Code (WKP, Integer Integer Integer Enumerated String

The possible values of SrcTyp are: SUB_TYP = 1 Subroutines RUL_TYP = 3 Rules EVT_TYP = 4 Events CND_TYP = 5 Conditions HLP_TYP = 7 Help DOC_TYP = 8 Documentation HTML_TYP = 18 HTML (WebPanels) The following is added to these old values: SRC_TYP=11 Source code. (Only valid for reports and procedures)

When querying the source, the string returned in the SrcCode field is a string with XML format. The XML structure comes from the following scheme: <ElementType name="CodeBlock" content="textOnly"/> <ElementType name="PrintBlock" content="textOnly"/> <ElementType name="Source"> <element type="CodeBlock"/> <element type="PrintBlock"/> </ElementType> in printblock type nodes, the node value is the path to a bmp that contains the printblock image. Below is an example of the generated string:

After a transformation made using a simple XSL, this XML would look as follows:

Property PICFOLDER 23 It specifies the directory where images are stored.

By default, printblocks bitmaps are stored in Windows temporary directory. To change the path, you must assign the desired value to the PICFOLDER property. Printblocks names have the following structure:

PrintBlock < printblock number on the screen >_<MdlId>_<ObjCls>_<ObjId>

Table: ObjForm
Information: Forms of an object Structure: MdlId* ObjCls* ObjId* FrmClsId* FrmPath Form Class Id Path of the Bitmap with the object form for a specific form class Integer Integer Integer Integer String

Property PICFOLDER 23 It specifies the directory where the images will be stored

Some considerations: The path where the bitmap is stored for each object is saved by default in Windows temporary directory. This default value may be changed using the PICFOLDER property. The name of the file is made up a follows: <objName>_<MdlId>_<ObjCls>_<ObjId>_<FrmClsId> Records are not returned for objects of the following type: procedures, reports and webpanels. Currently, it can only be saved in bitmap format. Example: Dim cmd As New ADODB.Command Dim kb as New ADODB.Connection the knowledge base is opened Kb.Open(sConnectionString) the path where bitmaps are stored is setup cmd.ActiveConnection = kb cmd.Properties(23).Value = sPathBmps the query is built Dim sQuery As String

sQuery = "Select * From OBJFORM where mdlid=1 and objcls=4 and objid=1" cmd.CommandText = sQuery the query is executed Dim rst As ADODB.Recordset Set rst = cmd.Execute If Not rst.EOF Then rst.MoveFirst Image1.Picture = LoadPicture(rst.Fields("FrmPath").Value) End If the memory is released (quite important) rst.Close set rst = nothing set cmd = nothing kb.Close set kb = nothing In the example, Image1, the image of the first form associated to the 1-41 object is loaded in a control.

Table: ObjProp
Information: Objects properties Structure:

MdlId* ObjCls* ObjId* PropId* PropValue Constraint: Property code Property value

Integer Integer Integer String String

Only those properties that do not have default value are brought. At least the model must be instantiated (MdlId) Note: it reads the values of objects.def or proc.pty, TRN.pty, etc. E.g.: PropID ISMAIN TRNEND Value Object Main Commit on exit

Table: Property
Model properties The model must be instantiated MdlId* PropId* PropValue Property Id Property value String String

The PropId value is a string semantically corresponding to some non-default GX model property. E.g.: MdlGenerator is the value of the reorganization generator, and its values are: Development Environment Client/Server FoxPro Generator: VBasic Generator RPG/400 Generator: Cobol/400 Generator: Client/Server VBasic Generator: C/SQL Generator: Visual FoxPro Generator: Client/Server VFoxPro Generator: Java Generator: C# Generator: Embeded visual Basic 1 2 3 5 6 7 8 9 10 11 15 17

As regards the MAIN_DBMS property, the possible values are the same values of the PlatId attribute of the DVPlat table.

Table: Formclass
Information: Classes of a model form Structure: MdlId* FrmClsId* FrmClsName FrmTyp Class Name Form type (Graphic or text type) Integer Integer String String

Table: Generator
Information: Generators of a model Structure: MdlId* GenId* GenName GenPlat ActualGenId IsWeb Generator Number Generator Name Platform Generator Identifier Platform Web Integer Integer String String String String

GenId and GenName represent the value of the generator within the model. This means Reorganization generator or Default Generator or the name assigned by the user. GenPlat returns the Generator name; e.g.: .Net or Java (the list of names is the same as the one provided in the Mdlgenerator property of the Property table).

Table: Mstyle
Information: Master styles of a knowledge base Structure: MdlId* SObjCls* SObjId* Style class Object Id - If it is 0 it means that there is no associated master for this style class. Integer Integer (enumerated) Integer

The possible values for SobjCls are: transaction style procedure style STRN = 18, SPRC = 19,

report style work panel style prompt style web panel style menu bar style

SRPT = 20, SWKP = 21, SPMT = 22, SWBP = 23, SMBR = 24

Table: KbProp
PropId* PropValue Property value String String

Propid values are: UUID - ID unique for each KB, this property is used by gxquery. TimeZoneDiff is the difference between the KB Time Zone and the 0 Time Zone (GMT). It is updated once, in case it was not updated, when some object is saved. MinGxBuildNro - minimum GX build,code number to open some object of this KB. Values; GeneXus 7.5 = Build number GeneXus 80 = 1000 + Build number GeneXus 90 = 2000 + Build number Kbtype It specifies the Knowledge Base type. Values 0 = full, 1= trial.

Table: Message
Information: Messages defined in the Knowledge Base. Structure: MsgId* MsgType MsgText Message Id Message Type Message Text Integer Integer String

The possible values of MsgType are: MSG_TYPE_USER = 0 User message MSG_TYPE_INTERNAL = 1 GeneXus message

Table: Translation
Information: Message translations. Structure: MdlId* LngId* MsgId* MsgTran Model Id Language Id Message Id Message Translation Integer Integer Integer String

The MsgTran field can be modified using an UPDATE command.

Statements
Delete
It allows saving in the knowledge base, deleting objects. It is possible to delete Objects, subtype groups, attributes, domains and indexes of the user.

Objects
DELETE OBJECT WHERE MdlId=%i and ObjCls=%i and ObjNam=%s

Subtype Group
DELETE GROUP WHERE MdlId=%i and ObjCls=10 and ObjNam=%s

Domain
DELETE DOMAIN where Mdlid=%i and domid=%i

Attribute
DELETE ATTRIBUTE where Mdlid=%i and attid=%i

Indexes
DELETE FROM INDEX where Mdlid=%i and ObjCls=7 and Objid = %i and Idxnam=\"%s\ Output: Rowset with the error code (see update statement)

Update
This command allows saving in the knowledge base updating objects.

Objects
Modifying the Name, description or Folder of an object is possible. UPDATE OBJECT set ObjNam=%s , ObjDsc=\"%s\", ObjOwner=%i where Note: the following tables are enabled for updating: OBJECT - to change the name, description and folder of an object. ATTRIBUTE & DOMAIN to change the name and description. TABLEATT only to undo the redundancy. It is also posible to update the PROPERTY table, but in this case the syntax is different: UPDATE Property SET Property.<PropValue> =%s where

Domain
Modifying the Name of a domain is possible through the statement: UPDATE DOMAIN set DomNam=%s where mdlId=%i and DomNam=%s

Attribute
Modifying the name of the attribute is possible through the statement: UPDATE ATTRIBUTE set AttNam=\"%s\" where mdlId=%i and AttNam=\"%s\"" Specifying whether an attribute is redundant or not is possible through the statement: UPDATE TBLATT set TblAttRed=0 where MdlId=%i and tblid=%i and AttId=%i" Output: Rowset is the error code The possible values are: StatusID 0 - PGXD_OK 1- PGXD_1OBJ 2 -PGXD_NOOBJ 3 - PGXD_NOMATCH 4 - PGXD_NOREAD 5 - PGXD_NODELDSGN 6 - PGXD_CALLED 7 - PGXD_NODEL 8 - PGXD_NOMDL 9 - PGXD_NOUPD 10 - PGXD_NOREN 11 - PGXD_NONE 12 - PGXD_NODELIDX 13 - PGXD_NOUPDDSGN 14 - PGXD_NOUNDOGRP 15 - PGXD_NOUNDORED 16 - PGXD_NOTALL StatusDsc Successful operation Must specify exactly one record Record not found Id does not match Name Could not be read (Internal Error) Cant be deleted Prototype/production Cant be deleted as it is being used by another Could not be deleted (Internal Error) Could not select model Could not be updated (Internal Error) Invalid new name for renaming Nothing correct was set to update info System index can't be deleted Index can't be renamed in Prototype/Production Cannot delete group composition Cannot delete redundancy Not all items where updated

Commands WITH Clause


This clause applies to some of the commands detailed below. It is useful to program GXpublic in .NET environment, since setting the commands properties is not possible here (e.g.: the Specify and Generate option of the Specify command).

Specify and generate


Specify
Properties
Boolean = 0- NO 1-SI Code 15 16 17 18 24 Description Model over which the action will be executed. Specify and Generate Specification type Detailed Navigation GeneXus Version Values Integer (must be a valid model) Boolean Enumerated Boolean Integer Default 1 1 2 0 7

By default, the specification is executed with the Version specifier (winte), as from 7.0 version. If you want to specify with previous versions, you must change the value of the GeneXus Version property. The GeneXus Version property is useful for versions previous to GXpublic 8.0. Working with these versions, you may want to open a knowledge base with a higher GXpublic version (e.g.: a GeneXus 7.0 knowledge base with GXpublic 7.5), although you do not want to specify with this version. As from version 8.0 this is no longer useful, since you are only enabled to open/specify with the same 8.0 version. The values for the property (17 Specification type) are: 0 1 2 3 Full Specification Check Specification Force Generation View Last Navigation

The values of GXVersion property are: 7500 Version 7.5 7000 Version 70 6100 Version 6 Ev1

Syntax
An addition was made to the command so that it can receive the list of objects to specify/generate from an XML file:

The syntax for the command is: SPECIFY FROM <nro> OBJ FROM optional, by default, it takes it from the command properties OBJ = * It performs a specification of all objects. OBJ = <objects list> Where the objects lists must have the following syntax: <objects list> = <type>:<obj name> <objects list>= <type>:<obj name> , <objects list> <type> = { trn | prc | rpt | mnu | mbr | wkp | dv | strn | sprc | srpt | swkp | pmt | spmt | wbp | swbp } It specifies an object list. An example of a command would be the following: SPECIFY trn:Clientes, rpt:Valores, dv:miData OBJ = @<path de XML File> The XML path must be correct, otherwise the command would fail. The XML scheme is the following: <ElementType name="ObjCls" content="textOnly"/> <ElementType name="ObjName" content="textOnly"/> <ElementType name="Object"> <element type="ObjCls"/> <element type="ObjName"/> </ElementType> <ElementType name=Objects> <element type=Object/> </ElementType> Example: <Objects> <Object> <ObjCls>0</ObjCls> <ObjName>Trn</ObjName> </Object> <Object> <ObjCls>4</ObjCls> <ObjName>WorkPanel</ObjName> </Object> </Objects> Note that the format (.gxl) generated by GeneXus when exporting in 7.0 version matches this scheme.

Output
The output of this command is a table with the following structure: MdlId* ObjId* ObjCls* ObjState ObjNavPth Object Id Object class Object status after specifying Path, relative to the KB directory, of the XML resulting from the specification. Enumerado String

The possible values of ObjState are: 0 1 2 3 4 Cancelled - OK - Equal - Equal con Warning OK con Warning

When GeneXus version is 6, the GXNAVIG file is saved under the KB user directory. Note: When specifying in a version previous to 7.0, the ObjNavPath field is empty.

With Clause
This command allows the WITH clause, with the following syntax: Specify . With (DetailedNavig=1, SpecificationType=2) Where: 1001 "GenerateAfter" 1002 "SpecificationType" 1003 "DetailedNavig" 1009 "GXVersion" Known problems Prompts are not generated on specifying. The specifier and the generators to be used must be absolutely registered. The setup installs a GX.ini corresponding to 7.0 version in the GXpublic directory. To use other generators you must substitute this file by the GX.ini of 6.1 version.

Distribution and consolidation


Distribute
Command to distribute objects, attributes and domains

Properties
Boolean = 0- NO 1-SI Code 15 19 20 21 Model Id Path of the output XPW XPW Description You must indicate whether you want to do an append or create a new one. Distribution flag (0=Xpz, 1 = Xpw) Description Values Integer String String Boolean GXPublic Distribution 0 0 Default 1

33

Integer

Syntax
Distribute FROM <nro> OBJ FROM optional; by default, it takes it from property OBJ = <objects list> Where objects list must have the following syntax: <objects list> = <type>:<obj name> <objects list>= <type>:<obj name> , <objects list> <type> = { trn | att | dom | prc | rpt | mnu | wkp | dv | strn | sprc | srpt | swkp | pmt | spmt | wbp | swbp | sdt } It exports a list of objects/attributes/domains DISTRIBUTE trn:Clients, rpt:VAlues, dv:miData, att:CliCod, dom:Name OBJ = @<path de XML File> The objects/attributes/domains specified in input XML are distributed. The XML path must be correct; otherwise, the command would fail. The XML scheme is the following: <ElementType name=DomId content=textOnly/> <ElementType name=AttId content=textOnly/> <ElementType name="ObjCls" content="textOnly"/> <ElementType name="ObjName" content="textOnly"/> <ElementType name="Object"> <element type="ObjCls"/> <element type="ObjName"/> </ElementType> <ElementType name=Attribute> <element type=AttNam/> </ElementType> <ElementType name=Domain>

<element type=DomId/> </ElementType> <ElementType name=Objects> <element type=Object/> <element type=Attribute/> <element type=Domain/> </ElementType> Example: <Objects> <Object> <ObjCls>0</ObjCls> <ObjName>Trn</ObjName> </Object> <Object> <ObjCls>4</ObjCls> <ObjName>WorkPanel</ObjName> </Object> <Attribute> <AttNam>CliCod</AttNam> </Attribute> </Objects>

Output
The output of this command is a table with the following structure: MdlId* ObjCls* ObjId* ObjExpState Object class Object Id The object was successfully distributed. Integer Integer Integer Boolean

With Clause
This command allows the WITH clause, with the following syntax: Distribute With (OutputPath="c:\my distributions", DistributionFlags=1) Where: 1004 1005 1006 1018 "OutputPath" "OutputDesc" "AppendToOutput" "DistributionFlags" // // // // Output XPW Output Description Append to XPW? Export Type: 1: Do not zipfile

Example
Lets see an example of how to execute a distribution. Dim kb as New ADODB.Connection Kb.Open Provider=GXPublic.GXPublic.2;Data Source=c:\mimodelo

Dim cmd as New ADODB.Command cmd.ActiveConnection = kb cmd.Properties(15).Value = 2 Se especificar el modelo 2 cmd.Properties(19).Value = c:\misexportaciones\export.xpw Para setear las otras properties es lo mismo cambiando el valor 15 por el correspondiente En este caso me sirven los valores default de las properties cmd.CommandText = "DISTRIBUTE trn:Clientes, trn:Nueva" Dim rwsOutput as New ADODB.Recordset Set rwsOutput = cmd.Execute Running rwsOutput and seeing the distribution result is pending.

Consolidate
Command that consolidates a group of objects/attributes/domains. Properties: Code 22 Description Distribution Type It indicates whether objects and associated attributes are consolidated or only attributes and domains are. Values Integer. (0- objects and attributes, 1only attributes and domains) Default 0

Syntax
CONSOLIDATE @<path del XPW>

Output
The GXImport.log file is saved in the GXUSER directory with the information of the consolidated objects (in this case it is an XML) Besides, it generates a table with Objects, Status and an Xml with the information about the consolidation (see Rowset1)

With Clause
This command allows the WITH clause, with the following syntax: Consolidate . With (ConsolidatationType=1) Where: 1007 "ConsolidationType" // Import Type: Attributes/Domains | Objects

Mapfile
It allows specify a mapping file (adapt from) Syntax: consolidate @<name.xpz> [MAPFILE "myfile.map"] [with (xxx= )]

The .MAP file is generated after apply the adapt from rules. When using a relative path the Folder KB is referenced.

MakeBackup
It allows made a backup, from model 1 to 999, before the consolidation. Syntax: consolidate @c:\exp\MyExport.xpz with (MakeBackup=1) The valid values are: 1, Y, Yes, T or True

Impact
Update model
It allows modifying the model properties. Syntax: update model <nro> @Arch.GMP The following properties are valid: Language o o Application Path Output: a table with the error code and command description (see Rowset 2 ) Note: it is also possible to modify the design properties specifying model 1 and making a reference to GDP file (GeneXus Design Preference).

Create KB
Syntax: create KB "name" @path Name: it is the name of the design model. Output: a table with the error code and command description (see Rowset 2 ) The possible values are: Code 1 1000 Description Successful Operation Error creating KnowledgeBase:

It is possible to do a KB.Open without specifying a directory. This allows creating a Knowledge Base (using this command) without being connected to another KB.

Create Model
Syntax: Create model "Model Name" @Pref.GMP Create MDL was used previously.

The pref.gmp file has the model Preferences. If it does not find the file, it takes the default preferences of the default generator (Visual Basic) Output: a table with the error code and command description (see Rowset 2 ) Properties: Code 26 Description Application path : Selection of the application path (CREMDLPATH) Language : Model Language (CREMDLLANG) 28 Reorganization Generator (CREMDLGEN) 29 30 Model DBMS (CREMDLDS) New Model Type: It indicates whether the New Model is from Prototype or Production Integer (valid value of GenId) Integer Integer (0-Prototype, 1-Production) 3- Visual Basic 0 0 Values String Default DATAXXXX

27

English, Spanish, Portuguese, Italian

English

Impact analysis
It executes the impact analysis between two models. Syntax: impact analysis [FROM <NRO>] to <nro> FROM is optional; it takes design by default The Knowledge Base is opened in a non-exclusive way Output: Table with Object, Status and path to the xml (see Rowset1)

Generate reorg
It executes an impact analysis and generates the programs for the reorganization. Syntax: GENERATE REORG FROM %i TO %i with (execution=<nro>) Where <nro> may be 0 - Gen&Exec, 1 - GenOnly, 2- ExecOnly and 3 CancelReorg. The Cancel Reorganization (3) value deletes the creation or reorganization specifications; therefore, it is valid only after calling the command with Generate Only (1) value. Output: Table with Objects, Status and path to the xml (see Rowset1)

Generate create DB
Executes a Create DB and generates the programs for the creation of the database. Syntax: GENERATE CREATE DB FROM %i TO %i with (execution=<nro>) Where <nro> may be 0 - Gen&Exec, 1 - GenOnly, 2- ExecOnly and 3 CancelReorg. Output: Table with Objects, Status and path to the xml (see Rowset1)

Copy Model
Syntax: copy model FROM <nroO> to <nro> Output: a table with the error code and the command description (see Rowset 2 )

List
This command makes a list of tables. Syntax: LIST * from TABLE [where <conditions>] Example: list * from TABLE where MdlId = 1 and TblId = 3 Output: It generates a table with Objects, Status and an xml with the information about the consolidation (see Rowset1) If an internal error occurs, the following message is displayed: completed OK. This implies that the gxlog.err file must be verified. ...Operation

Convert KB
It allows converting a KB to the 9.0 version. Syntax: Convert KB @Path Output: Code 9 Description Conversion Failed.

This command must be applied on knowledge bases previous 9.0 version to be able to open with GXpublic 9.0 version; otherwise, the following error occurs at the connection: 8: Kb_Need_Conversion There is no need to convert the knowledge base: - If the kb was already converted from GeneXus (when opening this Kb with Genexus 9.0)

If you use Gxpublic Factory and the kb does not open with GXpublic 9.0 but with the specific version, such as GXpublic 8.0.

To know if you must execute Convert KB or not, you must do Open(<path>). If this command returns error 8 (KB must be converted to current version), you must do Open("") [i.e.: without path] and then Convert KB @<path>

Compile
It allows compiling the programs with a specific generator. Syntax: Compile <Obj> [(WITH GENERATOR = nro, BATCH = <0 o 1>]] You must specify the model through property 15.

Code 15

Description Model over which the action will be executed

Values Integer

Default 1

The default values are the following: GENERATOR is the model main generator BATCH = 1 The values of <Obj> are similar to the ones taken by the specify command. The batch option is not implemented in C/SQL compiler and Iseries COMPILE * It compiles all the objects. COMPILE <objects list> It compiles a group of objects determined by a list containing them. <lista de objetos> = <tipo>:<obj name>, <lista de objetos> <tipo> = { trn | prc | rpt | mnu | wkp | dv | strn | sprc | srpt | swkp | pmt | spmt | wbp | swbp } Un ejemplo sera COMPILE trn:Clientes, rpt:Valores COMPILE @<path de XML File> It compiles a group of objects determined by a XML file with the following structure: <ElementType name="ObjCls" content="textOnly"/> <ElementType name="ObjName" content="textOnly"/> <ElementType name="Object"> <element type="ObjCls"/> <element type="ObjName"/> </ElementType> <ElementType name=Objects> <element type=Object/> </ElementType> Note: it takes the settings of the users that are currently executing. The output of this command is a group of Xml files with the detail of the compilation result. It generates as many files as environments it has defined. The output file name is

GxPubTmp_XX.xml ,where XX is the number of environment returned by the GENERATOR table.

Generate Help
Syntax: GENERATE HELP FROM <nModelId> [with (<Properties>)] <nModelId> It cannot be design model. <Properties> Same properties as HelpGenerator.ini file (Help compiler path, Help type, etc.). The GenerationDate property is not allowed to set.

Import Help
Syntax: Import help to <ModelID> @<GXL_File> [with (LangId=<ObjLngId>)] When the language is not specified is refered the model language. Gxl file is similar to the created file under model\HELP\Language folder

Import Wsdl
Syntax: IMPORT WSDL @"<path_xml_file>" The Xml_File, is created under the Genexus installation path, when calling WSDL Inspector Batch

Appendix
Rowset
Rowset 1
MdlId* ObjCls* ObjId* ObjState ObjNavPth Status Path relative to the Xml file. Integer Integer . Integer String

Rowset 2
StatusID StatusDsc Integer String

The possible values of ObjState are:

Error New object Updates Equal Must reorganize table New table Redundancy occr.

0 1 2 3 4 5 6

Negative numbers indicate that there is a warning.

Extensin to Select *
There is a group of tables in which you can select the group of attributes that recordset will return. They are: - ObjProp - Variable - MSTyle Examle: Select ObjCls, MdlId, PropId From ObjProp Where MdlId = 1 The first column of the resulting recordset is ObjCls, the second MdlId and the third PropId.

GXService
As it was previously said, GXpublic includes a group of services on a Knowledge Base. GetRelatedAttributes(NumMod as Integer, Collection, RelatedAttributes as Collection) Attributes as

Objective: Given a model and a group of attributes belonging to it, it obtains a group of related attributes. (Starting from the attributes, it works out their base table and then includes all the attributes belonging to the extended tables of the tables subordinated to this table). Parameters: NumMod [input] Number of the model the Attributes belong to. Attributes [input] Group of attributes entered as a collection of integers. RelatedAttributes [output] Attributes related to Attributes. String GetSqlStatement(NumMod as Integer, Attributes as Collection , sentWhere as String, attsOrder as Collection) Objective: Building a SELECT statement that involves the attributes belonging to Attributes with the condition expressed in

sentWhere and whose ORDER is given by the group of attributes given in attsOrder. Parameters: NumMod [input] Number of the model the Attributes belong to. Attributes [input] Group of attributes entered as a collection of integers. SentWhere [input] Filter conditions AttsOrder [input] Attributes for ORDER Output: Generated SELECT statement To access these services, developers must put a reference to a dll called dynq 1.0 Library, which exposes an object called GXDynQuery over which the two previous methods were implemented, in addition to an extra method that will allow setting the Path to the KB that will be accessed. E.g. : Building a SELECT statement Dim Dim Dim Dim dinq As GxDynQuery Atts As New Collection Order As New Collection whereStr As String

Atts.Add(1) AttsAdd(5) Order.Add(5) WhereStr = CliCuenta > 100 Set dinq = New GxDynQuery dinq.SetKBase "c:\evento\kb" Dim mdl As Integer mdl = mdlid sqlStm = dinq.GetSqlStatement(mdl, Atts, whereStr, Order)

Functions for GXService interface CopyKB


Objective: The objective of this function is to be able to copy the KB files required to use Dynamic Query. Parameters: [in] sKbOrigen (String) [in] sDirDestino (String) Return value [out] iCodeError (Integer)

The possible values for iCodeError are: o o o 0 - Success 1 Source Directory does not exist 2 - Destination Directory does not exit

o o o

3 - Files in use (Access Violation) 4 Source directory does not contain a KB 5 - Destination directory does not contain a KB

Example: A dynamic reports application was developed on a knowledge base (c:\KB) The entire development is executed pointing to this directory, which clearly does not exist in the client PC. Therefore, the application setup should be: o o o Create this directory. Copy the minimum possible KB information. Install the other components.

To obtain the files that you must copy, you should do the following: Dim oService as New GXService Dim iRet as Integer IRet = oService.copyKB( sOrigen, sDestino) If irte = 0 then Msgbox xito

Endif

Ole DB Provider
The OLEDB technology is part of a strategy called Universal Data Access (UDA), whose primary objective is standardizing the access to any data type. OLEDB is a group of COM interfaces that provide the applications with uniform access to data stored in different ways, in addition to allowing the implementation of additional services. Within OLEDB we find two components that are very important for Providers and Consumers (of data). The idea is that data providers would hide the logic to access data and expose data in tabular form, regardless of their origin. Besides, they can expose services on this data. The advantage of the above is that consumers can access data through known interfaces, regardless of how and where data are stored. Nowadays, there are standard access interfaces (ADO-ActiveX Data Objects) that allow accessing providers through OLEDB. ADO is the highest level interface to access any type of data exposed by an OLEDB provider, therefore, this is the way to access GXpublic from languages such as VB,VFP and JAVA. For more information about ADO please refer to: http://www.microsoft.com/data/ado/default.htm In VC++ you can access the providers using ADO or lower level interfaces. For more information about OLEDB and UDA please access: http://www.microsoft.com/data/

Programming with GXpublic


With GeneXus
As from GeneXus 7.0 version, there is the possibility of accessing GXpublic tables via DataView (only for Visual Basic). For this, as from this version, there is a new format for Data Views called ADO. To use it, you must add the Access platform in Platform Specific Information and change the following properties: Table Name: Name of the GXpublic table (E.g.: Model) Database Location: GeneXus KB Path. To make it dynamic see Dynamic Data View. Data Format: ADO ADO Information Provider: Provider Id. For GXpublic it is: GXPublic.GXPublic.2 (without quotations)

So far, it only works in procedures (that do not save), reports and Work Panels, since GXpublic does not allow modifying the KB. There is also the possibility of accessing via the call to external programs. GXOpenKB(pathKB, successfuly) Open a KB o o PathKB : [in] Path de la KB Successfully: [out] 1-open 0-did not open

GXOpenTable(NameTable,val1,val2,val3) Open a table instantiating the key values with val1,val2 and val3. o NameTable: [in] name of the table to be opened

Vali: [in] value for the i-th key value.

GXLoadCurrent(Vals(), count) Returns the values of the current record. o o Vals(); [out] Returns and array with the values of the current record in the open table and KB. Count: [out] returns the array size. GXMoveNext() Moves to the next record, if possible. GXEOTable() Indicates whether you have reached the end of the table. E.G.: A GeneXus event loading the Models could be: Event Load // Abre kb call('gxOpenKb', &KBNAME) // Opening of model table &msg = 'Model' call('gxOpenTable',&msg) // Scanning KB models &endofTable = udp('gxeotable') do while &endofTable = 0 call('gxLoadCurrent',&vals(),&cantCol) &MdlId = &vals(1) &MdlName = &vals(2) &MdlPath = &vals(3) call('gxMoveNext') &endofTable = udp('gxeotable') Load Enddo EndEvent Note: The functions described above were not implemented as standard programs; they are just a guide to show an example with GeneXus. To use this idea, each developer must implement the functions by himself and use them as external programs.

With VB (or VFP) via ADO


Another way of accessing is via ADO. This option is for advanced developers. In ADO, there is a group of components through which you an access a Provider. We will use the following components: Connection Represents a connection to a Data Source. The methods used are: Open(ConnectionString) Close RecordSet o Represents a group of records of the base table. o o

The methods used are: Open(StringCommand) It loads the Recordset with the group of records specified in StringCommand MoveFirst I moves to the first record of the RecordSet MoveLast It moves to the last record of the RecordSet EOF It indicates whether the end of the RecordSet has been reached (there are no more records) Fields(i) in VB or Fields(i).value in VFP It returns the value of the i-th column of the current record of the RecordSet. The values of the columns may be also retrieved using Fields(<nameColumn>); e.g.:. Record.Fields(MdlNam) Close

An example of a VB function displaying the names of the models of a KB would be: Dim myConn As ADODB.Connection Dim myTable As ADODB.Recordset ' Opening of a KB myConn.Open ("Provider=GXPublic.GXPublic.1;Data Source=C:\MisModelos\ModeloPrueba") ' Loading of a KB models to a RecordSet ' Indicates who do recordset belong to myTable.ActiveConnection = myConn myTable.Open ("SELECT * FROM MODEL") ' Models are scanned and their names are displayed If Not myTable.EOF Then myTable.MoveFirst Do While Not myTable.EOF MsgBox (myTable.Fields("MdlNam")) myTable.MoveNext Loop myTable.Close myConn.Close End If The recordset Open receives as parameter a command indicating what records must be loaded to the recordset. This command is a SQL statement. The syntax to build the statements is explained in detail in the following section. Examples:

You want all the model objects 1 CommandString = SELECT * FROM MODEL WHERE MDLID = 1 You want all the transactions CommandString = Select * From OBJECT where MdlId = 1 and ObjCls = 0 Currently, there are some constraints in the statement: Although you put attributes in the SELECT, * is always considered. E.g.: SELECT MdlId, MdlNam is equivalent to SELECT * The ORDER is ignored; it is always sorted by primary key. Queries can be made over a unique table; that is to say, joins must be manually implemented. Example of how to implement a join: Tables where there are VarChar type attributes in model 1: Dim Dim Dim Dim myConn As New ADODB.Connection Table1 As New ADODB.Recordset Table2 As New ADODB.Recordset sentencia As String ("Provider=GXPublic.GXPublic.1;Data

' KB opening myConn.Open Source=C:\ModeloPrueba") ' Indicates who do recordsets belong to Table1.ActiveConnection = myConn Table2.ActiveConnection = myConn

'Varchar type attributes of model 1 are searched for Table1.Open ("SELECT * FROM Attribute WHERE MDLID = 1 and AttTyp = 13") If Not Table1.EOF Then Table1.MoveFirst 'Records resulting from the select query are scanned Do While Not Table1.EOF 'For eachAttId you search in the TBLID table in which tables is the statement = "SELECT * FROM TblAtt where MDLID = 1 and AttId = " + Str(Table1.Fields("ATTID")) located. Table2.Open (statement) If Not Table2.EOF Then Table2.MoveFirst ''Records resulting from the select statement are scanned Do While Not Table2.EOF MsgBox (Table2.Fields("TblId")) Table2.MoveNext

Loop End If Table2.Close Table1.MoveNext Loop Table1.Close myConn.Close End If

Connect Method GXpublic Factory


ADODB.Connection Connect(string pathKB, long reference nVersion) Where pathKB is the path where the KB that you want to open is located. nVersion is the GXpublic version with which you want to open this KB. The version, in this case, is the number appearing in the provider name: "GxPublic.GxPublic.3"; in this case is version 3. If 0 is specified, it means that you must select the newest GXpublic that this KB can open. In this case, the value with which it was opened is returned in the same parameter. If nVersin is not 0, it DOES NOT mean that you should open with a version other than the one specified with the given value. This method returns an ADODB.Connection and returns the same errors as the Open() method of the GxPublic.GxPublic provider: 1 2 KB OPEN OK KB Does not EXIST Integer Provided the path is the correct one, the *.dat file is missing the kb is already open in Design GPF type or exception Generic error on opening; it might be opened by the specifier or generator. reserved

3 4 5 6

KB USED INVALID PATH UNEXPECTED_ERROR KB OPENERROR

7 8 9

NOT_IMPLEMENTED_YET KB NEED CONVERSION KB CONVERSION FAILED

The difference with the previous case is that in case of error, the Connection will not have anything assigned (null, nulo, or nothing); therefore, it cannot be used

to query the error. If the global error is created, for instance in Visual Basic, the ERR global variable must be used. If nVersion is a large number, it is anyway opened with the higher version DLL. Notes: This DLL has information in the Windows record (it is registered with regsvr32 command; this is done by the setup). You must have installed the previous GXpublic versions to be used. If 0 is specified as nVersion, it returns the number of the version with which it was opened (the last one registered). On opening a 7.0 version KB, if GXpublic 7.5 is not installed/registered, the factory will attempt to open it with the highest version installed and compatible with it (GXpublic 7.0 or 1.0) Compatibility: Connection via ProgId (programmatic identifier) is still supported; it is one tier above ADO connection. E.g.: the Visual Basic code to get connected to a Knowledge Base must be modified if you want to use GxpublicFactory

dim KB as ADODB.Connection
it remains the same as before but instead of using it is changed by

set KB = KB.Open("Provider=GxPublic.GXPublic.3;DataSource=" + sKBPath) dim nVersion as long dim GxpublicFactory as object set GxpublicFactory = CreateObject("GXPublicFactory.ConnectionFactory") nVersion = 0 set KB = GxpublicFactory.Connect(sKBPath, nVersion)

The rest is the same, taking into account that if Connect fails (e.g.: the KB does not exist), the KB variable will remain in Nothing. Therefore, querying KB.Errors to verify the possible errors is no longer possible; you must query the global variable of the VB Err.

connectionString Method GXpublic Factory


The ConnectionString() method has three parameters. The first two ones are the ones of the Connect method and the additional one is : sConnectionString. The latter is a BSTR that has the connection string that GXpublic must use to open this knowledge base. This is the IDL signature.
HRESULT ConnectionString([in] BSTR sKBPath, [in,out] int* pnVersion,[out, retval] BSTR* sConnectionString)

It is particularly useful to allow using the factory from .NET, since the connect returns a OleDBProvider that cannot interpret the Csharp code. An example of CSharp code would be the following:
int version = 0; string path = @"C:\Models\Example";

OleDbConnection connection = new OleDbConnection(); try { IConnectionFactory cf = new GXPUBLICFACTORYLib.ConnectionFactoryClass(); string connectionString = cf.ConnectionString(path, ref version); connection.ConnectionString = connectionString; connection.Open(); } catch (COMException ex) { throw new ApplicationException(String.Format("Error opening KB {0}\n{1}", path, ex.Message)); }

Writing a GXpublic table


Attprop

USER_METADATA Property
It is possible to write a value in this property and then query it doing a select on the ATTprop table. For this, you must export the Knowledge base; once you modified an attribute property, edit and modify the xpz export file and then consolidate it again. E.g.: put the picture of an attribute such as @! Then decompress the export file (xpz) and edit the xml; then search for the @! String. <GXAtt> <Attribute> <Id>2</Id> <Name>CliNom</Name> <Title>CliNom</Title> <Type>Character</Type> </Attribute> <Property> <Type>string</Type> <Name>ATT_PICTURE</Name> <Value>@!</Value> </Property> Add immediately after (or substitute) the new property <Property> <Type>string</Type> <Name>USER_METADATA</Name> <Value>Valor User Metadata</Value> </Property> Then, consolidate the export file. On doing select on the Attprop table, you will visualize this property and its corresponding value.

Objprop

USER_METADATA Property
It is possible to write a value in this property and then query it doing a select on the ObjProp table. The mechanism is similar to the Attprop table; you must include the property, editing and modifying the export file and then consolidate it. We recommend putting a non-default value to an object property to determine where to include the code. In case of a transaction it would be as follows: <GXObject> <Transaction> <Info> </Info> <Property> <Type>string</Type> <Name>USER_METADATA</Name> <Value> Valor Usermetada</Value> </Property>

DynQ and Services


In case of DYNQ and services, you CANNOT use the References with Visual Basic, since you must use the late binding; that is to say, creating the objects with CreateObject() and not with new DynqLib.GxDynQuery, because it depends on the KB version if it is 7.5 or lower or if it is Olimar or higher. Note: the reference can be used only if you know exactly with which version you will get ALWYAS connected. You must use DYNQ with ProgID GxPubilc.GxDynQuery As independent version GxPubilc.GxDynQuery.1 to use the 7.5 version dynq GxPubilc.GxDynQuery.4 to use the Olimar (8.0) dynq That is to say, you must use the nVersion that returns the new GXPublicFactory Connect method to know what DynQ you should use. In case of the services provided by GXpublic you must do the same with CreateObject: GxPublic.GXService.1 GxPublic.GXService.3 GxPublic.GXService.4 GxPublic.GXService.5 Unfortunately, you must do a small adjustment in the numbers in GXPublic versions: nVersion GeneXus Version DynQ Services

2 3 4 5

7.0 (Ceibo) 7.5 (Solis) 8.0 (Olimar) 9.0 (Yi)

.1 .1 .4 .5

.1 .3 .4 .5

As from version 4, numbers will always coincide. A new GxDynQFactory service may be performed in the future, to do the same as with GXPublicFactory.

Crash Report
When a general exception occurrs a dump file (crashinfo.zip) is created. This File is created under GXpublic installation directory.

You might also like