Re: RE: Re: [freetds] SQLPutData error

brazilchina at mail.goo.ne.jp brazilchina at mail.goo.ne.jp
Mon Mar 15 23:24:29 EST 2004


Thanks for your reply.

> It's not clear to me what you're doing. In SQLBindParameter(),
> you specify a parameter buffer size of zero, but in SQLPutData(),
> you pass it a buffer of 3 bytes, not zero. 

I mistook.
I executed last program, because I have wanted to test a function "SQLPutData".
Finally I intend to insert long size binary data.

> I think if you change your description of the size of cbName, your code will work (better).

My code worked when I changed the size of cbName.But I have another question.
I can't have expected result when executing below code.
The result that I expect is "abcdefg", but "efg at 0・".

---------------------------------------------------------------------
int testPutData( SQLHSTMT hstmt ){
	int rc;
	int i;
	
	SQLINTEGER ind;
	SQLPOINTER ptr;
	char test_text[] = "abcdefg";
	int len = strlen( test_text );
	
	//SQLBindParameter
	rc = SQLBindParameter( hstmt,
						1,
						SQL_PARAM_INPUT,
						SQL_C_CHAR,
						SQL_VARCHAR,
						0,
						0,
						(SQLPOINTER)123,
						0,
						&ind);
	if( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO ){
		exit(1);
	}
	ind = SQL_LEN_DATA_AT_EXEC(len);
	
	//SQLPrepare
	//CREATE TABLE TEST_TABLE (c VARCHAR(255) NULL, b VARBINARY(255) NULL)
	rc = SQLPrepare( hstmt, (SQLCHAR *) "INSERT INTO TEST_TABLE(c) VALUES(?)", SQL_NTS);
	if( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO ){
		exit(1);
	}

	//SQLExecute
	rc = SQLExecute( hstmt );
	while( rc == SQL_NEED_DATA ){
		rc = SQLParamData( hstmt, &ptr );
		if( rc == SQL_NEED_DATA ){
			if( ptr == (SQLPOINTER)123 ){
				SQLPutData( hstmt, test_text, len);
			}
		}
	}
	return 0;
}
---------------------------------------------------------------------



More information about the FreeTDS mailing list