Ejemplo n.º 1
0
SQLRETURN SQLForeignKeysA(
    SQLHSTMT           statement_handle,
    SQLCHAR            *szpk_catalog_name,
    SQLSMALLINT        cbpk_catalog_name,
    SQLCHAR            *szpk_schema_name,
    SQLSMALLINT        cbpk_schema_name,
    SQLCHAR            *szpk_table_name,
    SQLSMALLINT        cbpk_table_name,
    SQLCHAR            *szfk_catalog_name,
    SQLSMALLINT        cbfk_catalog_name,
    SQLCHAR            *szfk_schema_name,
    SQLSMALLINT        cbfk_schema_name,
    SQLCHAR            *szfk_table_name,
    SQLSMALLINT        cbfk_table_name )
{
    return SQLForeignKeys( statement_handle,
                            szpk_catalog_name,
                            cbpk_catalog_name,
                            szpk_schema_name,
                            cbpk_schema_name,
                            szpk_table_name,
                            cbpk_table_name,
                            szfk_catalog_name,
                            cbfk_catalog_name,
                            szfk_schema_name,
                            cbfk_schema_name,
                            szfk_table_name,
                            cbfk_table_name );
}
Ejemplo n.º 2
0
/* display foreign keys, from this table to others */
bool
fetchForeign(char *tname)
{
    char farschema[40], fartab[40];
    char farcol[40];
    char nearcol[40];
    SQLLEN nearcolOut, farschemaOut, fartabOut, farcolOut;
    char *dot;

    newStatement();
    stmt_text = "foreign keys";
    debugStatement();

    dot = strchr(tname, '.');
    if(dot)
	*dot++ = 0;

    rc = SQLForeignKeys(hstmt,
       NULL, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS,
       NULL, SQL_NTS,
       (dot ? tname : NULL), SQL_NTS, (dot ? dot : tname), SQL_NTS);
    if(dot)
	dot[-1] = '.';
    if(rc)
	goto abort;

    SQLBindCol(hstmt, 2, SQL_CHAR, (SQLPOINTER) farschema, sizeof (farschema),
       &farschemaOut);
    SQLBindCol(hstmt, 3, SQL_CHAR, (SQLPOINTER) fartab, sizeof (fartab),
       &fartabOut);
    SQLBindCol(hstmt, 4, SQL_CHAR, (SQLPOINTER) farcol, sizeof (farcol),
       &farcolOut);
    SQLBindCol(hstmt, 8, SQL_CHAR, (SQLPOINTER) nearcol, sizeof (nearcol),
       &nearcolOut);

    while(SQLFetch(hstmt) == SQL_SUCCESS) {
	printf("%s > ", nearcol);
	if(farschema[0])
	    printf("%s.", farschema);
	printf("%s.%s\n", fartab, farcol);
    }

    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    return true;

  abort:
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    return false;
}				/* fetchForeign */
Ejemplo n.º 3
0
SQLRETURN SQL_API
SQLForeignKeysA(SQLHSTMT StatementHandle,
		SQLCHAR *PKCatalogName,
		SQLSMALLINT NameLength1,
		SQLCHAR *PKSchemaName,
		SQLSMALLINT NameLength2,
		SQLCHAR *PKTableName,
		SQLSMALLINT NameLength3,
		SQLCHAR *FKCatalogName,
		SQLSMALLINT NameLength4,
		SQLCHAR *FKSchemaName,
		SQLSMALLINT NameLength5,
		SQLCHAR *FKTableName,
		SQLSMALLINT NameLength6)
{
	return SQLForeignKeys(StatementHandle, PKCatalogName, NameLength1,
			      PKSchemaName, NameLength2,
			      PKTableName, NameLength3,
			      FKCatalogName, NameLength4,
			      FKSchemaName, NameLength5,
			      FKTableName, NameLength6);
}
Ejemplo n.º 4
0
/************************************************************************
* name: SQLForeignKeysW
* arguments:
* returns/side-effects:
* description:
* NOTE:
************************************************************************/
ODBC_INTERFACE RETCODE SQL_API
SQLForeignKeysW (SQLHSTMT hstmt,
                 SQLWCHAR *pk_catalog, SQLSMALLINT pk_catalog_len,
                 SQLWCHAR *pk_schema, SQLSMALLINT pk_schema_len,
                 SQLWCHAR *pk_table, SQLSMALLINT pk_table_len,
                 SQLWCHAR *fk_catalog, SQLSMALLINT fk_catalog_len,
                 SQLWCHAR *fk_schema, SQLSMALLINT fk_schema_len,
                 SQLWCHAR *fk_table, SQLSMALLINT fk_table_len)
{
  RETCODE ret = ODBC_ERROR;
  char *cb_pk_catalog = NULL,  *cb_pk_schema = NULL, *cb_pk_table = NULL,
          *cb_fk_catalog = NULL,   *cb_fk_schema = NULL,  *cb_fk_table = NULL;
  int  cb_pk_catalog_len = 0,  cb_pk_schema_len = 0, cb_pk_table_len = 0,
         cb_fk_catalog_len = 0,   cb_fk_schema_len = 0,  cb_fk_table_len = 0;

  OutputDebugString ("SQLForeignKeysW called.\n"); 
  wide_char_to_bytes (pk_catalog, pk_catalog_len, &cb_pk_catalog, &cb_pk_catalog_len, NULL);
  wide_char_to_bytes (pk_schema, pk_schema_len, &cb_pk_schema, &cb_pk_schema_len, NULL);
  wide_char_to_bytes (pk_table, pk_table_len, &cb_pk_table, &cb_pk_table_len, NULL);
  wide_char_to_bytes (fk_catalog, fk_catalog_len, &cb_fk_catalog, &cb_fk_catalog_len, NULL);
  wide_char_to_bytes (fk_schema, fk_schema_len, &cb_fk_schema, &cb_fk_schema_len, NULL);
  wide_char_to_bytes (fk_table, fk_table_len, &cb_fk_table, &cb_fk_table_len, NULL);
        
  ret = SQLForeignKeys(hstmt, 
                                       cb_pk_catalog, cb_pk_catalog_len, cb_pk_schema, cb_pk_schema_len,
                                       cb_pk_table, cb_pk_table_len, cb_fk_catalog, cb_fk_catalog_len,
                                       cb_fk_schema, cb_fk_schema_len, cb_fk_table, cb_fk_table_len);
  
  UT_FREE(cb_pk_catalog);
  UT_FREE(cb_pk_schema);
  UT_FREE(cb_pk_table);
  UT_FREE(cb_fk_catalog);
  UT_FREE(cb_fk_schema);
  UT_FREE(cb_fk_table);
  return ret;
}
Ejemplo n.º 5
0
static int odbc_dispatch19(void)
{
	unsigned long retval;
	PWord rval; int rtype;
	PWord arg1; int type1;
	PWord arg2; int type2;
	PWord arg3; int type3;
	PWord arg4; int type4;
	PWord arg5; int type5;
	PWord arg6; int type6;
	PWord arg7; int type7;
	PWord arg8; int type8;
	PWord arg9; int type9;
	PWord arg10; int type10;
	PWord arg11; int type11;
	PWord arg12; int type12;
	PWord arg13; int type13;
	PWord arg14; int type14;
	PWord arg15; int type15;

	PI_getan(&arg1,&type1,1);
	if (type1 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg1,type1))
			PI_FAIL;
	PI_getan(&arg2,&type2,2);
	if (type2 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg2,type2))
			PI_FAIL;
	PI_getan(&arg3,&type3,3);
	if (type3 == PI_SYM)
		arg3 = (unsigned long) PI_getsymname(0,arg3,0);
	else if (!CI_get_integer((unsigned long *)&arg3,type3))
		PI_FAIL;
	PI_getan(&arg4,&type4,4);
	if (type4 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg4,type4))
			PI_FAIL;
	PI_getan(&arg5,&type5,5);
	if (type5 == PI_SYM)
		arg5 = (unsigned long) PI_getsymname(0,arg5,0);
	else if (!CI_get_integer((unsigned long *)&arg5,type5))
		PI_FAIL;
	PI_getan(&arg6,&type6,6);
	if (type6 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg6,type6))
			PI_FAIL;
	PI_getan(&arg7,&type7,7);
	if (type7 == PI_SYM)
		arg7 = (unsigned long) PI_getsymname(0,arg7,0);
	else if (!CI_get_integer((unsigned long *)&arg7,type7))
		PI_FAIL;
	PI_getan(&arg8,&type8,8);
	if (type8 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg8,type8))
			PI_FAIL;
	PI_getan(&arg9,&type9,9);
	if (type9 == PI_SYM)
		arg9 = (unsigned long) PI_getsymname(0,arg9,0);
	else if (!CI_get_integer((unsigned long *)&arg9,type9))
		PI_FAIL;
	PI_getan(&arg10,&type10,10);
	if (type10 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg10,type10))
			PI_FAIL;
	PI_getan(&arg11,&type11,11);
	if (type11 == PI_SYM)
		arg11 = (unsigned long) PI_getsymname(0,arg11,0);
	else if (!CI_get_integer((unsigned long *)&arg11,type11))
		PI_FAIL;
	PI_getan(&arg12,&type12,12);
	if (type12 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg12,type12))
			PI_FAIL;
	PI_getan(&arg13,&type13,13);
	if (type13 == PI_SYM)
		arg13 = (unsigned long) PI_getsymname(0,arg13,0);
	else if (!CI_get_integer((unsigned long *)&arg13,type13))
		PI_FAIL;
	PI_getan(&arg14,&type14,14);
	if (type14 != PI_INT)
		if (!CI_get_integer((unsigned long *)&arg14,type14))
			PI_FAIL;
	PI_getan(&arg15,&type15,15);


	switch(arg1)
	{
		case 0:
			retval = (unsigned long) SQLForeignKeys(((SQLHSTMT  ) arg2),((SQLCHAR * ) arg3),((SQLSMALLINT  ) arg4),((SQLCHAR * ) arg5),((SQLSMALLINT  ) arg6),((SQLCHAR * ) arg7),((SQLSMALLINT  ) arg8),((SQLCHAR * ) arg9),((SQLSMALLINT  ) arg10),((SQLCHAR * ) arg11),((SQLSMALLINT  ) arg12),((SQLCHAR * ) arg13),((SQLSMALLINT  ) arg14));
			break;
		default:
			PI_FAIL;
	}
	PI_makedouble(&rval,&rtype,(double) retval);
	if (PI_unify(arg15,type15,rval,rtype))
		PI_SUCCEED;
	PI_FAIL;
}
Ejemplo n.º 6
0
void get_foreign_keys()
{
	printf("get_foreign_keys\n");
	SQLHENV env;
	SQLHDBC dbc;
	
	SQLRETURN ret; /* ODBC API return status */
	SQLCHAR outstr[1024];
	SQLSMALLINT outstrlen;
	
	/* Allocate an environment handle */
	SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
	/* We want ODBC 3 support */
	SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
	/* Allocate a connection handle */
	SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
	
	ret = SQLDriverConnect(dbc, NULL, inString, SQL_NTS, outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
	if (SQL_SUCCEEDED(ret)) { printf("connected. Returned connection string was:\n\t%s\n", outstr);
		if (ret == SQL_SUCCESS_WITH_INFO) {
			printf("Driver reported the following diagnostics\n");
			extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
		}
	} else {
		printf("Failed to connect\n");
		extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
		SQLFreeHandle(SQL_HANDLE_DBC, dbc);
		SQLFreeHandle(SQL_HANDLE_ENV, env);
	}
	/*-------------------------------------------------*/
	SQLHSTMT stmt;
	SQLSMALLINT columns; /* number of columns in result-set */
	SQLCHAR bufChar[10][64];
	SQLSMALLINT bufSmallInt[4];
	SQLINTEGER indicator[5];
	
	ret = SQLAllocStmt(dbc, &stmt);
	if (ret != SQL_SUCCESS) {
		extract_error("SQLAllocStmt", dbc, SQL_HANDLE_DBC); return;
	}
	
	SQLTables(stmt, NULL, SQL_NTS, (SQLCHAR*)"installdb3", SQL_NTS, (SQLCHAR*)"", SQL_NTS, (SQLCHAR*)"TABLE", SQL_NTS );
	/* How many columns are there */
	
	SQLNumResultCols(stmt, &columns);
	
	/* Loop through the rows in the result-set binding to */
	/* local variables */
	int i;
	for (i = 0; i < columns; i++) {
		SQLBindCol( stmt, i + 1, SQL_C_CHAR, bufChar[i], sizeof( bufChar[i] ), &indicator[i] );
	}
	
	/* Fetch the data */
	while (SQL_SUCCEEDED(SQLFetch(stmt))) {
		/* display the results that will now be in the bound area's */
		for ( i = 0; i < columns; i ++ ) {
			if (indicator[ i ] == SQL_NULL_DATA) { 
				//				printf("  Column %u : NULL\n", i); 
			}
			else {
				if (strlen((char*)(bufChar[i])) > 0) { 
					printf("  Column %u : %s\n", i, bufChar[i]);
					
				} 
				else { 
					//					printf("  Column %u : Empty string\n", i); 
				}
			}
		}
		printf("\n");
	}
	
	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
	
	/*----------------------------------*/
	SQLCHAR		errormsg[SQL_MAX_MESSAGE_LENGTH];
	ret = SQLAllocStmt(dbc, &stmt);
	if (ret != SQL_SUCCESS) {
		extract_error("SQLAllocStmt", dbc, SQL_HANDLE_DBC); return;
	}
	
	ret = SQLForeignKeys(stmt, 
						 NULL, 0, /* Primary catalog */ 
					  NULL, 0, /* Primary schema */
					  NULL, 0, /* Primary table */
					  (SQLCHAR*)"instaldb123", SQL_NTS, /* Foreign catalog */
						 (SQLCHAR*)"instaldb3", SQL_NTS, /* Foreign schema */
						  (SQLCHAR*)"eventtypes", SQL_NTS /* Foreign table */
						  );
						  if (ret != SQL_SUCCESS) {
							  
							  printf("error: %s\n", dbErrorMsg(env, dbc, stmt, &errormsg[0], SQL_MAX_MESSAGE_LENGTH));
						 printf("SQLForeignKeys - ret: %d\n", ret);
	extract_error("SQLForeignKeys", stmt, SQL_HANDLE_STMT); 
	return;
						  }
						  
						  SQLNumResultCols(stmt, &columns);
						  
						  SQLFreeHandle(SQL_HANDLE_STMT, stmt);
						  /*-------------------------------------------------*/
						  /* free up allocated handles */
						  SQLDisconnect(dbc);
						  SQLFreeHandle(SQL_HANDLE_DBC, dbc);
						  SQLFreeHandle(SQL_HANDLE_ENV, env);
}
Ejemplo n.º 7
0
void get_foreign_keys()
{
	printf("get_foreign_keys\n");
	SQLHENV env;
	SQLHDBC dbc;
	
	SQLRETURN ret; /* ODBC API return status */
	SQLCHAR outstr[1024];
	SQLSMALLINT outstrlen;
	
	/* Allocate an environment handle */
	SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
	/* We want ODBC 3 support */
	SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
	/* Allocate a connection handle */
	SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
	
	ret = SQLDriverConnect(dbc, NULL, inString, SQL_NTS, outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
	if (SQL_SUCCEEDED(ret)) { printf("connected. Returned connection string was:\n\t%s\n", outstr);
		if (ret == SQL_SUCCESS_WITH_INFO) {
			printf("Driver reported the following diagnostics\n");
			extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
			}
			} else {
				printf("Failed to connect\n");
				extract_error("SQLDriverConnect", dbc, SQL_HANDLE_DBC);
				SQLFreeHandle(SQL_HANDLE_DBC, dbc);
				SQLFreeHandle(SQL_HANDLE_ENV, env);
			}
			/*-------------------------------------------------*/
			SQLHSTMT stmt;
			SQLSMALLINT columns; /* number of columns in result-set */
			SQLCHAR bufChar[10][64];
			SQLSMALLINT bufSmallInt[4];
			SQLINTEGER indicator[5];
			
			/*----------------------------------*/
			SQLCHAR		errormsg[SQL_MAX_MESSAGE_LENGTH];
			ret = SQLAllocStmt(dbc, &stmt);
			if (ret != SQL_SUCCESS) {
				extract_error("SQLAllocStmt", dbc, SQL_HANDLE_DBC); return;
			}
			
			ret = SQLForeignKeys(stmt, 
			NULL, 0, /* Primary catalog */ 
			NULL, 0, /* Primary schema */
			NULL, 0, /* Primary table */
			NULL, 0, /* Foreign catalog */
			NULL, 0, /* Foreign schema */
			(SQLCHAR*)"ne_node_version", SQL_NTS /* Foreign table */
			);
			printf("SQLForeignKeys - ret: %d\n", ret);
			if (ret != SQL_SUCCESS) {
				
				printf("error: %s\n", dbErrorMsg(env, dbc, stmt, &errormsg[0], SQL_MAX_MESSAGE_LENGTH));
				extract_error("SQLForeignKeys", stmt, SQL_HANDLE_STMT); 
				return;
			}
			
			SQLNumResultCols(stmt, &columns);
			
			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
			/*-------------------------------------------------*/
			/* free up allocated handles */
			SQLDisconnect(dbc);
			SQLFreeHandle(SQL_HANDLE_DBC, dbc);
			SQLFreeHandle(SQL_HANDLE_ENV, env);
			}
Ejemplo n.º 8
0
int
main(int argc, char **argv)
{
	int rc;
	HSTMT hstmt = SQL_NULL_HSTMT;
	/* Cases where output is limited to relevant information only */
	SQLSMALLINT sql_tab_privileges_ids[6] = {1, 2, 3, 4, 6, 7};
	SQLSMALLINT sql_column_ids[6] = {1, 2, 3, 4, 5, 6};

	test_connect();

	rc = SQLAllocHandle(SQL_HANDLE_STMT, conn, &hstmt);
	if (!SQL_SUCCEEDED(rc))
	{
		print_diag("failed to allocate stmt handle", SQL_HANDLE_DBC, conn);
		exit(1);
	}

	/* Check for SQLGetTypeInfo */
	printf("Check for SQLTypeInfo\n");
	rc = SQLGetTypeInfo(hstmt, SQL_VARCHAR);
	CHECK_STMT_RESULT(rc, "SQLGetTypeInfo failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLTables */
	printf("Check for SQLTables\n");
	rc = SQLTables(hstmt, NULL, 0,
				   (SQLCHAR *) "public", SQL_NTS,
				   (SQLCHAR *) "%", SQL_NTS,
				   (SQLCHAR *) "TABLE", SQL_NTS);
	CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLColumns */
	printf("Check for SQLColumns\n");
	rc = SQLColumns(hstmt,
					NULL, 0,
					(SQLCHAR *) "public", SQL_NTS,
					(SQLCHAR *) "%", SQL_NTS,
					NULL, 0);
	CHECK_STMT_RESULT(rc, "SQLColumns failed", hstmt);
	print_result_meta(hstmt);
	/*
	 * Print only the 6 first columns, we do not want for example
	 * to get the OID in output, and this information looks to be
	 * enough.
	 */
	print_result_series(hstmt, sql_column_ids, 6);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLColumnPrivileges */
	//printf("Check for SQLColumnPrivileges\n");
	//rc = SQLColumnPrivileges(hstmt,
	//						 NULL, 0,
	//						 (SQLCHAR *) "public", SQL_NTS,
	//						 (SQLCHAR *) "testtab1", SQL_NTS,
	//						 (SQLCHAR *) "id", SQL_NTS);
	//CHECK_STMT_RESULT(rc, "SQLColumnPrivileges failed", hstmt);
	//print_result_meta(hstmt);
	//print_result(hstmt);
	//rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	//CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLSpecialColumns */
	printf("Check for SQLSpecialColumns\n");
	rc = SQLSpecialColumns(hstmt, SQL_ROWVER,
						   NULL, 0,
						   (SQLCHAR *) "public", SQL_NTS,
						   (SQLCHAR *) "testtab1", SQL_NTS,
						   SQL_SCOPE_SESSION,
						   SQL_NO_NULLS);
	CHECK_STMT_RESULT(rc, "SQLSpecialColumns failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/*
	 * Check for SQLStatistics. It is important to note that this function
	 * returns statistics like the number of pages used and the number of
	 * index scans.
	 */
	printf("Check for SQLStatistics\n");
	rc = SQLStatistics(hstmt,
					   NULL, 0,
					   (SQLCHAR *) "public", SQL_NTS,
					   (SQLCHAR *) "testtab1", SQL_NTS,
					   0, 0);
	CHECK_STMT_RESULT(rc, "SQLStatistics failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLPrimaryKeys */
	printf("Check for SQLPrimaryKeys\n");
	rc = SQLPrimaryKeys(hstmt,
						NULL, 0,
						(SQLCHAR *) "public", SQL_NTS,
						(SQLCHAR *) "testtab1", SQL_NTS);
	CHECK_STMT_RESULT(rc, "SQLPrimaryKeys failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLForeignKeys */
	printf("Check for SQLForeignKeys\n");
	rc = SQLForeignKeys(hstmt,
						NULL, 0,
						(SQLCHAR *) "public", SQL_NTS,
						(SQLCHAR *) "testtab1", SQL_NTS,
						NULL, 0,
						(SQLCHAR *) "public", SQL_NTS,
						(SQLCHAR *) "testtab_fk", SQL_NTS);
	CHECK_STMT_RESULT(rc, "SQLForeignKeys failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLProcedures */
	printf("Check for SQLProcedures\n");
	rc = SQLProcedures(hstmt,
					   NULL, 0,
					   (SQLCHAR *) "public", SQL_NTS,
					   (SQLCHAR *) "simple_add", SQL_NTS);
	CHECK_STMT_RESULT(rc, "SQLProcedures failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLProcedureColumns */
	printf("Check for SQLProcedureColumns\n");
	rc = SQLProcedureColumns(hstmt,
							 NULL, 0,
							 (SQLCHAR *) "public", SQL_NTS,
							 (SQLCHAR *) "simple_add", SQL_NTS,
							 NULL, 0);
	CHECK_STMT_RESULT(rc, "SQLProcedureColumns failed", hstmt);
	print_result_meta(hstmt);
	print_result(hstmt);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Check for SQLTablePrivileges */
	printf("Check for SQLTablePrivileges\n");
	rc = SQLTablePrivileges(hstmt,
							NULL, 0,
							(SQLCHAR *) "public", 0,
							(SQLCHAR *) "testtab1", SQL_NTS);
	CHECK_STMT_RESULT(rc, "SQLTablePrivileges failed", hstmt);
	print_result_meta(hstmt);
	print_result_series(hstmt, sql_tab_privileges_ids, 6);
	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/*
	 * Extra tests.
	 * Older versions of the driver had a bug in handling table-types lists
	 * longer than 32 entries. Check for that.
	 */
	rc = SQLTables(hstmt, "", SQL_NTS,
				   "public", SQL_NTS,
				   "testtab%", SQL_NTS,
				   "1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5, TABLES", SQL_NTS);

	CHECK_STMT_RESULT(rc, "SQLTables failed", hstmt);
	print_result(hstmt);

	rc = SQLFreeStmt(hstmt, SQL_CLOSE);
	CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);

	/* Clean up */
	test_disconnect();

	return 0;
}
Ejemplo n.º 9
0
Archivo: odbc.c Proyecto: kevinarpe/kx
ZK fk(K x,S s,H j){D d=d1(xj);U(d)R rs(SQLForeignKeys(d,(S)0,0,(S)0,0,(S)0,0,(S)0,0,(S)0,0,s,S0),d,j);}