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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| ||||
| 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 > |