Jump to content

Postgres pg_prepare , pg_execute and INSERT problem


pentium10

Recommended Posts

Hello,

 

I have a rule setup on PostgreSQL to return a column after insert.

 

CREATE RULE get_projectkey_on_insert AS ON INSERT TO projects DO SELECT currval(('projects_id_seq'::text)::regclass) AS id;

 

I use pg_prepare, and pg_execute

 

 
$sql="insert into " . $this->TableName. " (username,companycode,projectname) values ($1,$2,$3)";
$this->result=@pg_prepare("projects_insert",$sql)  or die(pg_errormessage());

 

 
$this->result=@pg_execute("projects_insert",
    array(
        $GLOBALS["username"],
        $GLOBALS["companycode"],
        ''
        )
    ) or die(pg_errormessage());

 

My problem is that pg_execute result seams empty and I cannot get the expected value the ID of the projects table.

Can you help?

 

Regards,

Pentium10

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.