Re: Syntax error in spi_prepare usage

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: dipti shah <shahdipti1980(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Syntax error in spi_prepare usage
Date: 2010-04-24 16:45:03
Message-ID: 530C4DC6-8B9D-434F-B882-E2B269246F8A@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> If I remove the braces from (\$1, \$2, \$3) then it gives below error.
>
> my $query = (<<ENDQUERY);
> INSERT INTO changelogtest(id, txid, txtime)
> SELECT \$1, \$2, \$3
> EXCEPT
> SELECT (id, txid, txtime)
> FROM changelogtest
> WHERE id = \$1
> AND txid = \$2
> AND txtime = \$3;
> ENDQUERY
>
> techdb=# SELECT insert_history_info();
> ERROR: error from Perl function "insert_history_info": each EXCEPT query must have the same number of columns at line 15.

Yes of course, your select lists are different. Try:
> my $query = (<<ENDQUERY);
> INSERT INTO changelogtest(id, txid, txtime)
> SELECT \$1, \$2, \$3
> EXCEPT
> SELECT id, txid, txtime
> FROM changelogtest
> WHERE id = \$1
> AND txid = \$2
> AND txtime = \$3;
> ENDQUERY

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,4bd3201310412109115467!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam 2010-04-24 17:48:43 Help me stop postgres from crashing.
Previous Message Steve Atkins 2010-04-24 15:55:06 Re: ISP provider with postgres and perl dbi