IIUG 2011: Last call / Ultima chamada

This article is written in English and Portuguese
Este artigo est� escrito em Ingl�s e Portugu�s

English version:

The 2011 International Informix User Group conference is just around the corner. It will take place in Lenexa, Kansas City between 15 and 18 May. The conference site has all the information you may need. This includes the sessions abstracts, the list of tutorials, hotel and transportation information etc.

And what a great conference this will be. Remember that we have Informix 11.7, Informix Warehouse Accelerator and the Genero partnership with 4Js.
And then you have all the permanent/usual attractions, like deep technical sessions, keynote speakers, the Sunday tutorials etc. Some of my personal favorites this year would be:
  • Sunday tutorials (Flexible grid, Fastest Informix DBA, Partitioning, Certification preparation)
  • Keynote speakers (Jerry Keesee - Director of Informix Database Development, Rob Thomas - Vice President of Business Development, Arvind Krishna - General Manager IBM Information Management) including this year's special with Dr. David Ferrucci the lead researcher and Principal Investigator (PI) for the Watson/Jeopardy! project
    These are great opportunities to understand IBM plans and to ask the difficult questions
  • Several sessions on specific topics like Informix 11.7, Informix Warehouse Accelerator, Performance and Tunning, integrating Informix with other products
  • Free certification opportunity
  • Networking with many people from the Informix community
  • Evening specials... Great fun to trigger networking
As I observed in last year's conference, the IIUG team does everything possible to provide you the best value for money. And they, together with all the people delivering sessions in the conference, really manage to provide great sessions, great tutorials and great entertainment.

If you never had the opportunity to go to one of the IIUG's conferences you really don't know what you're missing. If you had, you know it's worth it. Unfortunately this year I won't be able to join, but I'm eagerly waiting for feedback from the community and to check the presentation materials. To all the lucky attendees I wish you a great conference, and please blog/email about it!

Vers�o Portuguesa:

A confer�ncia de 2011 do grupo internacional de utilizadores de Informix est� quase a acontecer. Ter� lugar em Lenexas, Kansas City entre 15 e 18 de Maio. O site da confer�ncia tem toda a informa��o poss�vel. Isto inclu� as sinapses das sess�es, a lista de tutorials, informa��o sobre o hotel e transportes etc.

E tudo indica que esta ser� uma grande confer�ncia. Lembremo-nos que temos a vers�o 11.7 do Informix, o Informix Warehouse Accelerator e a parceria Genero com a 4JS.
Para al�m disso teremos as atrac��es habituais, como sess�es muito t�cnicas, os oradores especiais, os tutorials de domingo etc. Alguns dos meus favoritos detes ano seriam:

  • Tutorials de domingo (Flexible grid, Fastest Informix DBA, Partitioning, Prepara��o para certifica��o)
  • Oradores especiais (Jerry Keesee - Director de Informix Database Development, Rob Thomas - Vice Presidente de desenvolvimento de neg�cio, Arvind Krishna - General Manager IBM Information Management) incluindo uma participa��o especial do Dr. David Ferrucci - lead researcher and Principal Investigator (PI) para o projecto Watson/Jeopardy!
    S�o grandes oportunidades para entender os planos da IBM e para colocar as quest�es dif�ceis
  • V�rias sess�es sobre t�picos espec�ficos como Informix 11.7, Informix Warehouse Accelerator, Performance e optimiza��o, integra��o de Informix com outros produtos
  • Oportunidade para obter a certifica��o gratuitamente
  • Convivio com imensas pessoas da comunidade Informix
  • Anima��o nocturna... Muito divertimento para proporcionar o convivio e interac��o entre os participantes
Como pude observar na confer�ncia do ano passado, a equipa do IIUG faz tudo o poss�vel para proporcionar o melhor retorno do investimento. E eles, juntamente com quem apresenta as sess�es, conseguem realmente providenciar �ptimas sess�es, excelentes tutorials e muito entretenimento.

Se nunca teve a oportunidade de participar numa das confer�ncias do IIUG ent�o n�o sabe o que perde. Se j� teve, ent�o sabe que valem a pena. Infelizmente este ano n�o me vai ser poss�vel participar, mas fico ansioso pelo feedback da comunidade e para espreitar as apresenta��es quando estiverem dispon�veis. A todos os felizardos que v�o assistir � confer�ncia, desejo um excelente evento, e por favor bloguem ou contem na lista de mail como est� a ser.

Informix Roadshow 2011 Lisboa (Agenda)

This article is only written in Portuguese due to it's local nature
Este artigo s� est� escrito em Portugu�s dada a sua natureza local


A agenda do evento Informix Roadshow 2011 a realizar no pr�ximo dia 3 de Maio nas instala��es da IBM �:


AGENDA:
  • 9:45 Registo e Boas Vindas
  • 10.00 � 10.15 Discover the Next Decade of Informix at IBM
    Juan Brogeras - SWG Information Management Sales Director SPGI
  • 10.15 � 10.45 Informix UltimateWarehouse.Transformational and Continuous Improvements for Your DataWarehouse.
    Steve Shoaf -WWSales Executive - Informix & solidDB
  • 10.45 � 11.15 Informix Genero: Broadening the Informix 4GL Portfolio.
    Manuel Jorge Sousa - Vice President 4Js for Iberia
  • 11.15 � 11.45 Caf�
  • 11.45 � 12.15 Informix 11.7 solutions, features, roadmap and evolution
    Jos� Manuel Ruiz Gallud - Database Sales, Southwest IOT
  • 12.15 � 12.45 Upgrading Informix Dynamic Server / Case study.
  • 12.45 � 13.15 Testemunho de um Informix Business Partner
  • 13.15 � 13.30 Wrap up / Almo�o

Fa�a a sua inscri��o atrav�s do email ibmdm@pt.ibm.com
Estacionamento gratuito no parque do Hotel Vip Art�s (mesmo em frente ao Edf IBM no Parque das Na��es em Lisboa)

Informix Roadshow 2011 Lisboa

This article is written only in Portuguese due to it's local nature
Este artigo s� est� escrito em Portugu�s dada a natureza local

Vers�o Portuguesa:

A IBM vai realizar o Informix Roadshow 2011 no dia 3 de Maio, no IBM F�rum Lisboa (instala��es da IBM no Parque das Na��es).
Ser� meio dia dedicado �s �ltimas novidades da fam�lia Informix. Em particular:

  • Funcionalidades da vers�o 11.7 (Panther)
  • Informix Warehouse Accelerator
  • Informix Genero
Comemoram-se este ano os primeiros 10 anos ap�s a aquisi��o da Informix, pelo que ser� apresentado um balan�o desta d�cada e lan�amento das bases para a pr�xima
As sess�es contar�o com oradores nacionais e internacionais. Haver� tempo para quest�es e intera��o entre clientes, parceiros e equipa IBM.
N�o deixe se comparecer e se n�o receber convite nos pr�ximos dias n�o deixe de contactar a IBM ou a mim pessoalmente.
No final das sess�es ser� proporcionado um almo�o onde ter� toda a equipa IBM e oradores � sua disposi��o para qualquer esclarecimento adicional.
O convite � extens�vel a todos os que n�o sendo clientes ou parceiros desejem conhecer melhor uma base de dados fi�vel, robusta, r�pida, moderna, extens�vel e especialmente adaptada para ambientes "embebidos".

Finalmente, mantenha-se atento a este espa�o para obter informa��o mais detalhada sobre a agenda.

New products / Novos produtos

This article is written in English and Portuguese
Este artigo est� dispon�vel em Ingl�s e Portugu�s

English version:

Informix Warehouse Accelerator

There are several news in the Informix area. As I mentioned in the last article, version 11.7.xC2 is already available (including the update on the documentation center), but that's not all. One of the major features of 11.7.xC2 is that it supports a new product called Informix Warehouse Accelerator. This is a separate installable component, that uses a columnar based approach and holds copy of certain groups of tables (datamarts). The data is stored in memory and the queries that can be solved by this system are transparently sent from the main instance. If the data you're querying is not stored/duplicated in the system than the query is solved by the Informix instance. The principle is terribly simple and the installation and configuration is very straight forward. The Accelerator is only available for Linux x86_64 but can work together with Informix on other platforms. The product includes an eclipse based tool to manage the data mapping and configuration of your Informix instance. The product is oriented for data warehouse workloads and was already available for DB2 on z/OS.
The Informix Ultimate Warehouse Edition includes the usual Informix features, the Warehouse Accelerator, compression, LBAC, replications etc.
I've done a few preliminary tests and I can assure you the configuration is very easy. Expect some details in a future article. Meanwhile you can start discovering it at the following URL:

http://www-01.ibm.com/software/data/informix/ultimate-warehouse-edition/

Informix Genero

Informix Genero is another new product targeting the 4GL users. You may recognize the name as a 4JS product. It enables the modernization of 4GL applications (new interface, new functionalities, new deployment environments).

I've seen lots of customers with very customized, flexible and stable applications running with Informix 4GL that complain about the looks (character based) and some lack of functionalities. Nevertheless they don't want to leave 4GL for several reasons:
  • 4GL productivity
  • Programmers mindset (4GL is a procedural language, and moving to object oriented is not always easy)
  • Ease of debug
  • Stability
  • etc.
If you're one of this customers you may want to take a close look at this new IBM offer. Please start here:

http://www-01.ibm.com/software/data/informix/tools/genero.html


Partners conference calls:

If you have interest in these two topics, you can try to check these two partner conference calls:


Vers�o Portuguesa:



Informix Warehouse Accelerator
H� v�rias noticias na �rea de Informix. Como mencionei no �ltimo artigo, a vers�o 11.7.xC2 j� est� dispon�vel (incluindo a actualiza��o no centro de documenta��o), mas n�o � tudo. Uma das funcionalidades da 11.7.xC2 � suportar um novo produto chamado Informix Warehouse Accelerator. Este � um componente instalado separadamente, que usa uma abordagem orientada a colunas e que guarda uma c�pia de v�rios groupos de tabelas (datamarts). Estes dados s�o guardados em mem�ria e a queries que possam resolver-se no novo sistema ser�o enviadas transparentementde pelo sistema principal. Se os dados n�o que estamos a interrogar n�o existirem neste sistema, ent�o a query � resolvida pelo sistema principal. O princ�pi � terrivelmente simples bem como a configura��o e instala��o. O Accelerator s� existe para Linux x86_64 (mas pode estar ligado a uma inst�ncia Informix noutra plataforma). O produto inclu� uma ferramenta baseada no Eclipse que permite a gest�o dos mapeamentos de dados e a configura��o da inst�ncia Informix. O produto � orientado a ambientes de data warehouse e j� estava dispon�vel para DB2 em z/OS.
O Informix Ultimate Warehouse Edition inclu� as funcionalidades habituais do motor, o Warehouse Accelerator, compress�o LBAC, replica��o etc.
J� tive oportunidade de fazer alguns testes preliminares e posso assegurar que a configura��o � de facto muito f�cil. Aguarde mais detalhes num futuro artigo. Entretanto pode come�ar a descobrir o assunto no seguinte URL:

http://www-01.ibm.com/software/data/informix/ultimate-warehouse-edition/

Informix Genero

O Informix Genero � outro produto cujo alvo s�o os utilizadores de 4GL. Talvez reconhe�a o nome como um produto da 4JS. Permite a moderniza��o de aplica��es 4GL (novo interface, novas funcionalidades, novos ambinetes de utiliza��o).

Tenho visto muitos clientes com aplica��es muito adaptadas, fl�xivies e est�veis que sistematicamente se quixam do aspecto (baseado em caracter) e alguma falta de funcionalidades.
No entanto n�o querem deixar o 4GL por v�rias razoes.:
  • Produtividade do 4GL
  • Orienta��o dos programadores(4GL � uma linguagem procedimental e a mudan�a para programa��o orientada a objectos nem sempre � f�cil)
  • Facilidade de despiste de problemas
  • Estabilidade
  • etc.
Se � um destes clientes, talvez queira dar uma olhadela nestas novas ofertas da IBM: Comec aqui:

http://www-01.ibm.com/software/data/informix/tools/genero.html


Confer�ncias para parceiras;

Se tem interesse em algum destes t�picos pode tentar assistir a estas duas reuni�es

Informix Ultimate Warehouse Editions:

Informix 11.70.xC2: It's out!

This article is written in English and Portuguese
Este artigo est� escrito em Ingl�s e Portugu�s

English Version:

It's been too long since my last post. The reason is the usual lack of time. Sorry for that...
This is just a small post to let you know that Informix version 11.70.xC2 is being made available. It's already possible to get if from the Fix Central site (link on the right). The Information Center documentation site is still not updated. But a quick look into the release notes shows some interesting stuff:
  • Installation without root privileges
    This makes it possible to install and use Informix without root privileges. But due to the Unix/Linux nature, some features may not be available. This was a request from some embedded solutions providers. So it's another feature that helps make Informix the right choice for those environments. I believe we'll see more developments in the usage without root privileges in the future.
  • More SQL Admin API commands
    This time will see things like CREATE/DROP DATABASE and ONTAPE/ONBAR/ONSMSYNC commands. This is great since you can trigger your backups as tasks. Something that we're missing.
  • More improvements in the BTS text search datablade. IBM continues to improve this datablade which it free of charges
  • Table and column ALIASES in DML instructions (SELECT, DELETE and UPDATE)
    The ALIAS can now be used in GROUP BY clauses. I like this one. We could use numbers, but if you change your projection list you also need to change the GROUP BY clause.
  • Case insensitive searches
    This was also a frequently asked for feature. It applies only to NCHAR and NVARCHAR fields and you need to specify it in the CREATE DATABASE statement
  • OAT improvements
    As usual, when we see engine improvements we also see them in OAT. This time, a new area lets you manage your backups. Other features include the ability to uninstall a plug-in (something I also missed), ability to create reports based on historical data, improvements in the schema manager plugin-in and a few more
  • Ability to configure the number of file descriptor servers
    This is an intriguing feature related to a nasty problem that affects Informix instances with very intensive usage (I'm talking about thousands of concurrent connections, and a very high rate of new connections per second - typical values lay in the vicinity of more than 2000 concurrent sessions and/or more than 15 new connections per second, but it really depends on the environment). This issue is worth a dedicated article, and tech support usually knows it by "nsf.lock issue". If you never heard about it, it's because you don't suffer from it. In any case, this feature is in fact present in several older versions (later v10 fixpacks and 11.50). Unfortunately it was not properly documented. Also note that v11.7 has some structural changes that should eliminate this problem. The feature is translated into a new parameter called NUMFDSERVERS. Classical versions (pre v10.??) used just one. Somewhere in the v10 family it was decided that more was better, but sometimes it isn't due to other points of contention (eliminated in v11.7). So now you can decide how many to use.
  • Informix Warehouse Accelerator
    This is a new product that uses new technology. It is composed of a new in-memory based query engine, and a tool you use to map your OLTP data into that new system. Then, when you send DSS like queries to the OLTP engine, it will decide if the "partner" system can handle them. If it does the query is routed transparently and the results sent back. If it doesn't than the OLTP will resolve the queries. The advantage is that you get much (really!) faster query times on the queries routed to the new system. There was a preview of these technology on IIUG conference last year and the results were impressive. Please be alert, because there will be some buzz around this (the same technology is already available on DB2 for z/OS)
In short that's it. And there as with any other fixpack there are some bug fixes.


Vers�o Portuguesa:


Passou muito tempo desde o �ltimo artigo. A raz�o � a habitual falta de tempo. As minhas desculpas...
Este artigo serve apenas para dar conta de que a vers�o 11.7.xC2 do Informix est� a ser disponibilizada. J� � poss�vel obt�-la do site Fix Central (liga��o � direita). A documenta��o no Information Center ainda estar� a ser actualizada. Mas uma pequena espreitadela nas release notes mostra algumas coisas interessantes:
  • Instala��o sem privil�gios de root.
    Isto torna poss�vel instalar e utilizar o Informix sem privil�gios de root. Mas dada a natureza dos sistemas operativos Unix/Linux, algumas funcionalidades poder�o n�o estar dispon�veis. Isto foi um pedido de alguns fornecedores de solu��es embebidas. Por isso � mais uma funcionalidade que ajuda o Informix a ser a escolha acertada para este tipo de ambientes. Acredito que iremos ver mais desenvolvimentos relativos � utiliza��o sem root no futuro
  • Mais comandos da API de administra��o SQL
    Desta vez vemos comandos como CREATE/DROP DATABASE e ONTAPE/ONBAR/ONSMSYNC. Isto � �ptimo pois passamos a poder despoletar backups como tarefas. Algo que j� se sentia falta
  • Mais melhorias no datablade de pesquisa de texto livre (BTS)
    A IBM continua a melhorar este datablade que � distribu�do sem custos com o produto
  • ALIAS em tabelas e colunas nas instru��es de DML ((SELECT, DELETE and UPDATE)
    Os ALIAS podem agora ser usados nas cl�usulas de GROUP BY. Pessoalmente agrada-me bastante. J� pod�amos usar n�meros, mas se mud�ssemos a projection list ter�amos tamb�m de arranjar a cl�usula GROUP BY
  • Pesquisas por caracteres n�o sens�veis a mai�sculas ou min�sculas
    Esta funcionalidade fazia parte da lista com mais pedidos. S� se aplica a colunas NCHAR e NVARCHAR e tem de ser especificada na cria��o da base de dados (instru��o CREATE DATABASE)
  • Melhorias no OAT
    Como vem sendo h�bito, sempre que temos melhorias no motor tamb�m as vemos no OAT. Desta vez, uma nova �rea permite gerir os backups. Outras novidades incl�em a possibilidade de desinstalar plug-ins (algo que sentia falta), cria��o de relat�rios baseados em dados de hist�rico, melhorias no plug-in de gest�o de schema e mais alguns
  • Possibilidade de configurar o n�mero de servidores de file descriptors.
    Isto � uma funcionalidade algo intrigante, relacionada com um problema complexo que afecta inst�ncias Informix com uma utiliza��o muito intensiva (estou a falar de milhares de sess�es concorrentes e uma taxa muito alta de novas sess�es por segundo - valores tipicos situam-se perto de mais de 2000 sess�es concorrentes e/ou mais de 15 novas sess�es por segundo, mas depender� sempre de cada ambiente)
    Este assunto mereceria por si s� um artigo, mas o suporte t�cnico reconhece-o por "problema do nsf.lock". Se nunca ouviu falar nele � porque nunca sofreu com ele. Em qualquer caso, esta funcionalidade est� de facto presente em v�rias vers�es j� antigas (�ltimos fixpacks da vers�o 10 e fixpacks da vers�o 11.50). Infelizmente n�o estava devidamente documentadas. Note-se tamb�m que a vers�o 11.7 tem algumas modifica��es estruturuais que dever�o eliminar este problema. A funcionalidade traduz-se num novo par�metro chamado NUMFDSERVERS. Vers�es antigas (pre v10.??) usavam apenas um servidor de file descriptors. Num determinado fixpack da vers�o 10 considerou-se que mais era melhora, mas em alguns casos n�o �, devido a outros pontos de conten��o (eliminados na vers�o 11.7). Assim, agora podemos decidir e ajustar quantos queremos
  • Informix Warehouse Accelerator
    Isto � um novo produto que utiliza tecnologia nova. � composto por um motor de queries, baseado em mem�ria, e uma ferramenta que pode usar-se para mapear alguns dados do sistema OLTP neste novo sistema. Depois, quando enviados uma query do tipo DSS ao motor OLTP, ele decide se o novo sistema associado pode resolver a query. Se sim, a query � enviada transparentemente ao novo sistema, e os resultados s�o enviados de volta. Se a query n�o puder ser processada pelo sistema "emparceirado", ent�o o sistema OLTP ir� resolv�-la. A vantagem � que obteremos muito (mesmo muito!) melhores tempos de execu��o nas querys enviadas ao novo sistema. Houve uma antevis�o do sistema na �ltima confer�ncia do IIUG e os resultados eram realmente impressionantes. Mantenha-se alerta, pois isto ir� certamente dar que falar nos pr�ximos tempos (a mesma tecnologia j� existe para DB2 em z/OS)
Em resumo � isto. E como em qualquer outro fixpack cont�m igualmente um n�mero de correc��es.

Informix making the world smarter...

This article is written only in English
Este artigo apenas est� dispon�vel em Ingl�s

Although I'm preparing some technical articles I'm happy to make a break to echo some good news...

Informix is helping an IBM Partner, Centric Solutions, in making the world smarter. Bank of China is using it for a SWIFT application, that also helps to save trees.

These are my words, but I think everyone agrees it must be robust, fast and trustworthy... and Informix is a perfect match for that!

Read all about it here:

http://www.prnewswire.com/news-releases/bank-of-china-in-the-uk-works-with-ibm-to-become-a-smarter-greener-bank-114573679.html

Stored procedure PDQ / PDQ dos procedimentos

This article is written in English and Portuguese
Este artigo est� escrito em Ingl�s e Portugu�s

English version:

A few years ago I needed to check if I had some stored procedures created with PDQ. Maybe some readers don't know, but if you have SET PDQPRIORITY n in your session before creating a procedure it will run with that PDQ. And that can cause abnormal resource consumption. In most cases you'll want your procedures created without PDQ.
The PDQ associated with a procedure will also change if you run UPDATE STATISTICS FOR PROCEDURE [...], in a session with PDQ active. This is also a frequent issue when people forgot to turn it off or when the statistics are gathered for tables (where PDQ can be helpful) and procedures on the same command or script.

So, how to check the PDQ of your procedures? The catalog tables don't provide this information, so at the time I asked for help internally within IBM. Cosmo, from UK came to my rescue with a strange query that I used successfully a couple of times. The query checks the first 3 characters of the column "data" from sysprocplan where planid = -2.... Don't ask... supposedly this is an encode of the PDQ value.
Recently I had another situation on a customer, where we suspected they had their procedures with PDQ. We were expecting to see the value of 80 (which we caught in some sessions) but all we saw was NULL. Once again I asked Cosmo for help, and during our conversations we noticed that we only had run the query on little endian platforms (Linux on Intel and Tru64). So, Cosmo sent me a script that created 100 procedures with different PDQ levels and then returns the encoded values. It was no surprise that the values were different. Following Cosmo's suggestion I joined both set of values into a big CASE statement that you can check at the end of this article.

The query has a few important points:
  1. I used data[1,3] in the CASE statement. We could use data::CHAR(3), but with that it would not run on version 7. It's not supported anymore, but there are still people using it, so I decided to use a syntax that's compatible with those old versions.
  2. If I remember correctly Cosmo's first query was really a function that received the procedure name. I'm including that as another option in the end of the article. In that version the query raises and error if it enters the ELSE condition of the CASE statement. In the version I was using at the later customer, the case returned NULL and that fulled me... In this new version it will raise an error since it means there is something wrong with the query.
    For the non-procedural version, I did a small and dirty trick: If it enters the ELSE condition it will try to return a value divided by zero. This will cause an error.
    Note that this conditions can't happen because the PDQ must be a value between 0 and 100. So if in the future the encoding changes the query will start raising errors, and this should alert the user...
  3. The encoded values for PDQ 1 to 100 are distinct in the two types of platforms. The encoded value for 0 however is equal. That's why we have two WHEN conditions for each value between 1 and 100 and just one for 0.

Vers�o Portuguesa:

H� alguns anos atr�s precisei de verificar se tinha criado algum procedimento com PDQ. Talvez alguns leitores n�o saibam, mas se tivermos executado SET PDQPRIORITY n na sess�o antes de criar um procedimento, este ir� ser executado com esse valor de PDQ. E isso pode causar um consumo anormal de recursos. Na maioria das situa��es n�o queremos ter procedimentos criados com PDQ.
O PDQ associado a um procedimento tamb�m muda se corrermos um UPDATE STATISTICS FOR PROCEDURE [...], numa sess�o com PDQ activo. Isto � um problema habitual quando nos esquecemos de desligar o PDQ, ou quando as estat�sticas s�o criadas para tabelas (processo onde o PDQ � ben�fico) e procedimentos no mesmo comando ou script.

Como podemos verificar o PDQ dos procedimentos? As tabelas do cat�logo n�o disponibilizam esta informa��o, por isso na altura pedi ajuda internamente na IBM. O Cosmo, de UK, auxiliou-me com o envio de uma query um pouco estranha que usei algumas vezes com sucesso. A query verifica os tr�s primeiros caracteres de uma coluna "data" da tabela sysprocplan, onde "planid = -2"... N�o pergunte... � suposto isto ser o valor de PDQ codificado de alguma forma.
Recentemente tive outra situa��o num cliente onde suspeit�vamos que tinham os procedimentos com PDQ. Esper�vamos ver o valor 80 (que tinhamos visto activo em algumas sess�es), mas tudo o que a query nos dava era NULL. Note-se que se tivesse olhado bem para a query deveria ter percebido que o NULL implicava um erro. Mas como est�vamos � espera de ver um valor (80) cometi um "erro de simpatia". Recorri novamente ao Cosmo para ajuda. E durante as nossas trocas de impress�es not�mos que s� tinhamos corrido a query em plataforms que usam little endian (Linux em Intel e Tru64). Assim o Cosmo enviou-me um script que cria 100 procedimentos com diferentes valores de PDQ e que retorna os respectivos valores codificados. N�o foi surpresa ver valores diferentes. Seguindo uma sugest�o do Cosmo, juntei ambos os conjuntos de valores numa instru��o CASE que pode ser consultada no final deste artigo.

A query tem alguns pontos importantes:
  1. Utilizei data[1,3] na instru��o CASE. Pod�amos utilizar data::CHAR(3), mas com isso a query n�o correria na vers�o 7. Esta vers�o j� est� sem suporte, mas ainda � usada, por isso preferi uma sintaxe compat�vel com vers�es mais antigas
  2. Se bem me recordo a primeira query que o Cosmo me enviou, era na realidade uma fun��o que recebia o nome do procedimento que quer�amos verificar. Esta forma est� tamb�m inclu�da no final do artigo. Nesta forma o c�digo causa um erro caso entre na condi��o ELSE do CASE. Na vers�o que estava a usar neste �ltimo cliente, o CASE retornava NULL e isso enganou-me... Nesta vers�o actualizada e corrigida, ir� gerar um erro, dado que isso implica que algo n�o est� correcto na query. N�o vers�o n�o procedimental inclu� um pequeno truque: Se entrar no ELSE do CASE vai tentar retornar um valor a dividir por zero. Isto ir� causar um erro.
    Note-se que esta condi��o n�o pode acontecer pois o PDQ ser� sempre um valor entre 0 e 100. Se no futuro os valores codificados forem alterados a query dever� come�ar a dar erro, e isso dever� alertar o utilizador...
  3. Os valores codificados de PDQ de 1 a 100 s�o distintos nos dois tipos de plataforma (little endian e big endian). No entanto o valor codificado para 0 � igual. � por isso que temos duas condi��es WHEN para cada valor entre 1 e 100 e s� um para o valor 0.

Non-procedural query:
Query n�o procedimental:


SELECT
f.procname,
CASE data[1,3]
WHEN "AAA" THEN 0
WHEN "AQA" THEN 1
WHEN "AAE" THEN 1
WHEN "AgA" THEN 2
WHEN "AAI" THEN 2
WHEN "AwA" THEN 3
WHEN "AAM" THEN 3
WHEN "BAA" THEN 4
WHEN "AAQ" THEN 4
WHEN "BQA" THEN 5
WHEN "AAU" THEN 5
WHEN "BgA" THEN 6
WHEN "AAY" THEN 6
WHEN "BwA" THEN 7
WHEN "AAc" THEN 7
WHEN "CAA" THEN 8
WHEN "AAg" THEN 8
WHEN "CQA" THEN 9
WHEN "AAk" THEN 9
WHEN "CgA" THEN 10
WHEN "AAo" THEN 10
WHEN "CwA" THEN 11
WHEN "AAs" THEN 11
WHEN "DAA" THEN 12
WHEN "AAw" THEN 12
WHEN "DQA" THEN 13
WHEN "AA0" THEN 13
WHEN "DgA" THEN 14
WHEN "AA4" THEN 14
WHEN "DwA" THEN 15
WHEN "AA8" THEN 15
WHEN "EAA" THEN 16
WHEN "ABA" THEN 16
WHEN "EQA" THEN 17
WHEN "ABE" THEN 17
WHEN "EgA" THEN 18
WHEN "ABI" THEN 18
WHEN "EwA" THEN 19
WHEN "ABM" THEN 19
WHEN "FAA" THEN 20
WHEN "ABQ" THEN 20
WHEN "FQA" THEN 21
WHEN "ABU" THEN 21
WHEN "FgA" THEN 22
WHEN "ABY" THEN 22
WHEN "FwA" THEN 23
WHEN "ABc" THEN 23
WHEN "GAA" THEN 24
WHEN "ABg" THEN 24
WHEN "GQA" THEN 25
WHEN "ABk" THEN 25
WHEN "GgA" THEN 26
WHEN "ABo" THEN 26
WHEN "GwA" THEN 27
WHEN "ABs" THEN 27
WHEN "HAA" THEN 28
WHEN "ABw" THEN 28
WHEN "HQA" THEN 29
WHEN "AB0" THEN 29
WHEN "HgA" THEN 30
WHEN "AB4" THEN 30
WHEN "HwA" THEN 31
WHEN "AB8" THEN 31
WHEN "IAA" THEN 32
WHEN "ACA" THEN 32
WHEN "IQA" THEN 33
WHEN "ACE" THEN 33
WHEN "IgA" THEN 34
WHEN "ACI" THEN 34
WHEN "IwA" THEN 35
WHEN "ACM" THEN 35
WHEN "JAA" THEN 36
WHEN "ACQ" THEN 36
WHEN "JQA" THEN 37
WHEN "ACU" THEN 37
WHEN "JgA" THEN 38
WHEN "ACY" THEN 38
WHEN "JwA" THEN 39
WHEN "ACc" THEN 39
WHEN "KAA" THEN 40
WHEN "ACg" THEN 40
WHEN "KQA" THEN 41
WHEN "ACk" THEN 41
WHEN "KgA" THEN 42
WHEN "ACo" THEN 42
WHEN "KwA" THEN 43
WHEN "ACs" THEN 43
WHEN "LAA" THEN 44
WHEN "ACw" THEN 44
WHEN "LQA" THEN 45
WHEN "AC0" THEN 45
WHEN "LgA" THEN 46
WHEN "AC4" THEN 46
WHEN "LwA" THEN 47
WHEN "AC8" THEN 47
WHEN "MAA" THEN 48
WHEN "ADA" THEN 48
WHEN "MQA" THEN 49
WHEN "ADE" THEN 49
WHEN "MgA" THEN 50
WHEN "ADI" THEN 50
WHEN "MwA" THEN 51
WHEN "ADM" THEN 51
WHEN "NAA" THEN 52
WHEN "ADQ" THEN 52
WHEN "NQA" THEN 53
WHEN "ADU" THEN 53
WHEN "NgA" THEN 54
WHEN "ADY" THEN 54
WHEN "NwA" THEN 55
WHEN "ADc" THEN 55
WHEN "OAA" THEN 56
WHEN "ADg" THEN 56
WHEN "OQA" THEN 57
WHEN "ADk" THEN 57
WHEN "OgA" THEN 58
WHEN "ADo" THEN 58
WHEN "OwA" THEN 59
WHEN "ADs" THEN 59
WHEN "PAA" THEN 60
WHEN "ADw" THEN 60
WHEN "PQA" THEN 61
WHEN "AD0" THEN 61
WHEN "PgA" THEN 62
WHEN "AD4" THEN 62
WHEN "PwA" THEN 63
WHEN "AD8" THEN 63
WHEN "QAA" THEN 64
WHEN "AEA" THEN 64
WHEN "QQA" THEN 65
WHEN "AEE" THEN 65
WHEN "QgA" THEN 66
WHEN "AEI" THEN 66
WHEN "QwA" THEN 67
WHEN "AEM" THEN 67
WHEN "RAA" THEN 68
WHEN "AEQ" THEN 68
WHEN "RQA" THEN 69
WHEN "AEU" THEN 69
WHEN "RgA" THEN 70
WHEN "AEY" THEN 70
WHEN "RwA" THEN 71
WHEN "AEc" THEN 71
WHEN "SAA" THEN 72
WHEN "AEg" THEN 72
WHEN "SQA" THEN 73
WHEN "AEk" THEN 73
WHEN "SgA" THEN 74
WHEN "AEo" THEN 74
WHEN "SwA" THEN 75
WHEN "AEs" THEN 75
WHEN "TAA" THEN 76
WHEN "AEw" THEN 76
WHEN "TQA" THEN 77
WHEN "AE0" THEN 77
WHEN "TgA" THEN 78
WHEN "AE4" THEN 78
WHEN "TwA" THEN 79
WHEN "AE8" THEN 79
WHEN "UAA" THEN 80
WHEN "AFA" THEN 80
WHEN "UQA" THEN 81
WHEN "AFE" THEN 81
WHEN "UgA" THEN 82
WHEN "AFI" THEN 82
WHEN "UwA" THEN 83
WHEN "AFM" THEN 83
WHEN "VAA" THEN 84
WHEN "AFQ" THEN 84
WHEN "VQA" THEN 85
WHEN "AFU" THEN 85
WHEN "VgA" THEN 86
WHEN "AFY" THEN 86
WHEN "VwA" THEN 87
WHEN "AFc" THEN 87
WHEN "WAA" THEN 88
WHEN "AFg" THEN 88
WHEN "WQA" THEN 89
WHEN "AFk" THEN 89
WHEN "WgA" THEN 90
WHEN "AFo" THEN 90
WHEN "WwA" THEN 91
WHEN "AFs" THEN 91
WHEN "XAA" THEN 92
WHEN "AFw" THEN 92
WHEN "XQA" THEN 93
WHEN "AF0" THEN 93
WHEN "XgA" THEN 94
WHEN "AF4" THEN 94
WHEN "XwA" THEN 95
WHEN "AF8" THEN 95
WHEN "YAA" THEN 96
WHEN "AGA" THEN 96
WHEN "YQA" THEN 97
WHEN "AGE" THEN 97
WHEN "YgA" THEN 98
WHEN "AGI" THEN 98
WHEN "YwA" THEN 99
WHEN "AGM" THEN 99
WHEN "ZAA" THEN 100
WHEN "AGQ" THEN 100
ELSE
TRUNC(p.rowid / 0)
END pdq_value
FROM
sysprocplan p, sysprocedures f
WHERE
p.planid = -2 AND
f.procid = p.procid
ORDER BY 2 DESC


Procedural version:
Vers�o procedimental:


CREATE FUNCTION get_proc_pdq_value(v_proc_name VARCHAR(128))
RETURNING SMALLINT;

DEFINE v_ret_pdq_value SMALLINT;


SELECT
f.procname,
CASE data[1,3]
WHEN "AAA" THEN 0
WHEN "AQA" THEN 1
WHEN "AAE" THEN 1
WHEN "AgA" THEN 2
WHEN "AAI" THEN 2
WHEN "AwA" THEN 3
WHEN "AAM" THEN 3
WHEN "BAA" THEN 4
WHEN "AAQ" THEN 4
WHEN "BQA" THEN 5
WHEN "AAU" THEN 5
WHEN "BgA" THEN 6
WHEN "AAY" THEN 6
WHEN "BwA" THEN 7
WHEN "AAc" THEN 7
WHEN "CAA" THEN 8
WHEN "AAg" THEN 8
WHEN "CQA" THEN 9
WHEN "AAk" THEN 9
WHEN "CgA" THEN 10
WHEN "AAo" THEN 10
WHEN "CwA" THEN 11
WHEN "AAs" THEN 11
WHEN "DAA" THEN 12
WHEN "AAw" THEN 12
WHEN "DQA" THEN 13
WHEN "AA0" THEN 13
WHEN "DgA" THEN 14
WHEN "AA4" THEN 14
WHEN "DwA" THEN 15
WHEN "AA8" THEN 15
WHEN "EAA" THEN 16
WHEN "ABA" THEN 16
WHEN "EQA" THEN 17
WHEN "ABE" THEN 17
WHEN "EgA" THEN 18
WHEN "ABI" THEN 18
WHEN "EwA" THEN 19
WHEN "ABM" THEN 19
WHEN "FAA" THEN 20
WHEN "ABQ" THEN 20
WHEN "FQA" THEN 21
WHEN "ABU" THEN 21
WHEN "FgA" THEN 22
WHEN "ABY" THEN 22
WHEN "FwA" THEN 23
WHEN "ABc" THEN 23
WHEN "GAA" THEN 24
WHEN "ABg" THEN 24
WHEN "GQA" THEN 25
WHEN "ABk" THEN 25
WHEN "GgA" THEN 26
WHEN "ABo" THEN 26
WHEN "GwA" THEN 27
WHEN "ABs" THEN 27
WHEN "HAA" THEN 28
WHEN "ABw" THEN 28
WHEN "HQA" THEN 29
WHEN "AB0" THEN 29
WHEN "HgA" THEN 30
WHEN "AB4" THEN 30
WHEN "HwA" THEN 31
WHEN "AB8" THEN 31
WHEN "IAA" THEN 32
WHEN "ACA" THEN 32
WHEN "IQA" THEN 33
WHEN "ACE" THEN 33
WHEN "IgA" THEN 34
WHEN "ACI" THEN 34
WHEN "IwA" THEN 35
WHEN "ACM" THEN 35
WHEN "JAA" THEN 36
WHEN "ACQ" THEN 36
WHEN "JQA" THEN 37
WHEN "ACU" THEN 37
WHEN "JgA" THEN 38
WHEN "ACY" THEN 38
WHEN "JwA" THEN 39
WHEN "ACc" THEN 39
WHEN "KAA" THEN 40
WHEN "ACg" THEN 40
WHEN "KQA" THEN 41
WHEN "ACk" THEN 41
WHEN "KgA" THEN 42
WHEN "ACo" THEN 42
WHEN "KwA" THEN 43
WHEN "ACs" THEN 43
WHEN "LAA" THEN 44
WHEN "ACw" THEN 44
WHEN "LQA" THEN 45
WHEN "AC0" THEN 45
WHEN "LgA" THEN 46
WHEN "AC4" THEN 46
WHEN "LwA" THEN 47
WHEN "AC8" THEN 47
WHEN "MAA" THEN 48
WHEN "ADA" THEN 48
WHEN "MQA" THEN 49
WHEN "ADE" THEN 49
WHEN "MgA" THEN 50
WHEN "ADI" THEN 50
WHEN "MwA" THEN 51
WHEN "ADM" THEN 51
WHEN "NAA" THEN 52
WHEN "ADQ" THEN 52
WHEN "NQA" THEN 53
WHEN "ADU" THEN 53
WHEN "NgA" THEN 54
WHEN "ADY" THEN 54
WHEN "NwA" THEN 55
WHEN "ADc" THEN 55
WHEN "OAA" THEN 56
WHEN "ADg" THEN 56
WHEN "OQA" THEN 57
WHEN "ADk" THEN 57
WHEN "OgA" THEN 58
WHEN "ADo" THEN 58
WHEN "OwA" THEN 59
WHEN "ADs" THEN 59
WHEN "PAA" THEN 60
WHEN "ADw" THEN 60
WHEN "PQA" THEN 61
WHEN "AD0" THEN 61
WHEN "PgA" THEN 62
WHEN "AD4" THEN 62
WHEN "PwA" THEN 63
WHEN "AD8" THEN 63
WHEN "QAA" THEN 64
WHEN "AEA" THEN 64
WHEN "QQA" THEN 65
WHEN "AEE" THEN 65
WHEN "QgA" THEN 66
WHEN "AEI" THEN 66
WHEN "QwA" THEN 67
WHEN "AEM" THEN 67
WHEN "RAA" THEN 68
WHEN "AEQ" THEN 68
WHEN "RQA" THEN 69
WHEN "AEU" THEN 69
WHEN "RgA" THEN 70
WHEN "AEY" THEN 70
WHEN "RwA" THEN 71
WHEN "AEc" THEN 71
WHEN "SAA" THEN 72
WHEN "AEg" THEN 72
WHEN "SQA" THEN 73
WHEN "AEk" THEN 73
WHEN "SgA" THEN 74
WHEN "AEo" THEN 74
WHEN "SwA" THEN 75
WHEN "AEs" THEN 75
WHEN "TAA" THEN 76
WHEN "AEw" THEN 76
WHEN "TQA" THEN 77
WHEN "AE0" THEN 77
WHEN "TgA" THEN 78
WHEN "AE4" THEN 78
WHEN "TwA" THEN 79
WHEN "AE8" THEN 79
WHEN "UAA" THEN 80
WHEN "AFA" THEN 80
WHEN "UQA" THEN 81
WHEN "AFE" THEN 81
WHEN "UgA" THEN 82
WHEN "AFI" THEN 82
WHEN "UwA" THEN 83
WHEN "AFM" THEN 83
WHEN "VAA" THEN 84
WHEN "AFQ" THEN 84
WHEN "VQA" THEN 85
WHEN "AFU" THEN 85
WHEN "VgA" THEN 86
WHEN "AFY" THEN 86
WHEN "VwA" THEN 87
WHEN "AFc" THEN 87
WHEN "WAA" THEN 88
WHEN "AFg" THEN 88
WHEN "WQA" THEN 89
WHEN "AFk" THEN 89
WHEN "WgA" THEN 90
WHEN "AFo" THEN 90
WHEN "WwA" THEN 91
WHEN "AFs" THEN 91
WHEN "XAA" THEN 92
WHEN "AFw" THEN 92
WHEN "XQA" THEN 93
WHEN "AF0" THEN 93
WHEN "XgA" THEN 94
WHEN "AF4" THEN 94
WHEN "XwA" THEN 95
WHEN "AF8" THEN 95
WHEN "YAA" THEN 96
WHEN "AGA" THEN 96
WHEN "YQA" THEN 97
WHEN "AGE" THEN 97
WHEN "YgA" THEN 98
WHEN "AGI" THEN 98
WHEN "YwA" THEN 99
WHEN "AGM" THEN 99
WHEN "ZAA" THEN 100
WHEN "AGQ" THEN 100
ELSE
-1
END pdq_value
INTO
v_ret_pdq_value
FROM
sysprocplan p, sysprocedures f
WHERE
p.planid = -2 AND
f.procid = p.procid AND
f.procname = v_proc_name;

IF v_ret_pdq_value = -1
THEN
RAISE EXCEPTION -746,0,'Could not decode PDQ value. Please check query';
ELSE
RETURN v_ret_pdq_value;
END IF
END FUNCTION;



Updated on Jan 12, 2011: Cosmo noted that the procedure should be declared as a function and asked me to reference him as Cosmo instead of Simon David

Alterado em 12 de Jan de 2011: O Cosmo referiu que o procedimento deveria ser declarado como fun��o e pediu para ser referido como Cosmo em vez de Simon David