Correct Insert SQL syntax?
Correct Insert SQL syntax?
От:
"Ruben Gouveia" <rubes7202@gmail.com>
Дата:
Will this syntax work:
fcn_stats are all in the same schema
CREATE OR REPLACE FUNCTION insert_stats(p_date date)
RETURNS void AS $$
BEGIN
insert into stats (
date,
stats1,
stats2
) (select
p_date,
fcn_stats1(p_date,'basic'),
fcn_stats2(p_date,'basic',0)
from dual
);
END;
$$ LANGUAGE 'plpgsql';
fcn_stats are all in the same schema
CREATE OR REPLACE FUNCTION insert_stats(p_date date)
RETURNS void AS $$
BEGIN
insert into stats (
date,
stats1,
stats2
) (select
p_date,
fcn_stats1(p_date,'basic'),
fcn_stats2(p_date,'basic',0)
from dual
);
END;
$$ LANGUAGE 'plpgsql';
Re: Correct Insert SQL syntax?
От:
"Yura Gal" <yuragal@gmail.com>
Дата:
There is no internal dual table in PG unlike Ora:) If you need to invoke non-set-returning function simply execute: SELECT my_func(p1, p2...); -- Best regards, Yuri.
Re: Correct Insert SQL syntax?
От:
"Ruben Gouveia" <rubes7202@gmail.com>
Дата:
Thanks Yuri!
On Thu, Sep 4, 2008 at 3:49 PM, Yura Gal <yuragal@gmail.com> wrote:
There is no internal dual table in PG unlike Ora:) If you need to
invoke non-set-returning function simply execute:
SELECT my_func(p1, p2...);
--
Best regards, Yuri.
Re: Correct Insert SQL syntax?
От:
"Bart Degryse" <Bart.Degryse@indicator.be>
Дата:
You might wanna check out the PostgreSQL manual.
There's definitely an answer in it to all your questions.
Especially chapter 38 on migrating from Oracle to PostgreSQL might be helpful.
http://www.postgresql.org/docs/8.3/interactive/plpgsql-porting.html
>>> "Ruben Gouveia" <rubes7202@gmail.com> 2008-09-05 0:56 >>>
>>> "Ruben Gouveia" <rubes7202@gmail.com> 2008-09-05 0:56 >>>
Thanks Yuri!
On Thu, Sep 4, 2008 at 3:49 PM, Yura Gal <yuragal@gmail.com> wrote:
There is no internal dual table in PG unlike Ora:) If you need to
invoke non-set-returning function simply execute:
SELECT my_func(p1, p2...);
--
Best regards, Yuri.
Re: Correct Insert SQL syntax?
От:
Lennin Caro <lennin.caro@yahoo.com>
Дата:
--- On Thu, 9/4/08, Ruben Gouveia wrote:
> From: Ruben Gouveia
> Subject: [SQL] Correct Insert SQL syntax?
> To: "pgsql-sql"
> Date: Thursday, September 4, 2008, 10:16 PM
> Will this syntax work:
>
> fcn_stats are all in the same schema
>
> CREATE OR REPLACE FUNCTION insert_stats(p_date date)
> RETURNS void AS $$
>
> BEGIN
> insert into stats (
> date,
> stats1,
> stats2
> ) (select
> p_date,
>
> fcn_stats1(p_date,'basic'),
>
> fcn_stats2(p_date,'basic',0)
> from dual
> );
> END;
> $$ LANGUAGE 'plpgsql';
Dual is a table create for you or is the generic table of oracle?
Re: Correct Insert SQL syntax?
От:
"Scott Marlowe" <scott.marlowe@gmail.com>
Дата:
On Fri, Sep 5, 2008 at 10:11 AM, Lennin Caro wrote: > --- On Thu, 9/4/08, Ruben Gouveia wrote: >> ) (select >> p_date, >> >> fcn_stats1(p_date,'basic'), >> >> fcn_stats2(p_date,'basic',0) >> from dual > > Dual is a table create for you or is the generic table of oracle? Dual is a special table oracle creates that always has one row and one row only so you have a target for your from clause always. PostgreSQL has the syntactic weirdness that everything is a function that makes some sql syntax hard to implement or get changed, oracle's weirdness (well, one of many really) is the requirement of a target table. the spec would seem to side with oracle on this, but it is a pain the butt.