[GENERAL] Sequence value

2000-12-14 Thread Esa Pikkarainen

So, I want to insert new record and get immediately its sequence 
value (serial column) (or OID). I Use iHTML web interface.
Now I have found out that I can give two queries in iHTML like this:

SQL ="SELECT nextval('koe_pkey_id') as val;
  INSERT INTO koe (id, name) values (val, 'uusi');"

Now there are some problems. The previous example causes an error:
ERROR: Attribute 'val' not found
Is there a method how to transmit a value from one query to another?

If I try the examples of FAQ:
SQL ="$newSerialID = nextval('koe_pkey_id');
  INSERT INTO koe (id, name) values ($newSerialID, 'uusi');"
Or 
SQL ="INSERT INTO koe (name) values ('uusi');"
  $newSerialID = curr('koe_pkey_id');

I get: ERROR: parser: parse error at or near "$"

And lately (this may be an iHTML problem) if I try:
SQL ="INSERT INTO koe (name) values ('uusi');
  SELECT currval('koe_pkey_id') as val;"
It causes no error, but I cannot retrieve the value because the 
queries seem not return any recordsets (nothig can be fetched).

Any hints are valuable!
Thanks
Esa Pikkarainen



RE: [GENERAL] Postgres failover implementation

2000-12-14 Thread Maarten Boekhold




Hi,

What you'll really want is a disk array that is shared by 2 machines. The
primary database is allowed to modify the data in the array. When it dies,
the secondary database machine is allowed write access to it. This
basically how Oracle does things like this. Don't know if FreeBSD allows
you to do things like this though.

This probably wont work without some twiddling. You probably can't have
both postmasters running at the same time because of caching issues.
However, a detection mechanism that checks whether the primary postmaster
is still running and starts the secondary if the primary dies should be
possible.

You'd also want some way of switching the IP-address of the machines so
that the whole fail-over is transparent to clients.

Maarten

On 13/12/2000 17:30:31 Schmidt, Peter wrote:

>-Original Message-
>From: Tom Lane [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, December 12, 2000 10:10 AM
>
>>Performance across an NFS mount will doubtless suck badly.
>
>It's a fact of life at this point. I'm hoping performance won't suck that
>much with 1 GB ethernet and NAS/RAID. In any case, we can't run
postmaster
>on NFS mount machine.
>
>> Seems like this still means a single point of failure, ie the NFS box.
So
>what's the point?

>"Peter Schmidt" <[EMAIL PROTECTED]> writes:
>> My company is looking for a way to implement failover w/Postgres.
>> I've determined that two postmasters running on different machines
>(FreeBSD)
>> can share a single $PGDATA directory(NFS mount) as long as only one
>> postmaster is running at a time.
>
>Performance across an NFS mount will doubtless suck badly.  That might
>be acceptable as an emergency backup mode of operation ... but if the
>machine with the disk is up, you might as well be running the postmaster
>there.
>
>It sounds like you intend to have both the primary and secondary
>database servers access an NFS server.  Seems like this still means a
>single point of failure, ie the NFS box.  So what's the point?
>
>> Originally I thought I might be able to use
>> postmaster.pid to lock out the second postmaster, but the pid file is
>> overwritten by the second postmaster when it starts.
>
>The lockfile code assumes that if the PID in the file doesn't belong to
>a live process *on the local machine*, then it's left over from a
>crashed postmaster.  You could remove that check, perhaps, but then
>you'd have to remove the PID file manually anytime you had a postmaster
>crash.  (However, postmaster crashes are rare, so this might be OK.)




Maarten Boekhold, [EMAIL PROTECTED]

Reuters Consulting
Entrada 308
1096 ED Amsterdam
The Netherlands
tel: +31 (0)20-6601000 (switchboard)
  +31 (0)20-6601066 (direct)
  +31 (0)20-6601005 (fax)
  +31 (0)651585137 (mobile)


-
Visit our Internet site at http://www.reuters.com

Any views expressed in this message are those of  the  individual
sender,  except  where  the sender specifically states them to be
the views of Reuters Ltd.



Re: [GENERAL] adding a C function with optional arguments

2000-12-14 Thread Tom Lane

Jim Mercer <[EMAIL PROTECTED]> writes:
> i was wondering if someone could tell me how, if possible, to implement
> a c function such that i can do:

>> SELECT makecrypt('secret', 'salt');
> or
>> SELECT makecrypt('secret');

> such that if salt is not specified, the c function would make one up.

This would be two separate functions in Postgres' view of the world.
Whether one calls the other internally is between you and your code...

regards, tom lane

PS: pneumonoultramicroscopicsilicovolcanoconiosis?  Wazzat?



Re: [GENERAL] Trigger/Function problem

2000-12-14 Thread Dan Wilson

That was it!  Thanks Tom.  I just put this functionality into phpPgAdmin and
of course it is taking the newline char from the browser's OS.

Thanks for all your help!

-Dan



> "Dan Wilson" <[EMAIL PROTECTED]> writes:
> > I get the following error:
> > NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
> > "RROR:  parse error at or near "
>
> Just like that, eh?  It looks like the parser is spitting up on a \r
> in the function text.  Try saving your script with Unix-style newlines.
>
> For 7.1 the plpgsql parser has been fixed to accept DOS-ish newlines,
> but for now you gotta be careful...
>
> regards, tom lane




[GENERAL] adding a C function with optional arguments

2000-12-14 Thread Jim Mercer


i've poked about and made a new function "makecrypt(plainpass, salt)", and
it works ok.

basically, it is just a hook to the unix crypt() function.

i was wondering if someone could tell me how, if possible, to implement
a c function such that i can do:

> SELECT makecrypt('secret', 'salt');
or
> SELECT makecrypt('secret');

such that if salt is not specified, the c function would make one up.

-- 
[ Jim Mercer  [EMAIL PROTECTED] ]
[  Reptilian Research -- Longer Life through Colder Blood  ]
[ aka[EMAIL PROTECTED]  +1 416 410-5633 ]



Re: [GENERAL] create trigger (can't compile example, problem with include files)

2000-12-14 Thread Tom Lane

"Robert B. Easter" <[EMAIL PROTECTED]> writes:
> I compared /usr/local/pgsql/include with
> /usr/src/postgresql-7.0.3/src/include and found that the src has more
> include files so that I tried:

Yeah, we keep meaning to clean up the include-file situation so that you
have some chance of compiling a useful C trigger with the installed
include files.  Right now you pretty much have to -I a source tree.

> ttest.c: In function `trigf':
> ttest.c:17: `WARN' undeclared (first use in this function)
> ttest.c:17: (Each undeclared identifier is reported only once
> ttest.c:17: for each function it appears in.)

s/WARN/ERROR/.   Looks like this example file never got updated when
that change was made, about three years ago :-(.  Will fix.

regards, tom lane



Re: [GENERAL] Trigger/Function problem

2000-12-14 Thread Tom Lane

"Dan Wilson" <[EMAIL PROTECTED]> writes:
> I get the following error:
> NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
> "RROR:  parse error at or near "

Just like that, eh?  It looks like the parser is spitting up on a \r
in the function text.  Try saving your script with Unix-style newlines.

For 7.1 the plpgsql parser has been fixed to accept DOS-ish newlines,
but for now you gotta be careful...

regards, tom lane



Re: [GENERAL] Trigger/Function problem

2000-12-14 Thread Dan Wilson

If you look at my function definition, you can see that this is not within
the function body.  This is the testing of the trigger which produces the
error.  It's just a plain old SQL statment that initiates the trigger.

-Dan

- Original Message -
From: "Robert B. Easter" <[EMAIL PROTECTED]>

> On Thursday 14 December 2000 21:27, Dan Wilson wrote:
> >
> > I'm totally fine up to this point... then I try this:
> >
> > UPDATE help SET site_id = 'APW' WHERE help_id = 2;
> >
> > I get the following error:
> >
> > NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
> > "RROR:  parse error at or near "
>
> Try:
>
> UPDATE help SET site_id = ''APW'' WHERE help_id = 2;
>
> Remember that ' is used to enclose the whole function body.  You have to
use
> '' to mean a literal '.
>




Re: [GENERAL] Trigger/Function problem

2000-12-14 Thread Robert B. Easter

On Thursday 14 December 2000 21:10, Robert B. Easter wrote:
> On Thursday 14 December 2000 21:27, Dan Wilson wrote:
> > I'm totally fine up to this point... then I try this:
> >
> > UPDATE help SET site_id = 'APW' WHERE help_id = 2;
> >
> > I get the following error:
> >
> > NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
> > "RROR:  parse error at or near "
>
> Try:
>
> UPDATE help SET site_id = ''APW'' WHERE help_id = 2;
>
> Remember that ' is used to enclose the whole function body.  You have to
> use '' to mean a literal '.

Nevermind.  I should have looked more closely at the message. %-)

-- 
 Robert B. Easter  [EMAIL PROTECTED] -
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
-- http://www.comptechnews.com/~reaster/ 



Re: [GENERAL] Trigger/Function problem

2000-12-14 Thread Robert B. Easter

On Thursday 14 December 2000 21:27, Dan Wilson wrote:
>
> I'm totally fine up to this point... then I try this:
>
> UPDATE help SET site_id = 'APW' WHERE help_id = 2;
>
> I get the following error:
>
> NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
> "RROR:  parse error at or near "

Try:

UPDATE help SET site_id = ''APW'' WHERE help_id = 2;

Remember that ' is used to enclose the whole function body.  You have to use 
'' to mean a literal '.


-- 
 Robert B. Easter  [EMAIL PROTECTED] -
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
-- http://www.comptechnews.com/~reaster/ 



[GENERAL] Trigger/Function problem

2000-12-14 Thread Dan Wilson

I'm having problems with a trigger/function and I think it's actually a
system problem but I have no clue how to fix it.  The trigger is supposed to
automatically timestamp the record when it is altered.

I've never used anything more than a sql function before so the plpgsql is
new to me.

Here's the info:

My table:
CREATE TABLE "help" (
   "help_id" int4 DEFAULT nextval('help_id_seq'::text) NOT NULL,
   "keyword" varchar(20) NOT NULL,
   "help_text" text NOT NULL,
   "auto_date" date NOT NULL,
   "title" varchar(50) DEFAULT 'Help Topic',
   "admin" bool DEFAULT 't',
   "site_id" varchar(5) DEFAULT '0',
   CONSTRAINT "help_pkey" PRIMARY KEY ("help_id")
);

My function:
CREATE FUNCTION "f_auto_date"() RETURNS OPAQUE AS '
BEGIN
  NEW.auto_date := ''now'';
  RETURN NEW;
END;
' LANGUAGE 'plpgsql';

My trigger:
CREATE TRIGGER "t_auto_date" BEFORE INSERT OR UPDATE ON "help" FOR EACH ROW
EXECUTE PROCEDURE "f_auto_date"();

I'm totally fine up to this point... then I try this:

UPDATE help SET site_id = 'APW' WHERE help_id = 2;

I get the following error:

NOTICE:  plpgsql: ERROR during compile of f_auto_date near line 1
"RROR:  parse error at or near "

I've tried the sample on the following web page as well:
http://www.postgresql.org/users-lounge/docs/7.0/user/c40874340.htm

And I get the exact same error (except of course the function name is
different). So I'm assuming that it's a problem in my system
configuration... I may be wrong.

I don't know how to fix this or even where to begin.  I do have plpgsql
installed as a language. I'm running PG 7.0.2 on standard RedHat 7 ... not
sure of the Kernel.

Thanks for your help,
-Dan




Re: [GENERAL] Apache+Postgresql (mod_auth_pgsql)

2000-12-14 Thread Alvar Freude

Hi,

>
> Secondly, how can i have stadistics of how many times an users has got
> into the privated directory. (any suggestion) Perhaps could be a script
> to write into the database. ?¿?

for this, you can use the standard Apache logfiles, if you don't need it
inside the Database.


For auth, I guess there are docs on the apache website. There is also an
mod_perl module for general DBI authentication, see
http://theoryx5.uwinnipeg.ca/CPAN/data/ApacheDBI/AuthDBI.html


Ciao
  Alvar


-- 
Alvar C.H. Freude  |  [EMAIL PROTECTED]

Demo: http://www.online-demonstration.org/  |  Mach mit!
Blast-DE: http://www.assoziations-blaster.de/   |  Blast-Dich-Fit
Blast-EN: http://www.a-blast.org/   |  Blast/english



Re: [GENERAL] Does column header support multibyte character?

2000-12-14 Thread Tatsuo Ishii

No. However an encoding "MULE_INTERNAL" would do almost what you want.
MULE_INTERNAL is compatible with EUC_CN and EUC_TW. So you could
create a table having EUC_CN and EUC_TW columns like this.

create table t1(euc_cn text, euc_tw text);
\encoding EUC_CN
insert into t1(euc_cn) values('text in EUC_CN');
\encoding EUC_TW
update t1 set euc_tw = 'text in EUC_CN';

Not so convenience, though.
--
Tatsuo Ishii

From: Dave <[EMAIL PROTECTED]>
Subject: Re: [GENERAL] Does column header support multibyte character?
Date: Thu, 02 Nov 2000 23:49:30 +0800
Message-ID: <[EMAIL PROTECTED]>

> Thanks for your reply,
> 
> My question is, can I use chinese, say Chinese used in Taiwan (EUC_TW?
> or Big5?), to name columns inside table.  Furthermore, is it possible
> to have columns with different encoding within the same table?
> 
> Many thanks
> Dave
> 
> 
> 
> 
> On Thu, 02 Nov 2000 18:33:01 +0900, you wroth:
> 
> >> Can I use chinese as the column header?
> >
> >I'm not sure what kind of chinese encoding you want to use, anyway
> >PostgreSQL supports following encodings:
> >
> >EUC-CN(simplified chinese EUC based on GB2312)
> >EUC-TW(traditional chinese EUC based on CNS 11643-1986)
> >Big5(yet another traditional chinese encoding, only for frontend)
> >
> >Sample files for each encoding are in test/mb/sql.
> >
> >see doc/README.mb for more details also.



Re: [GENERAL] create trigger (can't compile example, problem with include files)

2000-12-14 Thread Sandeep Joshi

Robert,
  I am insert_username.* in contrib directory for reference. So far so good.

Sandeep
"Robert B. Easter" wrote:

> On Thursday 14 December 2000 18:54, Robert B. Easter wrote:
> > Trigger functions, no matter what language, have be RETURNS OPAQUE.
> >
> > Here is an example (in the PostgreSQL docs):
> > http://www.comptechnews.com/~reaster/postgres/triggers20290.htm
> >
> > Sorry I can't help more as I've never actually used C triggers, just
> > PL/pgSQL ones.
> >
>
> Admitting I have not tried using C triggers, I decided to try the example at
> the url above.  I saved the example C trigger to a file called ttest.c and
> compile it with:
>
> gcc -shared -I/usr/local/pgsql/include ttest.c -o ttest.o
>
> (I hope that is the right command), then I got this:
>
> reaster@comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> ttest.c -o ttest.o
> In file included from ttest.c:1:
> /usr/local/pgsql/include/executor/spi.h:17: nodes/primnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:18: nodes/relation.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:19: nodes/execnodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:20: nodes/plannodes.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:21: catalog/pg_proc.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:22: catalog/pg_type.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:23: tcop/pquery.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:24: tcop/tcopprot.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:25: tcop/utility.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:26: tcop/dest.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:27: nodes/params.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:28: utils/fcache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:29: utils/datum.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:30: utils/syscache.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:31: utils/portal.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:32: utils/builtins.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:33: catalog/pg_language.h: No such
> file or directory
> /usr/local/pgsql/include/executor/spi.h:34: access/heapam.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:35: access/xact.h: No such file or
> directory
> /usr/local/pgsql/include/executor/spi.h:36: executor/executor.h: No such file
> or directory
> /usr/local/pgsql/include/executor/spi.h:37: executor/execdefs.h: No such file
> or directory
> In file included from ttest.c:2:
> /usr/local/pgsql/include/commands/trigger.h:16: nodes/execnodes.h: No such
> file or directory
> /usr/local/pgsql/include/commands/trigger.h:17: nodes/parsenodes.h: No such
> file or directory
> reaster@comptechnews:~/prog/triggers$
>
> I compared /usr/local/pgsql/include with
> /usr/src/postgresql-7.0.3/src/include and found that the src has more include
> files so that I tried:
>
> reaster@comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include
> -I/usr/src/postgresql-7.0.3/src/include ttest.c -o ttest.o
> ttest.c: In function `trigf':
> ttest.c:17: `WARN' undeclared (first use in this function)
> ttest.c:17: (Each undeclared identifier is reported only once
> ttest.c:17: for each function it appears in.)
>
>
> Anyhow, can someone help me here with these include files and the missing
> WARN define?
>
> > On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> > > I am trying to use "triggers". I get an error after "create trigger".
> > > Does anybody know why?
> > >
> > >  create function insert_into_db2 RETURNS int AS
> > > '/work/posgresql/lib/libpq.so' language 'C';
> > >
> > >  create trigger trial before insert or update on db1user for each row
> > > execute procedure  insert_into_db2();
> > >
> > >  ERROR:  CreateTrigger: function insert_into_db2() must return OPAQUE
> > >
> > > Does anybody know why?
> > >
> > > Also, if a function is enforced to return OPAQUE then  what is the
> > > "RETURNS" clause?
> > >
> > >
> > > One more question,
> > >  If a trigger does not succeed then I want to ABORT transaction, is
> > > it possible? how?
> > >
> > >
> > > - Sandeep
>
> --
>  Robert B. Easter  [EMAIL PROTECTED] -
> - CompTechNews Message Board   http://www.comptechnews.com/ -
> - CompTechServ Tech Services   http://www.comptechserv.com/ -
> -- http://www.comptechnews.com/~reaster/ 

> On Thursday 14 December 2000 18:54, Robert B. Easter wrote:
> > Trigger functions, no matter what language, have be RETURNS OPAQUE.
> >
> > Here is an example (in the PostgreSQL docs):
> > http://www.comptechnews.com/~reaster/postgres/triggers20290

Re: [GENERAL] create trigger (can't compile example, problem with include files)

2000-12-14 Thread Robert B. Easter

On Thursday 14 December 2000 18:54, Robert B. Easter wrote:
> Trigger functions, no matter what language, have be RETURNS OPAQUE.
>
> Here is an example (in the PostgreSQL docs):
> http://www.comptechnews.com/~reaster/postgres/triggers20290.htm
>
> Sorry I can't help more as I've never actually used C triggers, just
> PL/pgSQL ones.
>

Admitting I have not tried using C triggers, I decided to try the example at 
the url above.  I saved the example C trigger to a file called ttest.c and 
compile it with:

gcc -shared -I/usr/local/pgsql/include ttest.c -o ttest.o

(I hope that is the right command), then I got this:

reaster@comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include 
ttest.c -o ttest.o
In file included from ttest.c:1:
/usr/local/pgsql/include/executor/spi.h:17: nodes/primnodes.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:18: nodes/relation.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:19: nodes/execnodes.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:20: nodes/plannodes.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:21: catalog/pg_proc.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:22: catalog/pg_type.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:23: tcop/pquery.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:24: tcop/tcopprot.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:25: tcop/utility.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:26: tcop/dest.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:27: nodes/params.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:28: utils/fcache.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:29: utils/datum.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:30: utils/syscache.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:31: utils/portal.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:32: utils/builtins.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:33: catalog/pg_language.h: No such 
file or directory
/usr/local/pgsql/include/executor/spi.h:34: access/heapam.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:35: access/xact.h: No such file or 
directory
/usr/local/pgsql/include/executor/spi.h:36: executor/executor.h: No such file 
or directory
/usr/local/pgsql/include/executor/spi.h:37: executor/execdefs.h: No such file 
or directory
In file included from ttest.c:2:
/usr/local/pgsql/include/commands/trigger.h:16: nodes/execnodes.h: No such 
file or directory
/usr/local/pgsql/include/commands/trigger.h:17: nodes/parsenodes.h: No such 
file or directory
reaster@comptechnews:~/prog/triggers$ 


I compared /usr/local/pgsql/include with
/usr/src/postgresql-7.0.3/src/include and found that the src has more include 
files so that I tried:

reaster@comptechnews:~/prog/triggers$ gcc -shared -I/usr/local/pgsql/include 
-I/usr/src/postgresql-7.0.3/src/include ttest.c -o ttest.o
ttest.c: In function `trigf':
ttest.c:17: `WARN' undeclared (first use in this function)
ttest.c:17: (Each undeclared identifier is reported only once
ttest.c:17: for each function it appears in.) 
 

Anyhow, can someone help me here with these include files and the missing 
WARN define?


> On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> > I am trying to use "triggers". I get an error after "create trigger".
> > Does anybody know why?
> >
> >  create function insert_into_db2 RETURNS int AS
> > '/work/posgresql/lib/libpq.so' language 'C';
> >
> >  create trigger trial before insert or update on db1user for each row
> > execute procedure  insert_into_db2();
> >
> >  ERROR:  CreateTrigger: function insert_into_db2() must return OPAQUE
> >
> > Does anybody know why?
> >
> > Also, if a function is enforced to return OPAQUE then  what is the
> > "RETURNS" clause?
> >
> >
> > One more question,
> >  If a trigger does not succeed then I want to ABORT transaction, is
> > it possible? how?
> >
> >
> > - Sandeep

-- 
 Robert B. Easter  [EMAIL PROTECTED] -
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
-- http://www.comptechnews.com/~reaster/ 



Re: [GENERAL] create trigger

2000-12-14 Thread Sandeep Joshi

Robert,
Thanks. If you have any simple  PL/pgSQL trigger that will also help.
Indirectly.

Sandeep


> Trigger functions, no matter what language, have be RETURNS OPAQUE.
>
> Here is an example (in the PostgreSQL docs):
> http://www.comptechnews.com/~reaster/postgres/triggers20290.htm
>
> Sorry I can't help more as I've never actually used C triggers, just PL/pgSQL
> ones.
>
> On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> > I am trying to use "triggers". I get an error after "create trigger".
> > Does anybody know why?
> >
> >  create function insert_into_db2 RETURNS int AS
> > '/work/posgresql/lib/libpq.so' language 'C';
> >
> >  create trigger trial before insert or update on db1user for each row
> > execute procedure  insert_into_db2();
> >
> >  ERROR:  CreateTrigger: function insert_into_db2() must return OPAQUE
> >
> > Does anybody know why?
> >
> > Also, if a function is enforced to return OPAQUE then  what is the
> > "RETURNS" clause?
> >
> >
> > One more question,
> >  If a trigger does not succeed then I want to ABORT transaction, is
> > it possible? how?
> >
> >
> > - Sandeep
>
> --
>  Robert B. Easter  [EMAIL PROTECTED] -
> - CompTechNews Message Board   http://www.comptechnews.com/ -
> - CompTechServ Tech Services   http://www.comptechserv.com/ -
> -- http://www.comptechnews.com/~reaster/ 



Re: [GENERAL] create trigger

2000-12-14 Thread Robert B. Easter

Trigger functions, no matter what language, have be RETURNS OPAQUE.

Here is an example (in the PostgreSQL docs):
http://www.comptechnews.com/~reaster/postgres/triggers20290.htm

Sorry I can't help more as I've never actually used C triggers, just PL/pgSQL 
ones.


On Thursday 14 December 2000 18:04, Sandeep Joshi wrote:
> I am trying to use "triggers". I get an error after "create trigger".
> Does anybody know why?
>
>  create function insert_into_db2 RETURNS int AS
> '/work/posgresql/lib/libpq.so' language 'C';
>
>  create trigger trial before insert or update on db1user for each row
> execute procedure  insert_into_db2();
>
>  ERROR:  CreateTrigger: function insert_into_db2() must return OPAQUE
>
> Does anybody know why?
>
> Also, if a function is enforced to return OPAQUE then  what is the
> "RETURNS" clause?
>
>
> One more question,
>  If a trigger does not succeed then I want to ABORT transaction, is
> it possible? how?
>
>
> - Sandeep

-- 
 Robert B. Easter  [EMAIL PROTECTED] -
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
-- http://www.comptechnews.com/~reaster/ 



Re: [GENERAL] extra spaces

2000-12-14 Thread Brett W. McCoy

On Thu, 14 Dec 2000, Soma Interesting wrote:

> I'm using PHP & PostgreSQL.
>
> All values called from the database are still padded with extra spaces from
> the column size in the database. Is this normal - I don't remember this
> happening when I was using MySQL. I thought usually the database stripped
> the extra spaces when it retrieved the values.
>
> How do you recommend dealing with this, using a PHP command to strip every
> value from the database - or can I change something in the database to have
> it strip the spaces auto magic like?

Sounds like you are using fixed length strings (char) rather than variable
length strings (varchar).

-- Brett
 http://www.chapelperilous.net/~bmccoy/
---
A fool-proof method for sculpting an elephant: first, get a huge block of
marble; then you chip away everything that doesn't look like an elephant.




[GENERAL] create trigger

2000-12-14 Thread Sandeep Joshi

I am trying to use "triggers". I get an error after "create trigger".
Does anybody know why?

 create function insert_into_db2 RETURNS int AS
'/work/posgresql/lib/libpq.so' language 'C';

 create trigger trial before insert or update on db1user for each row
execute procedure  insert_into_db2();

 ERROR:  CreateTrigger: function insert_into_db2() must return OPAQUE

Does anybody know why?

Also, if a function is enforced to return OPAQUE then  what is the
"RETURNS" clause?


One more question,
 If a trigger does not succeed then I want to ABORT transaction, is
it possible? how?


- Sandeep





Re: [GENERAL] extra spaces

2000-12-14 Thread Alex Pilosov

Make your fields to be varchar(x), not char(x)

-alex

On Thu, 14 Dec 2000, Soma Interesting wrote:

> I'm using PHP & PostgreSQL.
> 
> All values called from the database are still padded with extra spaces from 
> the column size in the database. Is this normal - I don't remember this 
> happening when I was using MySQL. I thought usually the database stripped 
> the extra spaces when it retrieved the values.
> 
> How do you recommend dealing with this, using a PHP command to strip every 
> value from the database - or can I change something in the database to have 
> it strip the spaces auto magic like?
> 
> 
> -  -  -  -  -  -  - 
>   -  -  -  -
> WARNING: Some experts believe that use of any keyboard may cause
> serious injury. Consult Users Guide.
>  
>  [EMAIL PROTECTED]
> 
> 




[GENERAL] extra spaces

2000-12-14 Thread Soma Interesting

I'm using PHP & PostgreSQL.

All values called from the database are still padded with extra spaces from 
the column size in the database. Is this normal - I don't remember this 
happening when I was using MySQL. I thought usually the database stripped 
the extra spaces when it retrieved the values.

How do you recommend dealing with this, using a PHP command to strip every 
value from the database - or can I change something in the database to have 
it strip the spaces auto magic like?


-  -  -  -  -  -  - 
  -  -  -  -
WARNING: Some experts believe that use of any keyboard may cause
serious injury. Consult Users Guide.
   
[EMAIL PROTECTED]




Re: [GENERAL] Postgres demographics?

2000-12-14 Thread Jeff MacDonald

which just happens to be a sym link all to the same dir :)

jeff

On Mon, 11 Dec 2000, Tim Barnard wrote:

> 
> > 
> > We have some demographics available at http://www.pgsql.com/user_gallery
> > 
> 
> 
> I believe what was intended was:
> 
> http://www.pgsql.com/register
> 
> Tim
> 
> 

Jeff MacDonald,

-
PostgreSQL Inc  | Hub.Org Networking Services
[EMAIL PROTECTED]  | [EMAIL PROTECTED]
www.pgsql.com   | www.hub.org
1-902-542-0713  | 1-902-542-3657
-
Facsimile : 1 902 542 5386
IRC Nick  : bignose
PGP Public Key : http://bignose.hub.org/public.txt




Re: [GENERAL] is libpq thread-safe?

2000-12-14 Thread Alfred Perlstein

* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [001214 13:20] wrote:
> A staight forward question:
> 
>Is "libpq" thread-safe??
> 
> And an elaboration:
> 
>I want to write a server that opens-up a number of connections 
>to a PostgreSQL database, and then spawns threads handing a connection
>object (PGconn) to each thread, so that all the threads can
>perform data-base operations (queries) simultaneously. Each thread will
>use its own connection object. Will this work??

These are answered in the online docs.  Libpq is threadsafe with a 
few exceptions, see the docs for functions you shouldn't call.

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."