Collection data types are %$^%#%$%!!!!!!
Posted in 1998
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Security, Permissions & Auditing, Data Types & Schema Design, Internationalization & Character Sets
Hi,
I am trying to wrtie a datablade to search collection data types in
informix universal
server ... but I am running into mucho grief. Are there any datablade
gurus out there in netland that can help me out of my predicament?
A cut down version of the table structure I am trying to search is:
create row type credits_t
(
role varchar(20),
name varchar(100)
);
create table catalog
(
accn_num varchar(20) primary key,
full_title varchar(255) not null,
credits set(credits_t not null),
);
A sample instance of the catalog table would be:
accn_num: 1
full_title: star wars
credits: {row('Director', 'George Lucas'), row('Han Solo', 'Harrison
Ford')}
What I would like to be able to do is write a datablade to do text
searching within
collection datatypes. For example:
select *
from catalog
where searchset(credits, 'Ford')
should return the above row. Simple enough you might say?
But the query above results in the following error:
7420: Argument (collectioninput(): collectioninput: arg2 fparam rettype
xi)
Why??????????????????????????????????????
What I did was create a shared object using the following Makefile:
IDIR = /opt/informix
INCLUDE = -I $(IDIR)/incl/esql -I $(IDIR)/incl/dmi
all: searchlib.o
ld -G searchlib.o -o searchlib.so
searchlib.o: searchlib.c
gcc -c searchlib.c $(INCLUDE)
and then I did some C coding (in the file searchlib.c):
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <ifxgls.h>
#include <mi.h>
mi_boolean
searchset(MI_COLLECTION *set, mi_char *term)
{
return MI_TRUE;
}
note that this is a braindead function that just returns true for
the time being, I will add the string searching stuff later.
Finally I created a new function
create function searchset ( arg1 collection, arg2 char )
returning boolean; external name
"/opt/informix/work/searchlib/searchlib.so(searchset)"
language C
end function;
I am using Universal server v9.12.UC2 and Client SDK 2.01.UC1
Any ideas as to what is causing my 7420 error message?
Also another oddity: in /opt/informix/incl/dmi/milib.h we have the
following definition:
typedef struct mi_collection MI_COLLECTION;
yet there is no definition for "struct mi_collection" to be found in any
other include file?
I am starting to believe that perhaps the Informix developers cut some
corners in the development of the collection stuff for datablades. Is
there any credence to this belief?
thanks for considering my problem...
cheers,
Andrew