SQL 13-1 __________________________________________________________________________ PC-Axis and SQL Databases PC-Axis can always work with PC-Axis files stored on disk or CD-ROM, but it is also possible to connect to a SQL database which has been stored in accordance with the metadata decided on by Statistics Sweden. In order to work with SQL-databases the following changes are made compared to the earlier described PC-Axis software. - The file pcaxis.exe is enlarged to include a user interface for SQL. - A new dll-file is added, pxsql2008.dll - A new textfile is added, pcasqlen.txt (=language en, if several languages then further text files are added) and new texts in pcaxisen.msg. Starting from meta model 2.1 a textfile pcasqldb21.txt is used for the connection parameters and the names of tables and columns in the database, replacing this information in pcasqlen.txt for that part. For meta model 2.2 a textfile pcasqldb22.txt is used the same way. The structure of the meta database must be kept but the names of tables and columns may differ for different installations. These names are therefore read from the text file pcasqlsv.txt for meta model 2.0, from pcasqldb21.txt for meta model 2.1 and from pcasqldb22.txt for meta model 2.2. 1. Connection to SQL database The file pcasqlen.txt for meta model 2.0 or earlier, Pcasqldb21.txt for meta model 2.1 and Pcasqldb22 for meta model 2.2 contain information on the default server and user, as well as information on whether the connection is to a Sybase database or an ODBC data source (can also be Sybase via ODBC). If ODBC=N it means that logon can only be made to a Sybase database. Temptab=# means that temporary tables have a name starting with #. If an Oracle database is used the Temptab must instead be in the a-z character range. The texts Varorder=StoreColumnNo means that the variables will be shown sorted in this order. Since PC-Axis sql is always used in a LAN where it has already been checked that the user is accepted, there is no extra security when retrieval is made from the official database. As long as the default user is used the password is automatic. When the user logs in on another server he has to enter a userid and a password which are acceptable on that server/database. This is especially the case when logon is to a micro database. Information on which micro database has been used is therefore stored in the pcax2000.ini file. When a user logs in with a user identity other than the default user he also get the possibility to save sql tables. The name of the database used to store sql tables is also stored in the pcax2000.ini file after having been entered once. It is up to the user to get permission to create tables in a database beforehand. Example: Connect to an ODBC source Section: [Metabase] Name Example Explanation Metabase SDB_Metabase The name of the default metabase to use Server Internetdatabase The name of a default ODBC dsn
26
Embed
PC-Axis and SQL Databases - Statistiska Centralbyrån · PC-Axis and SQL Databases . PC-Axis can always work with PC-Axis files stored on disk or CD-ROM, ... Server=Database1 . Server1=Database2
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
PC-Axis and SQL Databases PC-Axis can always work with PC-Axis files stored on disk or CD-ROM, but it is also possible to connect to a SQL database which has been stored in accordance with the metadata decided on by Statistics Sweden. In order to work with SQL-databases the following changes are made compared to the earlier described PC-Axis software. - The file pcaxis.exe is enlarged to include a user interface for SQL. - A new dll-file is added, pxsql2008.dll - A new textfile is added, pcasqlen.txt (=language en, if several languages then further text files are added) and new texts in pcaxisen.msg. Starting from meta model 2.1 a textfile pcasqldb21.txt is used for the connection parameters and the names of tables and columns in the database, replacing this information in pcasqlen.txt for that part. For meta model 2.2 a textfile pcasqldb22.txt is used the same way. The structure of the meta database must be kept but the names of tables and columns may differ for different installations. These names are therefore read from the text file pcasqlsv.txt for meta model 2.0, from pcasqldb21.txt for meta model 2.1 and from pcasqldb22.txt for meta model 2.2.
1. Connection to SQL database The file pcasqlen.txt for meta model 2.0 or earlier, Pcasqldb21.txt for meta model 2.1 and Pcasqldb22 for meta model 2.2 contain information on the default server and user, as well as information on whether the connection is to a Sybase database or an ODBC data source (can also be Sybase via ODBC). If ODBC=N it means that logon can only be made to a Sybase database. Temptab=# means that temporary tables have a name starting with #. If an Oracle database is used the Temptab must instead be in the a-z character range. The texts Varorder=StoreColumnNo means that the variables will be shown sorted in this order. Since PC-Axis sql is always used in a LAN where it has already been checked that the user is accepted, there is no extra security when retrieval is made from the official database. As long as the default user is used the password is automatic. When the user logs in on another server he has to enter a userid and a password which are acceptable on that server/database. This is especially the case when logon is to a micro database. Information on which micro database has been used is therefore stored in the pcax2000.ini file. When a user logs in with a user identity other than the default user he also get the possibility to save sql tables. The name of the database used to store sql tables is also stored in the pcax2000.ini file after having been entered once. It is up to the user to get permission to create tables in a database beforehand. Example: Connect to an ODBC source Section: [Metabase] Name Example Explanation
Metabase SDB_Metabase The name of the default metabase to use
Server Internetdatabase The name of a default ODBC dsn
Server1 Productiondatabase The name of a default ODBC dsn.
Used for MS SQL server MServer Q1 The name of the server for a default ODBC
data source. Used for MS SQL Server
PServer Q2 The name of the server for a default ODBC data source. Used for MS SQL Server
DefUser SCB The default login. PC-Axis checks if this has been changed by the user.
Blip 1 1 or 2 (single or double ’ in queries)
Temptab # For MS and Sybase. For Oracle change to chars from a-z
Metatables statmeta For Oracle if an owner has to be given when retrieving metadata
Datatables statdata For Oracle if an owner has to be given when retrieving data
ODBC Y Use an ODBC DSN
Access Y If MS Access database
SAorder OmradeText Order by subject for micro meta data (will not be moved to dot net). Obsolete.
Varorder StoreColumnNo or PresText
Order the variables according to this column value
Language1 Svenska main language in SQL database
Language2 English second language in SQL database
LangCode1 sv code for main language
LangCode2 en code for second language
LangMeta1 From version 2.1 onwards
LangMeta2 Eng From version 2.1 onwards. suffix for tables with the second language
UpdateIgnore=0 UpdateIgnore=0 1=Ignore if data has been updated for a maintable 0=Check if user is allowed to see updated maintables before publication
PresCatIgnore=0 PresCatIgnore=0 1=Ignore the presentation category and let everybody see all maintables 0=Check if user is allowed to see private maintables
LoggSql 0 If 1 write a log file
TestSql 1 If 1 write created sql queries in a text file
LogDatabase ABC If LogUser=1, the name of the sql database
for log
LogTable UserLog If LogUser=1, the name of the sql table for log
LogServer Q3 If LogUser=1, the name of the sql server for log
LogDSN UserReg If logUser=1, the name of the ODBC dsn for log
LogDriver MS The log server is MS SQL server (special treatment of user/password)
InLogUser 1 IF LogUser=1 and the entered userid/password is to be used to write in the logtable
MatrixCode TableId
If the keyword Matrix is to be filled with information from TableId in Maintable Default is Contents.PrsCode
ContentsCode new 2008
PresCode Content
Default. PresCode is used when more than one content is selected to make the keyword CODES for contents variable. Content, new 2008, use Content instead of PresCode for CODES keyword.
ValueUpperCase 1 Make the first char of a value text upper case, when code+text is retrieved and stored in Values
SCBspec 1 Special for SCB. Allow a user to see all tables for a product if he is allowed to see at least one.
Example: Connect using ODBC [Metabase] Metabase=SDB_Metabas Server=Database1 Server1=Database2 MServer=Q0x PServer=Q0y DefUser=SCB Blip=1 Temptab=# ODBC=Y SAorder=OmradeText order by subject for micro meta data Varorder=StoreColumnNo order the variable according to this Language1=Svenska Language2=English
LangCode1=sv LangCode2=en UpdateIgnore=0 take into account that data can have been updated PresCatIgnore=0 take into account that data can be private LoggSql=0 if 1 write a log file TestSql=1 if 1 write created sql queries in a text file LogUser=1 if 1 log the retrieval in an sql table LogDatabase=inter if LogUser=1, the name of the database LogTable=UserLog if LogUser=1, the name of the sql table LogServer=Q0z if LogUser=1, the name of the db server LogDSN=ReguserMS dsn if log using ODBC LogDriver=MS if MS SQL server If the keyword Matrix is to be filled with information from TableId in Maintable then MatrixCode=TableId If the first char of a value text should be upper case when code+text is retrieved and stored in Values ValueUpperCase=1 Special for SCB. Allow a user to see all tables for a product if he is allowed to see at least one. SCBspec=1 Example: Connect to a Sybase database [Metabase] Metabase=SDB_Metabas Server=Q0xx DefUser=SCB Blip=1 Temptab=# ODBC=N SAorder=OmradeText order by subject for micro meta data Varorder=StoreColumnNo order the variable according to this Language1=Svenska Language2=English LangCode1=sv LangCode2=en UpdateIgnore=0 take into account that data can have been updated PresCatIgnore=0 take into account that data can be private LoggSql=0 if 1 write a log file TestSql=1 if 1 write created sql queries in a text file LogUser=1 if 1 log the retrieval in an sql table LogDatabase= if LogUser=1, the name of the database LogTable= if LogUser=1, the name of the sql table LogServer= if LogUser=1, the name of the db server LogDSN= dsn if log using ODBC If the keyword Matrix is to be filled with information from TableId in Maintable then MatrixCode=TableId
2. SQL - codes The text file contains information on which codes are used in the installation of the SQL meta base Pcasqlen.txt for meta model 2.0 or earlier Pcasqldb21.txt for meta model 2.1 Pcasqldb22.txt for meta model 2.2 PC-Axis SQL reads the file and compares the codes with the content in the meta base tables. If meta model 2.1 or 2.2 are used the text file Pcasqlen.txt is still used for the texts in menus and labels in PC-Axis SQL interface. Section: [Codes] Name Example Explanation
SQL table Column
CFPricesC C Current prices
Contents CFPrices
CFPricesF F Fixed prices
Contents CFPrices
StockFAS S Stock
Contents StockFA
StockFAF F Flow
Contents StockFA
StockFAA
A Average Contents StockFA
Copyright1 1 Official statistics no Copyright
Contents Copyright
Copyright2 2 Not official statistics and not Copyright
TimeScale Regular Y it is a regular timescale. Timeval can be created
Contents DayAdj Y data is day adjusted SeasAdj Y data is seasonal adjusted PresCellsZero Y show missing lines as 0
N show missing lines as .. AggrePossible Y can be aggregated ValueSet SortCodeExists Y sortcode exists in ValueSet.
N use Sortcode from ValuePool FootnoteContTime Cellnote Y this is a cellnote. May be
omitted if the other variable values are not selected
FootnoteContValue Cellnote Y this is a cellnote. May be omitted if the other variable values are not selected
MainTableVariableHierarchy AllLevelsStored
All levels in the hierarchy are stored. PC-Axis 2007 only works with hierarchies where all are stored.
Exception Codes that are the same in all languages and are not read from the text file: SQL table
Column Explanation
MainTable PresCategory O official P private I internal Grouping Hierarchy U unbalanced B balanced N not a hierarchy
3. Names of tables and columns, meta model 2.0 [TextCatalogue] TextCatalogue=TextCatalog CatalogueNo=TextCatalogNo TextType=TextType PresText=PresText [TextCatalogueLang2] TextCatalogueLang2=TextCatalog_eng [MetaAdm] MetaAdm=MetaAdm Value=Value Property=Property
6. Texts for menus, labels, etc Texts are always in pcasqlxx.txt, where xx is the code for the language, for instance pcasqlen.txt for English texts [Caption] Metabase=SDB_Metabas Classes=Classification of a variable Information=Information on Inlog=Log in NewGroup=New Aggregate UseQuery=Use Query SaveQuery=Save Query Search=Find Values=Values Select=Select SaveReg=Save List VarSel=Select Variable SaveHow=Create table Sumvar=Select sum variables MicInfo=Information on micro register MicInfoVar=Information on variables Class=Classifications
Reference=Reference Updated=Latest Update Footnotes=Footnotes Quality=Quality Information Reftime=Reference Time Unit=Unit Decimals=Decimals Valuesleft=Values left Valueset=Value Sets Groupsval=Aggregates/values Groups=Aggregates Valset=Used values Groupreg=Aggregation Lists General=General Personal=Personal Valuesnonmatch=Not Found NewGroup=Name of new aggregate PresText=Presentation Text UseVal=Value to Use FindVal=Find values for variable FindSel=Condition FoundVal=Found Values: Sorting=Sort Descend=Descending Ascend=Ascending Data=Data: FoundTables=Found in Tables: SaveFile=Save File InDatabase=in PC-AXIS Database Convert=Convert Display=Display CompleteTab=Complete Table PartTab=Part of Table Close=Close Metadata Window ListName=List Name: Domain=Valuepool: Aggreg=Aggregate AggVal=Single values OtherVal=Other values Including=Including Joker=? for wildcard, * for wildcards optSelected=&Selected time periods optLatest=&Only last time period optMoving=&Moving time interval optMovLast=&Fixed start time, moving stop time fraTime=Time Option number=number variable=Variable valuecode=Valuecode for number valuetext=Value name for number sumvariables=Sum variables Codes=Codes Code=Code Text=Text CodeText=Code+text
EmptyTable=Empty table ShowTable=Show table SaveTable=Save table in database or convert AfterRetr=After retrieval RegVer=Register/Version DBMatrix=Database/Matrix Register=Register Version=Version Database=Database DataMatrix=Datamatrix Description=Description Definition=Definition Source=Source Heading1=Variable order stub (rows) and heading (columns) Heading2=Mark the variable which is to be the first in heading MaxVar=Select max 15 variables Metabase=Metabase optMacro=&Macro Description optMicro=M&icro Description MetaStore=Metadata CalcText=Calculate with SqlSave=Save as SQL-table Replace=Replace if table already exists AddTo=Add if table already exists Abort=Abolish if table already exists Tablename=Table name CalculVar=Select factor SaveQuery=File name and directory VarOrder=Variable order SelCodetext=Select if variable values shown as codes only, as texts or both codes and texts Parttext=Part texts Partstart=Start Partlength=Length PartElim=Elimination should be allowed Sparse=Treat as sparse Sparsetext=The table is estimated to contain a large number of zero cells DepVar=Depending Variables DepVarAll=All starting with the same code Parttable=Subtable Product=Product Overlap=Allow overlapping MenuSel=Menu select Id=Id Status=Status Text=Text TimePeriods=Time periods Cellnote=indicates that footnote is cellnote continuepxq=Retrieve and start recording for edit and calculate NewDsn=Select server for new datasource prodmetabase=Production metabase extmetabase=External metabase other=Other AllValues=All values for this variable AllValuesSelect=Mark to select all values, which exist at time of retrieval optPxs=PXS in ini file format
optXml=PXS in XML format (test) hierarchy=Hierarchy hierarchyTot=Full Hierarchy hierarchy1=Level 2 hierarchy2=Level 3 hierarchy3=Level 4 hierarchyLast=Last level [Texts] Database=SDB TimeScale=Timescale Regular=Regular Footnote=Footnote for NoFootnote=No footnote for OblFootnote=Mandatory note for ReqFootnote=Note on request for NoOblFoot=No mandatory footnote for NoReqFoot=No footnote on request for Value=value Variable=variable Time=time Contents=contents Yes=Yes No=No Stock=Stock Flow=Flow Average=Average Groupbase=Aggregation list based on Reading=Extracting data CheckFoot=Checking footnotes CheckMeta=Checking metadata By=by Type=Type Codedepending=Code dependant TablestatusEx=Explanation: TablestatusU=Updated but not published TablestatusM=Only metadata TablestatusI=Internal TablestatusP=Private Selected=Selected Of=of NoOfTables=No of tables [Statustext] Cancel=Close metadata window Class=Select values, value sets, aggregates for current variable Code=Change between code, text and code+text for values English=Change language for the retrieval from the database Info=Show information for selected material OK=Selection ready, read data and create a PC-AXIS file PartTable=Select a part of the table from a menu of subtables MainTable=Return to the complete table SaveQuery=Save the selection in a file Search=Search for tables with specific variables, contents or values UndoClass=Undo the classification performed for selected variable UseQuery=Use a previously saved selection
Zoom=Enlarge the active (blue framed) listbox Unzoom=Return to normal size All=Select all values for the active variable InfoValue=Show information for the selected value InfoVar=Show information for the selected variable [PXBATCH] Options=Options Savebase=Save Database: Logfile=Log File: Createfile=Create file: Queryfile=Query File: Updatedat=Update Database Updatedat99=Year 1999 database format HTMLlist=Web List of Contents Replace=Replace if file already exists SQLTables=SQL-tables Readlist=Select list... HTMLonly=Only web list of contents will be created Servermiss=Enter server name Usermiss=Enter user name Passwordmiss=Enter password Querymiss=Enter name of query file Outnamemiss=Enter name of output file Nonexist=File does not exist Outputmiss=File name missing Outpxerr=The PC-Axis file must have extension .px DBmiss=Catalogue for Save database missing Logmiss=Name of log file missing NonAuth=The user SCB cannot create sql-tables Userret=User or password is wrong Serverret=Cannot log on to server Logonret=Error at login: LogonOK=Log in done process=processing HTMLcreate=Creating Web file CreateReady=File has been created Logoff=Logging off NameOptions=Select SameName=Same name as file PromptName=Prompt for name TableName=Table name ExistOptions=Select NoChangeSQL=Abort if table already exists ReplaceSql=Replace if table already exists AddSql=Add to existing table Sqldatabase=Sql-database Valuetexts=Select Codeonly=Only codes TextQuery=Value text as in query Tablemiss=Table name missing DriveErr=Error when changing drive: Nofile=The file does not exist Validname=The specified name is not correct
7. Saved query Because large retrievals can take a long time and there often is a need to make the same retrieval every month, quarter or year, when new time periods are added, it is possible to save a query in PC-Axis sql interface. Such a saved query is stored in a file with extension .pxs and looks like this: See Chapter 14 for details.
7. PX-Batch A saved query of type pxs can be used in PX-Batch. The only information the user needs to give is where the saved query is to be found and where the PC-Axis file is to be written. If the user has a lot of saved queries he can make a pxt file and list all files in this. That enables him to just select the pxt file in PX-Batch instead of selecting all the pxs files. Example of a pxt file: L:\SOS97\SPARFR\AM0401B1.PXS L:\SOS97\SPARFR\AM0401B3.PXS L:\SOS97\SPARFR\AM0401B4.PXS More in chapter 14.