freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "karthick v" <karthickv AT hclp.com>
- To: freetds AT franklin.oit.unc.edu
- Subject: Transferring data from Postgres to Sybase
- Date: Fri, 20 Sep 2002 02:47:22 -0400
Hi everyone,
I have written a small program in C to transfer records from postgresql to
Sybase. It works fine except that I am able to transfer only one record
whereas I need to transfer many records.
It would be very good if anyone can tell me what I have done wrong in the
program.
application and Postgresql are in Linux and Sybase is in Windows on
another machine.
can someone help
karthick v
Here is the code to transfer the data.
**********************************************
strcpy(strpgquery,"select * from emp");
//connect to the postgres server
connect_to_postgres();
if (no_of_postgres_records(strpgquery)>0)
{
//some records were fetched
// printf("something was fetched\n");
//connect to sybase server
if (connect_to_sybase()>0)
{
//connection to sybase was successfull, move the
records
//change to the correct database
for (i = 0; i < PQntuples(res); i++)
{
//create the query string
strcpy(strsyquery,"");
/* resetting the database*/
strcat(strsyquery,"insert into emp values(");
strcat(strsyquery,PQgetvalue(res, i, 0));
strcat(strsyquery,",'");
strcat(strsyquery,PQgetvalue(res, i, 1));
strcat(strsyquery,"','");
strcat(strsyquery,PQgetvalue(res, i, 2));
strcat(strsyquery,"')");
printf("%s\n",strsyquery);
// strcpy(strsyquery,"use test");
tds_submit_query(sybsocket,"use test");
//execute the query
tds_submit_query(sybsocket,strsyquery);
//process the query
//reset the sybsocket or maybe clear it
}
}
else
{
//could not connect to sybase
//clean up postgres connection
PQclear(res);
close_postgres();
exit(1);
}
//do the required processing
}
//clean up the recordset
PQclear(res);
//close the connection to postgres
close_postgres();
-
Transferring data from Postgres to Sybase,
karthick v, 09/20/2002
- <Possible follow-up(s)>
- Re: Transferring data from Postgres to Sybase, Frediano Ziglio, 09/22/2002
- Re: Transferring data from Postgres to Sybase, Karthick V, 09/22/2002
Archive powered by MHonArc 2.6.24.