Пример #1
0
static int
init(DBPROCESS * dbproc, const char *name)
{
	int res = 0;
	RETCODE rc;

	fprintf(stdout, "Dropping %s.%s..%s\n", SERVER, DATABASE, name);
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while ((rc=dbresults(dbproc)) == SUCCEED) {
		/* nop */
	}
	if (rc != NO_MORE_RESULTS)
		return 1;

	fprintf(stdout, "Creating %s.%s..%s\n", SERVER, DATABASE, name);
	sql_cmd(dbproc);
	sql_cmd(dbproc);

	if (dbsqlexec(dbproc) == FAIL) {
		res = 1;
	}
	while ((rc=dbresults(dbproc)) == SUCCEED) {
		dbprhead(dbproc);
		dbprrow(dbproc);
		while ((rc=dbnextrow(dbproc)) == REG_ROW) {
			dbprrow(dbproc);
		}
	}
	if (rc != NO_MORE_RESULTS)
		return 1;
	fprintf(stdout, "%s\n", res? "error" : "ok");
	return res;
}
Пример #2
0
static RETCODE
init_proc(DBPROCESS * dbproc, const char *name)
{
	RETCODE ret = FAIL;

	if (name[0] != '#') {
		fprintf(stdout, "Dropping procedure %s\n", name);
		add_bread_crumb();
		sprintf(cmd, "DROP PROCEDURE %s", name);
		dbcmd(dbproc, cmd);
		add_bread_crumb();
		dbsqlexec(dbproc);
		add_bread_crumb();
		while (dbresults(dbproc) != NO_MORE_RESULTS) {
			/* nop */
		}
		add_bread_crumb();
	}

	fprintf(stdout, "Creating procedure %s\n", name);
	sprintf(cmd, procedure_sql, name);
	dbcmd(dbproc, cmd);
	if ((ret = dbsqlexec(dbproc)) == FAIL) {
		add_bread_crumb();
		if (name[0] == '#')
			fprintf(stdout, "Failed to create procedure %s. Wrong permission or not MSSQL.\n", name);
		else
			fprintf(stdout, "Failed to create procedure %s. Wrong permission.\n", name);
	}
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
	return ret;
}
Пример #3
0
static RETCODE
init_proc(DBPROCESS * dbproc, const char *name)
{
	RETCODE ret = FAIL;

	if (name[0] != '#') {
		printf("Dropping procedure %s\n", name);
		sql_cmd(dbproc);
		dbsqlexec(dbproc);
		while (dbresults(dbproc) != NO_MORE_RESULTS) {
			/* nop */
		}
	}

	printf("Creating procedure %s\n", name);
	sql_cmd(dbproc);
	if ((ret = dbsqlexec(dbproc)) == FAIL) {
		if (name[0] == '#')
			printf("Failed to create procedure %s. Wrong permission or not MSSQL.\n", name);
		else
			printf("Failed to create procedure %s. Wrong permission.\n", name);
	}
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
	return ret;
}
Пример #4
0
static int
init(DBPROCESS * dbproc, const char *name)
{
	int res = 0;

	fprintf(stdout, "Dropping %s.%s..%s\n", SERVER, DATABASE, name);
	add_bread_crumb();
	sprintf(cmd, "if exists (select 1 from sysobjects where type = 'U' and name = '%s') drop table %s", name, name);
	dbcmd(dbproc, cmd);
	add_bread_crumb();
	dbsqlexec(dbproc);
	add_bread_crumb();
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
	add_bread_crumb();

	fprintf(stdout, "Creating %s.%s..%s\n", SERVER, DATABASE, name);

	dbcmd(dbproc, create_table_sql);

	if (dbsqlexec(dbproc) == FAIL) {
		add_bread_crumb();
		res = 1;
	}
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
	return res;
}
Пример #5
0
int
main(int argc, char **argv)
{
	LOGINREC *login;
	DBPROCESS *dbproc;

	read_login_info(argc, argv);
	printf("Starting %s\n", argv[0]);

	dbinit();

	printf("About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "t0011");

	printf("About to open\n");

	dbproc = dbopen(login, SERVER);
	if (strlen(DATABASE))
		dbuse(dbproc, DATABASE);
	dbloginfree(login);

	printf("Dropping table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("creating table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("insert\n");

	insert_row(dbproc);
	insert_row(dbproc);
	insert_row(dbproc);

	failed = select_rows(dbproc, STRINGBIND);

	dbexit();

	printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK"));
	return failed ? 1 : 0;
}
Пример #6
0
void Query::execute()
{
#ifdef MSSQL
	dbcmd(this->connector->conn_ptr, this->query.c_str() );
	if (dbsqlexec(this->connector->conn_ptr) == FAIL){
		// commits query to db connection 
		status = false;
	} else {
		status = true;
	}
#endif
#ifdef WATCHLIST_MYSQL

	MYSQL *id = &(connector->mysqlID);
	int stat = mysql_query(id, query.c_str());

	string error;

	if (stat){
		this->setStatus(false);
		this->setMessage(mysql_error(id));
	} else {
		this->setStatus(true);
	}
#endif
}
Пример #7
0
int save_pid_to_db(int id,char* pd)
{
   char szUsername[32] = "sa"; 
   char szPassword[32]= "1qazxsw2*";
   char szDBName[32] = "ids_db";
   char szServer[32] = "10.2.10.201";
   char   sqlquery[1024]={0};
   snprintf(sqlquery,1024,"update ids_policy_event set pid='%s' where id='%d'",pd,id);
   dbinit();
   LOGINREC *loginrec = dblogin();
   DBSETLUSER(loginrec, szUsername);
   DBSETLPWD(loginrec, szPassword);
   DBPROCESS *dbprocess = dbopen(loginrec, szServer);
   if(dbprocess == FAIL)
   {
    LOG_INFO(" Conect MS SQL SERVER fail       ");
    return -1;
   }
   if(dbuse(dbprocess, szDBName) == FAIL)
   {
    LOG_INFO(" Open database name fail");
    return -1;
   }
   dbcmd(dbprocess,sqlquery);
   if(dbsqlexec(dbprocess) == FAIL)
   {
    LOG_INFO("task.cpp dbsqlexec  error!!!");
   }
  dbclose(dbprocess);
  return 0; 
}
Пример #8
0
static int
start_query(DBPROCESS * dbproc)
{
	int i;

	if (SUCCEED != sql_cmd(dbproc)) {
		return 0;
	}
	if (SUCCEED != dbsqlexec(dbproc)) {
		return 0;
	}
	add_bread_crumb();

	if (dbresults(dbproc) != SUCCEED) {
		add_bread_crumb();
		return 0;
	}
	add_bread_crumb();

	for (i = 1; i <= dbnumcols(dbproc); i++) {
		add_bread_crumb();
		printf("col %d is named \"%s\"\n", i, dbcolname(dbproc, i));
		add_bread_crumb();
	}
	return 1;
}
Пример #9
0
static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt)
{
	pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
	pdo_dblib_db_handle *H = S->H;
	RETCODE ret;
	
	dbsetuserdata(H->link, (BYTE*) &S->err);
	
	pdo_dblib_stmt_cursor_closer(stmt);
	
	if (FAIL == dbcmd(H->link, stmt->active_query_string)) {
		return 0;
	}
	
	if (FAIL == dbsqlexec(H->link)) {
		return 0;
	}
	
	ret = pdo_dblib_stmt_next_rowset(stmt);
	
	stmt->row_count = DBCOUNT(H->link);
	stmt->column_count = dbnumcols(H->link);
	
	return 1;
}
Пример #10
0
static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len)
{
	pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
	RETCODE ret, resret;

	dbsetuserdata(H->link, (BYTE*)&H->err);

	if (FAIL == dbcmd(H->link, sql)) {
		return -1;
	}

	if (FAIL == dbsqlexec(H->link)) {
		return -1;
	}

	resret = dbresults(H->link);

	if (resret == FAIL) {
		return -1;
	}

	ret = dbnextrow(H->link);
	if (ret == FAIL) {
		return -1;
	}

	if (dbnumcols(H->link) <= 0) {
		return DBCOUNT(H->link);
	}

	/* throw away any rows it might have returned */
	dbcanquery(H->link);

	return DBCOUNT(H->link);
}
Пример #11
0
int	InsertSyncLog(COUPON_INFO_T *Data, int Count)
{
	char    sql_stm[SMALL_BUFF];
	int	i, count;
	DBPROCESS *dbproc = ConnectDB();

	memset(sql_stm, 0, SMALL_BUFF);

	for(i = 0; i < Count; i++)	{
		sprintf(sql_stm, "Insert INTO T_CouponInfo_Compare2 (CouponNo, MemberCode, ProductCode, UsePeriod, ValidPeriod, StartDate, EndDate, UseDate, Status, RegDate) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", 
				Data[i].CouponID, Data[i].MemberCode, Data[i].ProductID, 
				Data[i].DueMonth, Data[i].ExpireMonth, Data[i].CreateDate, 
				Data[i].ExpireDate, Data[i].RegistDate, Data[i].Status, 
				Data[i].LastUpdateTimeStamp);

		printLog(HEAD, "SQL::(%s)\n", sql_stm);
		dbcmd(dbproc, sql_stm);
		dbsqlexec(dbproc);
		if((count = DBCOUNT(dbproc)) == 0)	{
			printLog(HEAD, "(%s) sql fail ..\n", sql_stm);
		}
	}

	DisConnectDB();
	return	NO_ERROR;
}
Пример #12
0
void get_all(char *mitnr_in)
{
  dbfcmd(dbproc,"SELECT m.Name, m.Vorname, m.Ort, m.Gebdat, m.Beruf, m.Telnr, mp.Istvzae, mp.Planvzae, p.Proname FROM Mitarbeiter m, MiPro mp, Projekt p WHERE m.Mitnr = mp.Mitnr AND mp.Pronr = p.Pronr AND m.Mitnr = '%s'", mitnr_in);

  dbsqlexec(dbproc);

  while (dbresults(dbproc)!=NO_MORE_RESULTS)
  {	
    i=0;
    dbbind(dbproc,1,NTBSTRINGBIND,0,name);
    dbbind(dbproc,2,NTBSTRINGBIND,0,vorname);
    dbbind(dbproc,3,NTBSTRINGBIND,0,ort);
    dbbind(dbproc,4,DATETIMEBIND,0,(BYTE *)&gebdat);
    dbbind(dbproc,5,NTBSTRINGBIND,0,beruf);
    dbbind(dbproc,6,NTBSTRINGBIND,0,telnr);
    dbbind(dbproc,7,FLT8BIND,0,(BYTE *)&istvzae);
    dbbind(dbproc,8,FLT8BIND,0,(BYTE *)&planvzae);
    dbbind(dbproc,9,NTBSTRINGBIND,0,proname);

    while (dbnextrow(dbproc)!=NO_MORE_ROWS)
    {
      printf("%d:\t%s,\t%s,\t%s,\t%s,\t%s,\t%s,\t%f,\t%f,\t%s,\n",i, name, vorname, ort, date_to_str(gebdat), beruf, telnr, istvzae, planvzae, proname);
      i++;
    }
  }

}
Пример #13
0
int syb_exec_immediate (char *order)
{
  DBPROCESS * dbp = descriptor[PRIVATE_DESCRIPTOR];
  clear_error ();
  dbcmd (dbp, order);
  dbsqlexec (dbp);
  return error_number;
}
Пример #14
0
static int
select_rows(DBPROCESS * dbproc, int bind_type)
{
	char teststr[1024];
	char teststr2[1024];
	char testvstr[1024];
	DBINT testint;
	DBINT i;


	printf("select\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);


	if (dbresults(dbproc) != SUCCEED) {
		failed = 1;
		printf("Was expecting a result set.");
		exit(1);
	}

	for (i = 1; i <= dbnumcols(dbproc); i++) {
		printf("col %d is %s\n", i, dbcolname(dbproc, i));
	}

	if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) {
		fprintf(stderr, "Had problem with bind\n");
		return 1;
	}
	if (SUCCEED != dbbind(dbproc, 2, bind_type, 0, (BYTE *) teststr)) {
		fprintf(stderr, "Had problem with bind\n");
		return 1;
	}
	if (SUCCEED != dbbind(dbproc, 3, bind_type, 0, (BYTE *) teststr2)) {
		fprintf(stderr, "Had problem with bind\n");
		return 1;
	}
	if (SUCCEED != dbbind(dbproc, 4, bind_type, 0, (BYTE *) testvstr)) {
		fprintf(stderr, "Had problem with bind\n");
		return 1;
	}

	i = 0;
	while (dbnextrow(dbproc) == REG_ROW) {
		i++;
		if (testint != i) {
			printf("Failed.  Expected i to be |%d|, was |%d|\n", testint, i);
			return 1;
		}
		printf("c:  %s$\n", teststr);
		printf("c2: %s$\n", teststr2);
		printf("vc: %s$\n", testvstr);
		if (bind_type == STRINGBIND) {
		} else {
		}
	}
	return 0;
}
Пример #15
0
static void
test0(int n,  const char * expected)
{
	DBINT ind, expected_ind;
	char text_buf[16];

	dbfcmd(dbproc, "select c from #null where n = %d", n);

	dbsqlexec(dbproc);

	if (dbresults(dbproc) != SUCCEED) {
		fprintf(stderr, "Was expecting a row.\n");
		failed = 1;
		dbcancel(dbproc);
		return;
	}

	dbbind(dbproc, 1, NTBSTRINGBIND, 0, (BYTE *)text_buf);
	if (use_nullbind)
		dbnullbind(dbproc, 1, &ind);

	memset(text_buf, 'a', sizeof(text_buf));
	ind = -5;

	if (dbnextrow(dbproc) != REG_ROW) {
		fprintf(stderr, "Was expecting a row.\n");
		failed = 1;
		dbcancel(dbproc);
		return;
	}

	text_buf[sizeof(text_buf) - 1] = 0;
	printf("ind %d text_buf -%s-\n", (int) ind, text_buf);

	expected_ind = 0;
	if (strcmp(expected, "aaaaaaaaaaaaaaa") == 0)
		expected_ind = -1;

	/* do not check indicator if not bound */
	if (!use_nullbind)
		ind = expected_ind;
	if (ind != expected_ind || strcmp(expected, text_buf) != 0) {
		fprintf(stderr, "expected_ind %d expected -%s-\n", (int) expected_ind, expected);
		failed = 1;
		dbcancel(dbproc);
		return;
	}

	if (dbnextrow(dbproc) != NO_MORE_ROWS) {
		fprintf(stderr, "Only one row expected\n");
		dbcancel(dbproc);
		failed = 1;
	}

	while (dbresults(dbproc) == SUCCEED) {
		/* nop */
	}
}
Пример #16
0
static void
insert_row(DBPROCESS * dbproc)
{
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
}
Пример #17
0
static void
query(const char *query)
{
	printf("query: %s\n", query);
	dbcmd(dbproc, (char *) query);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) == SUCCEED) {
		/* nop */
	}
}
Пример #18
0
static void
char_test(const char *null, int bindlen, const char *expected)
{
	char db_c[16];
	RETCODE ret;

	if (null) {
		fprintf(stderr, "\tdbsetnull(CHARBIND, %u, '%s').\n", (unsigned int) strlen(null), null);
		ret = dbsetnull(dbproc, CHARBIND, strlen(null), (BYTE *) null);
		if (ret != SUCCEED) {
			fprintf(stderr, "dbsetnull returned error %d\n", (int) ret);
			failed = 1;
		}
	}

	memset(db_c, '_', sizeof(db_c));
	strcpy(db_c, "123456");
	dbcmd(dbproc, "select convert(char(20), null)");

	dbsqlexec(dbproc);

	if (dbresults(dbproc) != SUCCEED) {
		fprintf(stderr, "Was expecting a row.\n");
		failed = 1;
		dbcancel(dbproc);
	}

	fprintf(stderr, "dbbind(CHARBIND, bindlen= %d).\n", bindlen);
	dbbind(dbproc, 1, CHARBIND, bindlen, (BYTE *) &db_c);
	db_c[sizeof(db_c)-1] = 0;
	printf("buffer before/after dbnextrow: '%s'/", db_c);

	if (dbnextrow(dbproc) != REG_ROW) {
		fprintf(stderr, "Was expecting a row.\n");
		failed = 1;
		dbcancel(dbproc);
	}
	db_c[sizeof(db_c)-1] = 0;
	printf("'%s'\n", db_c);

	if (dbnextrow(dbproc) != NO_MORE_ROWS) {
		fprintf(stderr, "Only one row expected\n");
		dbcancel(dbproc);
		failed = 1;
	}

	while (dbresults(dbproc) == SUCCEED) {
		/* nop */
	}

	if (strcmp(db_c, expected) != 0) {
		fprintf(stderr, "Invalid NULL '%s' returned expected '%s' (%s:%d)\n", db_c, expected, tds_basename(__FILE__), __LINE__);
		failed = 1;
	}
}
Пример #19
0
int
main(int argc, char *argv[])
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	int ret_code;
	int num_cols;
	int num_res;

	set_malloc_options();

	read_login_info(argc, argv);
	printf("Starting %s\n", argv[0]);
	dbinit();

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	printf("About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "t0012");

	dbproc = dbopen(login, SERVER);
	if (strlen(DATABASE)) {
		dbuse(dbproc, DATABASE);
	}
	dbloginfree(login);
	printf("After logon\n");

	/* select */
	sql_cmd(dbproc);
	dbsqlexec(dbproc);

	num_res = 0;
	while ((ret_code = dbresults(dbproc)) == SUCCEED) {
		num_cols = dbnumcols(dbproc);
		printf("Result %d has %d columns\n", num_res, num_cols);
		if (!(num_res % 2) && num_cols)
			set_failed();
		while(dbnextrow(dbproc) != NO_MORE_ROWS) {};
		num_res++;
	}
	if (ret_code == FAIL)
		set_failed();

	dbclose(dbproc);
	dbexit();

	printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK"));
	return failed ? 1 : 0;
}
Пример #20
0
RETCODE dbExecSql(const char * sql_str,DBPROCESS **db_proc)
{
  RETCODE erc=-1;
  dbcmd(*db_proc,sql_str);
  if((erc=dbsqlexec(*db_proc))==FAIL)
  	{
  	fprintf(stderr, "%s:%d: exec sql:%s err\n", __func__, __LINE__,sql_str);
	return erc;
  	}
  return erc;
}
Пример #21
0
static void
create_tables(DBPROCESS * dbproc, int rows_to_add)
{
	int i;

	fprintf(stdout, "creating table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	fprintf(stdout, "insert\n");
	for (i = 1; i < rows_to_add; i++) {
		sql_cmd(dbproc);
		dbsqlexec(dbproc);
		while (dbresults(dbproc) != NO_MORE_RESULTS) {
			/* nop */
		}
	}
}
Пример #22
0
static int pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh)
{
	pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;

	if (FAIL == dbcmd(H->link, cmd)) {
		return 0;
	}

	if (FAIL == dbsqlexec(H->link)) {
		return 0;
	}

	return 1;
}
Пример #23
0
static void
drop_table(void)
{
	if (!dbproc) 
		return;

	dbcancel(dbproc);

	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}
}
Пример #24
0
void print_ort(void){
	/*anzeige aller berufe*/
	dbcmd(dbproc,"SELECT Ort FROM Mitarbeiter group by Ort");
	dbsqlexec(dbproc);

	while (dbresults(dbproc)!=NO_MORE_RESULTS)
	{
		dbbind(dbproc,1,NTBSTRINGBIND,0,Ort);
		while (dbnextrow(dbproc)!=NO_MORE_ROWS)
		{
			printf(":      %s\n",Mitarbeiter);
		 }
	}

}
Пример #25
0
static void
test(const char *type, int give_err)
{
	RETCODE ret;

	query("if object_id('#null') is not NULL drop table #null");

	dberrhandle(ignore_err_handler);
	dbmsghandle(ignore_msg_handler);

	printf("create table #null (n int, c %s NULL)\n", type);
	dbfcmd(dbproc, "create table #null (n int, c %s NULL)", type);
	dbsqlexec(dbproc);

	ret = dbresults(dbproc);

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	if (ret != SUCCEED) {
		dbcancel(dbproc);
		if (!give_err)
			return;
		fprintf(stdout, "Was expecting a result set.\n");
		failed = 1;
		return;
	}

	query("insert into #null values(1, '')");
	query("insert into #null values(2, NULL)");
	query("insert into #null values(3, ' ')");
	query("insert into #null values(4, 'foo')");

	use_nullbind = 1;
	test0(1, "");
	test0(2, "aaaaaaaaaaaaaaa");
	test0(3, "");
	test0(4, "foo");

	use_nullbind = 0;
	test0(1, "");
	test0(2, "");
	test0(3, "");
	test0(4, "foo");

	query("drop table #null");
}
Пример #26
0
QTDSResult::QTDSResult(const QTDSDriver* db)
    : QSqlCachedResult(db)
{
    d = new QTDSResultPrivate();
    d->login = db->d->login;

    d->dbproc = dbopen(d->login, const_cast<char*>(db->d->hostName.toLatin1().constData()));
    if (!d->dbproc)
        return;
    if (dbuse(d->dbproc, const_cast<char*>(db->d->db.toLatin1().constData())) == FAIL)
        return;

    // insert d in error handler dict
    errs()->insert(d->dbproc, d);
    dbcmd(d->dbproc, "set quoted_identifier on");
    dbsqlexec(d->dbproc);
}
Пример #27
0
void get_berufe()
{
  dbcmd(dbproc,"SELECT Beruf FROM Mitarbeiter GROUP BY Beruf");

  dbsqlexec(dbproc);

  while (dbresults(dbproc)!=NO_MORE_RESULTS)
  {	
    i=0;
    dbbind(dbproc,1,NTBSTRINGBIND,15,beruf);

    while (dbnextrow(dbproc)!=NO_MORE_ROWS)
    {
      printf("%d:      %s\n",i, beruf);
      i++;
    }
  }
}
Пример #28
0
void insert_lebenslauf(void){
	/*anzeige aller berufe*/
	dbcmd(dbproc,"SELECT Lebenslauf FROM Mitarbeiter");
	dbsqlexec(dbproc);

	while (dbresults(dbproc)!=NO_MORE_RESULTS)
	{
		dbbind(dbproc,1,STRINGBIND,0,abstract_var);
		while (dbnextrow(dbproc)!=NO_MORE_ROWS)
		{
      strcpy(abstract_var, "Hauptschule");
      dbwritetext(dbproc_insert, "Mitarbeiter.Lebenslauf",
          dbtxptr(dbproc, 1), DBTXPLEN, dbtxtimestamp(dbproc,1),TRUE,
          (DBINT)strlen(abstract_var),abstract_var);
		}
	}

}
Пример #29
0
/* execute a query that doesn't return a result set, mop up,
 * and return and APR-flavoured status
 */
static RETCODE freetds_exec(DBPROCESS *proc, const char *query,
                            int want_results, int *nrows)
{
    /* TBD */
    RETCODE rv = dbcmd(proc, query);
    if (rv != SUCCEED) {
        return rv;
    }
    rv = dbsqlexec(proc);
    if (rv != SUCCEED) {
        return rv;
    }
    if (!want_results) {
        while (dbresults(proc) != NO_MORE_RESULTS) {
            ++*nrows;
        }
    }
    return SUCCEED;
}
Пример #30
0
char *dblib_handle_last_id(pdo_dbh_t *dbh, const char *name, size_t *len)
{
	pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;

	RETCODE ret;
	char *id = NULL;

	/*
	 * Would use scope_identity() but it's not implemented on Sybase
	 */

	if (FAIL == dbcmd(H->link, "SELECT @@IDENTITY")) {
		return NULL;
	}

	if (FAIL == dbsqlexec(H->link)) {
		return NULL;
	}

	ret = dbresults(H->link);
	if (ret == FAIL || ret == NO_MORE_RESULTS) {
		dbcancel(H->link);
		return NULL;
	}

	ret = dbnextrow(H->link);

	if (ret == FAIL || ret == NO_MORE_ROWS) {
		dbcancel(H->link);
		return NULL;
	}

	if (dbdatlen(H->link, 1) == 0) {
		dbcancel(H->link);
		return NULL;
	}

	id = emalloc(32);
	*len = dbconvert(NULL, (dbcoltype(H->link, 1)) , (dbdata(H->link, 1)) , (dbdatlen(H->link, 1)), SQLCHAR, (BYTE *)id, (DBINT)-1);

	dbcancel(H->link);
	return id;
}