当前位置: 首页>>代码示例>>C++>>正文


C++ SQLBindParameter函数代码示例

本文整理汇总了C++中SQLBindParameter函数的典型用法代码示例。如果您正苦于以下问题:C++ SQLBindParameter函数的具体用法?C++ SQLBindParameter怎么用?C++ SQLBindParameter使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SQLBindParameter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DB_WriteTaxGenCodeRec

/* Write an SLRITaxonGencode record to the database */
Int2 DB_WriteTaxGenCodeRec(SLRITaxonGencodePtr stgp)
{
   Int4 bsLength=0;
   Int4 gencode_id;
   CharPtr asn1; 
    pABL Asnbuflen=NULL;

  	if(stgp == NULL) {
		ErrPostEx(SEV_INFO, 3, 0, "DB_WriteTaxGenCodeRec: Passed ASN.1 pointer is null.");
		return(-1);
	}

   /*get the asn1 bioseq into a bytestore pointer so that we can put it into a buffer.*/
  Asnbuflen = AssignASNMemChar((Pointer) stgp, (AsnWriteFunc) SLRITaxonGencodeAsnWrite);
  /* SK: NULL ptr check */
  if(Asnbuflen == NULL)
  {
    ErrPostEx(SEV_INFO, 3, 0, "DB_WriteTaxGenCodeRec: NULL Asnbuflen.");
    return(-1);
  }

  asn1 = Asnbuflen->buf;
  bsLength = Asnbuflen->len;     
   
   /*set up the input parameters */
  SQLBindParameter(hstmt_gcode, 1, SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0, 0, &gencode_id, 0, NULL);
  SQLBindParameter(hstmt_gcode, 2, SQL_PARAM_INPUT, SQL_C_DEFAULT,SQL_BLOB, 0, 0, asn1, 0, (long*)&bsLength);

 gencode_id = stgp->gencode_id;
	
  /* execute statment */
  if (SQLExecute (hstmt_gcode) != SQL_SUCCESS){
    ErrPostEx(SEV_ERROR,0,0, "DB_WriteTaxGenCodeRec: unable to execute insert statement. ");
    print_err(hstmt_gcode);
    return FALSE;
  }

  asn1 = MemFree(asn1);
  /*  pABLtmp->buf = MemFree(pABLtmp->buf);*/
  FreeABL(Asnbuflen); 
   return TRUE;

}
开发者ID:iandonaldson,项目名称:slri,代码行数:44,代码来源:taxdb_db2.c

示例2: backsql_BindParamStr

/*
 * Turned into macros --- see sql-wrap.h
 */
RETCODE
backsql_BindParamStr( SQLHSTMT sth, int par_ind, char *str, int maxlen )
{
	RETCODE		rc;

	rc = SQLBindParameter( sth, (SQLUSMALLINT)par_ind, SQL_PARAM_INPUT,
			SQL_C_CHAR, SQL_VARCHAR,
         		(SQLUINTEGER)maxlen, 0, (SQLPOINTER)str,
			(SQLUINTEGER)maxlen, NULL );
	return rc;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:14,代码来源:sql-wrap.c

示例3: bind_value

 void bind_value(T val, int index)
 {
   value_t *v = new value_t;
   v->data = new char[sizeof(T)];
   *static_cast<T*>(v->data) = val;
   host_data_.push_back(v);
   
   int ctype = mssql_statement::type2int(type_traits<T>::data_type());
   int type = mssql_statement::type2sql(type_traits<T>::data_type());
   SQLRETURN ret = SQLBindParameter(stmt_, index, SQL_PARAM_INPUT, ctype, type, 0, 0, v->data, 0, &v->len);
   throw_error(ret, SQL_HANDLE_STMT, stmt_, "mssql", "couldn't bind parameter");
 }
开发者ID:dlnufox,项目名称:oos,代码行数:12,代码来源:mssql_statement.hpp

示例4: SQLBindParameter

bool DbHelper::BindParamFloat(float* param)
{
	SQLRETURN ret = SQLBindParameter(mCurrentSqlHstmt, mCurrentBindParam++, SQL_PARAM_INPUT,
		SQL_C_FLOAT, SQL_REAL, 7, 0, param, 0, NULL);

	if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret)
	{
		PrintSqlStmtError();
		return false;
	}

	return true;
}
开发者ID:trizdreaming,项目名称:NHN-NEXT-GameServerProgramming,代码行数:13,代码来源:DBHelper.cpp

示例5: Test

static void
Test(const char *bind1, SQLSMALLINT type1, const char *bind2, SQLSMALLINT type2)
{
	char sql[512];
	char *val = "test";
	SQLLEN ind = 4;
	int id = 1;

	SQLFreeStmt(Statement, SQL_RESET_PARAMS);

	++test_num;
	sprintf(sql, "insert into #test_output values (%s, %s)", bind1, bind2);

	success(2, SQLPrepare(Statement, (SQLCHAR *) sql, strlen(sql)));
	if (bind1[0] == '?')
		success(3, SQLBindParameter(Statement, id++, SQL_PARAM_INPUT, SQL_C_LONG, type1, 3, 0, &test_num, 0, &ind));
	if (bind2[0] == '?')
		success(4,
			SQLBindParameter(Statement, id++, SQL_PARAM_INPUT, SQL_C_CHAR, type2, strlen(val) + 1, 0, (SQLCHAR *) val,
					 0, &ind));
	success(5, SQLExecute(Statement));
}
开发者ID:dparnell,项目名称:freetds,代码行数:22,代码来源:convert_error.c

示例6: DB_GetTaxMergedNodeRecNewTIDByOldTID

/* Get a new Tax ID given an old Tax ID from the merged node database */
Int4 DB_GetTaxMergedNodeRecNewTIDByOldTID(Int4 oldTaxId)
{
CharPtr search_mergeddb = "select new_taxid from seqhound.mergedtaxdb where old_taxid=?";
   SQLHANDLE hstmt;
   Int4 new_value = -1;
   Int2 sqlrc=SQL_SUCCESS;
   struct{
     Int4 len;
     Int4 val;
   }new_id;
 
   /* search merged db*/
   CreateHandle(&hstmt,search_mergeddb,&henv, &hdbc);

  SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0, 0, &oldTaxId, 0, NULL);

  /* set auto commit on */
   SQLSetConnectAttr( hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_NTS);  

  /* execute statment */
  if (SQLExecute(hstmt) != SQL_SUCCESS){
	ErrPostEx(SEV_ERROR,0,0,"DB_GetTaxMergedNodeRecNewTIDByOldTID:unable to execute select statement.");
	print_err(hstmt);
	SQLFreeStmt(hstmt, SQL_DROP);
	return FALSE;
  }

  SQLBindCol(hstmt,1,SQL_C_LONG,&new_id.val,10,(long*)&new_id.len); 
 
  sqlrc = SQLFetch(hstmt);
  if(sqlrc == SQL_NO_DATA_FOUND){
    ErrPostEx(SEV_INFO, 0, 0, "Old Tax ID: %ld not found in Mergedtaxdb.", oldTaxId);
	return(-1);
  }
  else if(sqlrc == SQL_SUCCESS || sqlrc == SQL_SUCCESS_WITH_INFO){
    new_value = new_id.val; 
	}
  else{
    print_err(hstmt);
    return (-1);
  }

   /* Free statement handle. */
   if(SQLFreeStmt(hstmt, SQL_DROP) != SQL_SUCCESS){
     print_err(hstmt);
     return (-1);
   }
   return(new_value);

}
开发者ID:iandonaldson,项目名称:slri,代码行数:51,代码来源:taxdb_db2.c

示例7: InsertTest

//*************************************************************************
int  InsertTest(SQLHANDLE env,SQLHANDLE dbc,SQLHANDLE stmt)
{
         
      SQLRETURN  ret;
      int f1=0; // f1 field
      char f2[15]="jitendra";//f2 field
      SQLINTEGER slen=SQL_NTS;
      
      ret = SQLPrepare(stmt,(unsigned char*)"INSERT INTO T1 VALUES(?,?)",SQL_NTS);
      checkrc(ret,__LINE__);

      // BIND PARAMETER

      ret = SQLBindParameter(stmt,1,SQL_PARAM_INPUT,SQL_C_LONG,SQL_INTEGER,0,0,&f1,0,NULL);
      checkrc(ret,__LINE__);

      ret = SQLBindParameter(stmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,196,0,(void*)f2,0,&slen);
      checkrc(ret,__LINE__);

    

      int i,count=0;
      for(i=0;i<1000;i++)
      {
         f1++;
         
         
         ret = SQLExecute(stmt);
         checkrc(ret,__LINE__);
        
         ret = SQLTransact(env,dbc,SQL_COMMIT);
         checkrc(ret,__LINE__);
         count++;
      } 
      printf("Total row inserted=%d\n",count);
      return 0;
  }
开发者ID:mattibickel,项目名称:csql,代码行数:38,代码来源:nonselectdml1nw.c

示例8: InsertTest

//*************************************************************************
int  InsertTest(SQLHANDLE env,SQLHANDLE dbc,SQLHANDLE stmt)
{
         
      int ret;
      int f1=90; // f1 field
      int f2=20;//f2 field
 
      
      ret = SQLPrepare(stmt,(unsigned char*)"INSERT INTO T1 VALUES(?,?)",SQL_NTS);
      checkrc(ret,__LINE__);

      // BIND PARAMETER

      ret = SQLBindParameter(stmt,1,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&f1,0,NULL);
      checkrc(ret,__LINE__);

      ret = SQLBindParameter(stmt,2,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGER,0,0,&f2,0,NULL);
      checkrc(ret,__LINE__);

    

      int i,count=0;
      for(i=0;i<10;i++)
      {
         f1++;
         f2++;
         
         ret = SQLExecute(stmt);
         checkrc(ret,__LINE__);
        
         ret = SQLTransact(env,dbc,SQL_COMMIT);
         checkrc(ret,__LINE__);
         count++;
      } 
      printf("Total row inserted=%d\n",count);
      return 0;
  }
开发者ID:mattibickel,项目名称:csql,代码行数:38,代码来源:odbcselect6.c

示例9: BindTickVariables

void BindTickVariables(DBHandles *d, DataFeedData *df)
{
    SQLRETURN r;

    //tickId, timestamp, last, lastSize, totalVol, bid, ask, bidSize, askSize
    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_INTEGER, 4, 0, df->tickId, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_TIMESTAMP, 19, 0, df->timestamp, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->last, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, -5, 8, 0, df->lastSize, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_INTEGER, 8, 0, df->totalVol, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->bid, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_DECIMAL, 20, 8, df->ask, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, -5, 8, 0, df->bidSize, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, -5, 8, 0, df->askSize, SIZE, &df->stringLength)))
        throw DataException(__FILE__, __LINE__);

    if (o.isOption == true || o.isFutures == true || o.useContract == true) {
        if (!SQL_SUCCEEDED(r = SQLBindParameter(d->hstmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, OPTION_SYMBOL_LENGTH, 0, (SQLPOINTER) df->symbol, (SQLINTEGER) strlen(df->symbol), &df->stringLength)))
            throw DataException(__FILE__, __LINE__);
    }
}
开发者ID:steve8918,项目名称:iqdata,代码行数:37,代码来源:main.cpp

示例10: main

int
main(int argc, char *argv[])
{
	SQLLEN cb = SQL_NTS;

	odbc_use_version3 = 1;

	odbc_connect();

	odbc_command_with_result(odbc_stmt, "drop proc sp_paramcore_test");
	odbc_command("create proc sp_paramcore_test @s varchar(100) output as select @s = '12345'");

	/* here we pass a NULL buffer for input SQL_NTS */
	CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, NULL, OUTSTRING_LEN, &cb, "S");

	cb = SQL_NTS;
	CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
	odbc_reset_statement();

	/* here we pass a NULL buffer for input */
	CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 18, 0, NULL, OUTSTRING_LEN, &cb, "S");

	cb = 1;
	CHKExecDirect(T(SP_TEXT), SQL_NTS, "E");
	odbc_reset_statement();

	odbc_command("drop proc sp_paramcore_test");
	odbc_command("create proc sp_paramcore_test @s numeric(10,2) output as select @s = 12345.6");
	odbc_reset_statement();

#if 0	/* this fails even on native platforms */
	/* here we pass a NULL buffer for output */
	cb = sizeof(SQL_NUMERIC_STRUCT);
	SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC, 18, 0, NULL, OUTSTRING_LEN, &cb);
	odbc_read_error();

	cb = 1;
	odbc_command_with_result(odbc_stmt, SP_TEXT);
	odbc_read_error();
	odbc_reset_statement();
#endif

	odbc_command("drop proc sp_paramcore_test");

	odbc_disconnect();

	printf("Done successfully!\n");
	return 0;
}
开发者ID:DavidRueter,项目名称:freetds,代码行数:49,代码来源:paramcore.c

示例11: SQLBindParameter

bool DbHelper::BindParamInt(int* param)
{
	//todo: int형 파라미터 바인딩
	SQLRETURN ret = SQLBindParameter( mCurrentSqlHstmt, mCurrentBindParam++, SQL_PARAM_INPUT, 
		SQL_C_SLONG, SQL_INTEGER, 4, 0, param, 0, NULL ); ///# 저기에서 4의 의미는?? 맞다고 생각?
	// WIP

	if (SQL_SUCCESS != ret && SQL_SUCCESS_WITH_INFO != ret)
	{
		PrintSqlStmtError();
		return false;
	}

	return true;
}
开发者ID:wooq17,项目名称:NHNNEXT_2014_GAME_SERVER,代码行数:15,代码来源:DBHelper.cpp

示例12: BindParameter

		void BindParameter(int index, SQLSMALLINT fParamType,
			SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef,
			SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax,
			SQLLEN *pcbValue)
		{
			assert(index > 0);
			SQLRETURN rc = 0;

			rc = SQLBindParameter(mStmt, index, fParamType, fCType, fSqlType,
				cbColDef, ibScale, rgbValue, cbValueMax, pcbValue);
			if (!SQL_SUCCEEDED(rc))
			{
				std::string message;
				HANAException::GetHANAErrorMessage(SQL_HANDLE_STMT, mStmt, rc, message);
				throw HANAException(message.c_str());
			}
		}	
开发者ID:zhaojunlucky,项目名称:veda,代码行数:17,代码来源:HANAStatement.hpp

示例13: __bind_param

	void __bind_param(HSTMT _stmt, int _parnum,
						SQLSMALLINT _ctype, SQLSMALLINT _sqltype,
						void * dst_buf, SQLLEN & StrLenOrInPoint,
						int sz = 0, int buf_sz = 0)
	{
		RETCODE rc = SQLBindParameter(_stmt,
			_parnum,
			SQL_PARAM_INPUT,
			_ctype,
			_sqltype,
			sz,
			0,
			(SQLPOINTER *)dst_buf,
			buf_sz,
			&StrLenOrInPoint);
		if (!TIODBC_SUCCESS_CODE(rc))
			throw bind_error(_parnum);
	}
开发者ID:CarverLab,项目名称:yb-orm,代码行数:18,代码来源:tiodbc.cpp

示例14: output

/**
  Internal function to test sending a SQL_NUMERIC_STRUCT value.

  @todo Printing some additional output (sqlnum->val as hex, dec)

  @param[in]  hstmt       Statement handle
  @param[in]  numdata     Numeric data
  @param[in]  prec        Precision to send
  @param[in]  scale       Scale to send
  @param[in]  sign        Sign (1=+,0=-)
  @param[in]  outstr      Expected result string
  @param[in]  exptrunc    Expected truncation failure
  @return OK/FAIL just like a test.
*/
int sqlnum_test_to_str(SQLHANDLE Stmt, SQLCHAR *numdata, SQLCHAR prec,
                       SQLSCHAR scale, SQLCHAR sign, char *outstr,
                       char *exptrunc)
{
  SQL_NUMERIC_STRUCT *sqlnum= malloc(sizeof(SQL_NUMERIC_STRUCT));
  SQLCHAR obuf[30];
  SQLRETURN exprc= SQL_SUCCESS;

  /* TODO until sqlnum errors are supported */
  /*
  if (!strcmp("01S07", exptrunc))
    exprc= SQL_SUCCESS_WITH_INFO;
  else if (!strcmp("22003", exptrunc))
    exprc= SQL_ERROR;
  */

  sqlnum->sign= sign;
  memcpy(sqlnum->val, numdata, SQL_MAX_NUMERIC_LEN);

  CHECK_HANDLE_RC(SQL_HANDLE_STMT, Stmt, SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_NUMERIC,
                                  SQL_DECIMAL, prec, scale, sqlnum, 0, NULL));

  OK_SIMPLE_STMT(Stmt, "select ?");

  exprc= SQLFetch(Stmt);
  if (exprc != SQL_SUCCESS)
  {
    IS(check_sqlstate(Stmt, (char *)exptrunc) == OK);
  }
  if (exprc == SQL_ERROR)
    return OK;
  is_num(sqlnum->precision, prec);
  is_num(sqlnum->scale, scale);
  is_num(sqlnum->sign, sign);
  CHECK_HANDLE_RC(SQL_HANDLE_STMT, Stmt, SQLGetData(Stmt, 1, SQL_C_CHAR, obuf, sizeof(obuf), NULL));
  diag("compare %s - %s", obuf, outstr);
  IS_STR(obuf, outstr, strlen(outstr));
  FAIL_IF(memcmp(sqlnum->val, numdata, SQL_MAX_NUMERIC_LEN), "memcmp failed");

  CHECK_HANDLE_RC(SQL_HANDLE_STMT, Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

  free(sqlnum);
  return OK;
}
开发者ID:ipaste,项目名称:mariadb-connector-odbc,代码行数:58,代码来源:types.c

示例15: ODBC_Execute

int
ODBC_Execute()
{

  SQLCHAR *      Statement = "select * from BTEST where id > ?";
  SQLUINTEGER    IDArray[ARRAY_SIZE];

  SQLINTEGER     IDIndArray[ARRAY_SIZE];

  SQLUSMALLINT   i, ParamStatusArray[ARRAY_SIZE];
  SQLUINTEGER    ParamsProcessed;

  if (SQLParamOptions(hstmt, ARRAY_SIZE, &ParamsProcessed) != SQL_SUCCESS)
    {
      ODBC_Errors ("ODBC_Execute");
      return -1;
    }

  IDArray[0] = 3;  IDIndArray[0] = 0;
  IDArray[1] = 2;  IDIndArray[1] = 0;
  IDArray[2] = 1;  IDIndArray[2] = 0;

  /*    Bind the parameters in column-wise fashion. */
  if (SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, IDArray, 0, IDIndArray) != SQL_SUCCESS)
    {
      ODBC_Errors ("ODBC_Execute");
      return -1;
    }


  /*   Execute the statement. */
  if (SQLExecDirect(hstmt, Statement, SQL_NTS) != SQL_SUCCESS)
    {
      ODBC_Errors ("ODBC_Execute");
      return -1;
    }

  /*    Check to see which sets of parameters were processed successfully. */
  printf("Parameter Sets Processed = %d\n",ParamsProcessed);
  printf("--------------------------------------\n");
  return 0;
}
开发者ID:Rahien,项目名称:virtuoso-opensource,代码行数:42,代码来源:b3078.c


注:本文中的SQLBindParameter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。