Unix Technical Forum

What's wrong with this C UDR?

This is a discussion on What's wrong with this C UDR? within the Informix forums, part of the Database Server Software category; --> I'm trying to do some basic stuff in a C UDR. Following the docs, mi_get_database_info takes a MI_CONNECTION* and ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 04:17 PM
bret@welcometolazyhill.com
 
Posts: n/a
Default What's wrong with this C UDR?

I'm trying to do some basic stuff in a C UDR. Following the docs,
mi_get_database_info takes a MI_CONNECTION* and a MI_DATABASE_INFO*.
However, the following causes Informix to give me "7520: Argument (2)
is NULL", which means a NULL was sent and Informix didn't expect it:

MI_CONNECTION *conn;
MI_DATABASE_INFO *dbInfo;
char* cpToEncrypt;
mi_lvarchar* cpOut;
fprintf(stderr,"encryptVarchar - entered");

cpOut = mi_var_copy(toEncrypt);
cpToEncrypt = mi_get_vardata(cpOut);

conn = mi_open(NULL, NULL, NULL);
/* If connection descriptor is NULL, there was an error *
connecting to the session context. */
if ( conn == NULL ) {
mi_db_error_raise(conn, MI_EXCEPTION, "func1: cannot
establish connection", NULL);
} else {
fprintf(stderr,"connected to db, getting dbInfo");
mi_get_database_info(conn,dbInfo);
fprintf(stderr,"User is %s", dbInfo->user_name);
mi_close(conn);
}

It fails on the mi_get_database_info(conn,dbinfo); line. FWIW, it
fails with the exact same message (argument 2 is null) even if I use
mi_get_default_database_info(dbInfo); which only has 1 parameter.

I can't find any examples of mi_get_database_info...what am I doing
wrong?

Thanks,

Bret

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 04:17 PM
Madison Pruet
 
Posts: n/a
Default Re: What's wrong with this C UDR?

bret@welcometolazyhill.com wrote:
> I'm trying to do some basic stuff in a C UDR. Following the docs,
> mi_get_database_info takes a MI_CONNECTION* and a MI_DATABASE_INFO*.
> However, the following causes Informix to give me "7520: Argument (2)
> is NULL", which means a NULL was sent and Informix didn't expect it:
>
> MI_CONNECTION *conn;
> MI_DATABASE_INFO *dbInfo;
> char* cpToEncrypt;
> mi_lvarchar* cpOut;
> fprintf(stderr,"encryptVarchar - entered");
>
> cpOut = mi_var_copy(toEncrypt);
> cpToEncrypt = mi_get_vardata(cpOut);


You need to allocate the dbInfo struct.
>
> conn = mi_open(NULL, NULL, NULL);
> /* If connection descriptor is NULL, there was an error *
> connecting to the session context. */
> if ( conn == NULL ) {
> mi_db_error_raise(conn, MI_EXCEPTION, "func1: cannot
> establish connection", NULL);
> } else {
> fprintf(stderr,"connected to db, getting dbInfo");
> mi_get_database_info(conn,dbInfo);
> fprintf(stderr,"User is %s", dbInfo->user_name);
> mi_close(conn);
> }
>
> It fails on the mi_get_database_info(conn,dbinfo); line. FWIW, it
> fails with the exact same message (argument 2 is null) even if I use
> mi_get_default_database_info(dbInfo); which only has 1 parameter.
>
> I can't find any examples of mi_get_database_info...what am I doing
> wrong?
>
> Thanks,
>
> Bret
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com