Thread: not permanent insert into stud values('myname')

not permanent insert into stud values('myname')

From
rony khoury
Date:
 

Hello ,

following is a part of my code , can any body tell me why it works fine ,
but 'myname' does not remain permanent in the table although I'm loging in as postgres
and see 'myname' in the result when I run the program ?

thanks ,
Rony .

--------------------- C code -------------------
res = PQexec(conn,"insert into stud values('myname')");
PQclear(res);
res = PQexec(conn,"select * from stud");
 
for (i=0;i<PQntuples(res);i++) {
  printf("\n answer is %s",PQgetvalue(res,i,0));

---------------------- output -----------------------
#a.out
answer is rony
answer is myname
#
----------------------------------------------------------
 

Re: [INTERFACES] not permanent insert into stud values('myname')

From
Hannu Krosing
Date:
rony khoury wrote:
>
>
>
> Hello ,
>
> following is a part of my code , can any body tell me why it works
> fine ,

It should work fine ;)

> but 'myname' does not remain permanent in the table although I'm
> loging in as postgres
> and see 'myname' in the result when I run the program ?

You probably start a transaction, but never commit it (in some other
part of your code)

Hannu

Re: [INTERFACES] not permanent insert into stud values('myname')

From
"rony khoury"
Date:

Hannu Krosing wrote:

> rony khoury wrote:
> >
> >
> >
> > Hello ,
> >
> > following is a part of my code , can any body tell me why it works
> > fine ,
>
> It should work fine ;)
>
> > but 'myname' does not remain permanent in the table although I'm
> > loging in as postgres
> > and see 'myname' in the result when I run the program ?
>
> You probably start a transaction, but never commit it (in some other
> part of your code)
>
> Hannu



no it does not work fine or else I wouldn't have asked .
What do you mean I should commit it in some other part of my code ? how
to do that ?

rony .



rony khoury wrote:

> Hannu Krosing wrote:
>
> > rony khoury wrote:
> > >
> > >
> > >
> > > Hello ,
> > >
> > > following is a part of my code , can any body tell me why it works
> > > fine ,
> >
> > It should work fine ;)
> >
> > > but 'myname' does not remain permanent in the table although I'm
> > > loging in as postgres
> > > and see 'myname' in the result when I run the program ?
> >
> > You probably start a transaction, but never commit it (in some other
> > part of your code)
> >
> > Hannu
>
> no it does not work fine or else I wouldn't have asked .
> What do you mean I should commit it in some other part of my code ? how
> to do that ?
>
> rony .



ok it works fine for me now , I just needed to add an
PQexec(conn,"END");

now that it works , it was a silly question , sorry for the trouble .

thanks again ,
Rony .



Re: [NOVICE] not permanent insert into stud values('myname')

From
James Olin Oden
Date:
 
res = PQexec(conn,"insert into stud values('myname')");
 
Don't you still need to include the SQL EOL character, that is a semicolon at the end of your querystring?