pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Can we use sql language to create a function in Postgres?
8+ messages / 4 participants
[nested] [flat]

* Can we use sql language to create a function in Postgres?
@ 2022-01-05 11:04 Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:08 ` Re: Can we use sql language to create a function in Postgres? Ray O'Donnell <ray@rodonnell.ie>
  2022-01-05 11:12 ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
  0 siblings, 2 replies; 8+ messages in thread

From: Shaozhong SHI @ 2022-01-05 11:04 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

I was given an Oracle script.  Can we use sql language to create a function
in Postgres?

Regards,

David

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-05 11:08 ` Ray O'Donnell <ray@rodonnell.ie>
  2022-01-05 11:10   ` Re: Can we use sql language to create a function in Postgres? Ray O'Donnell <ray@rodonnell.ie>
  1 sibling, 1 reply; 8+ messages in thread

From: Ray O'Donnell @ 2022-01-05 11:08 UTC (permalink / raw)
  To: Shaozhong SHI <shishaozhong@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 05/01/2022 11:04, Shaozhong SHI wrote:
> I was given an Oracle script.  Can we use sql language to create a 
> function in Postgres?

Yes, absolutely:

create function my_function(...)
as
$$
   select.....
$$
language sql;


Is this what you mean?


Ray.


-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:08 ` Re: Can we use sql language to create a function in Postgres? Ray O'Donnell <ray@rodonnell.ie>
@ 2022-01-05 11:10   ` Ray O'Donnell <ray@rodonnell.ie>
  0 siblings, 0 replies; 8+ messages in thread

From: Ray O'Donnell @ 2022-01-05 11:10 UTC (permalink / raw)
  To: Shaozhong SHI <shishaozhong@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 05/01/2022 11:08, Ray O'Donnell wrote:
> On 05/01/2022 11:04, Shaozhong SHI wrote:
>> I was given an Oracle script.  Can we use sql language to create a 
>> function in Postgres?
> 
> Yes, absolutely:
> 
> create function my_function(...)
> as
> $$
>    select.....
> $$
> language sql;

Should have added the link to the docs:

https://www.postgresql.org/docs/14/server-programming.html

Ray.


-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-05 11:12 ` hubert depesz lubaczewski <depesz@depesz.com>
  2022-01-05 11:22   ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: hubert depesz lubaczewski @ 2022-01-05 11:12 UTC (permalink / raw)
  To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On Wed, Jan 05, 2022 at 11:04:34AM +0000, Shaozhong SHI wrote:
> I was given an Oracle script.  Can we use sql language to create a function
> in Postgres?

Sure:

create function z() returns int4 language sql as $$
select 123;
$$;

depesz





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:12 ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
@ 2022-01-05 11:22   ` Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:26     ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:34     ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
  0 siblings, 2 replies; 8+ messages in thread

From: Shaozhong SHI @ 2022-01-05 11:22 UTC (permalink / raw)
  To: depesz@depesz.com; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

If so, can we use Oracle SQL script in DO block?

Does this mean that all Oracle SQL can be used in Postgres?

Regards,

David

On Wed, 5 Jan 2022 at 11:12, hubert depesz lubaczewski <depesz@depesz.com>
wrote:

> On Wed, Jan 05, 2022 at 11:04:34AM +0000, Shaozhong SHI wrote:
> > I was given an Oracle script.  Can we use sql language to create a
> function
> > in Postgres?
>
> Sure:
>
> create function z() returns int4 language sql as $$
> select 123;
> $$;
>
> depesz
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:12 ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
  2022-01-05 11:22   ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-05 11:26     ` Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 17:42       ` Re: Can we use sql language to create a function in Postgres? Merlin Moncure <mmoncure@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Shaozhong SHI @ 2022-01-05 11:26 UTC (permalink / raw)
  To: depesz@depesz.com; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

Any online documentation or examples for using Oracle SQL in Postgres?

Regards,

David

On Wed, 5 Jan 2022 at 11:22, Shaozhong SHI <shishaozhong@gmail.com> wrote:

> If so, can we use Oracle SQL script in DO block?
>
> Does this mean that all Oracle SQL can be used in Postgres?
>
> Regards,
>
> David
>
> On Wed, 5 Jan 2022 at 11:12, hubert depesz lubaczewski <depesz@depesz.com>
> wrote:
>
>> On Wed, Jan 05, 2022 at 11:04:34AM +0000, Shaozhong SHI wrote:
>> > I was given an Oracle script.  Can we use sql language to create a
>> function
>> > in Postgres?
>>
>> Sure:
>>
>> create function z() returns int4 language sql as $$
>> select 123;
>> $$;
>>
>> depesz
>>
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:12 ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
  2022-01-05 11:22   ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:26     ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-05 17:42       ` Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Merlin Moncure @ 2022-01-05 17:42 UTC (permalink / raw)
  To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: the <depesz@depesz.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On Wed, Jan 5, 2022 at 5:27 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
>
> Any online documentation or examples for using Oracle SQL in Postgres?

FYI there are commercial offerings (in particular, EDB, which I am not
affiliated with) that minimize compatibility concerns with oracle.  If
doing this by hand, utilizing the lists (which SPECIFIC questions) and
other internet resources is the way to go. There may be some guides,
but the SQL language and other nuance is moving fast, so try to get
contemporary help if possible.  Conversion to postgres will work, and
what you are doing is a good idea.

merlin





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Can we use sql language to create a function in Postgres?
  2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
  2022-01-05 11:12 ` Re: Can we use sql language to create a function in Postgres? hubert depesz lubaczewski <depesz@depesz.com>
  2022-01-05 11:22   ` Re: Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
@ 2022-01-05 11:34     ` hubert depesz lubaczewski <depesz@depesz.com>
  1 sibling, 0 replies; 8+ messages in thread

From: hubert depesz lubaczewski @ 2022-01-05 11:34 UTC (permalink / raw)
  To: Shaozhong SHI <shishaozhong@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

On Wed, Jan 05, 2022 at 11:22:34AM +0000, Shaozhong SHI wrote:
> If so, can we use Oracle SQL script in DO block?
> 
> Does this mean that all Oracle SQL can be used in Postgres?

I highly doubt that.
But - I used oracle last time like 2 years ago, so the only thing I can
tell you: TRY.
instead of asking if "something vague wll work" just try. it will work,
or not work, but I can't guess what you have in this "oracle sql" and
whether this particular bit of sql will be cross-plaftorm enough to
execute (or even parse) in pg.

depesz





^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2022-01-05 17:42 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 11:04 Can we use sql language to create a function in Postgres? Shaozhong SHI <shishaozhong@gmail.com>
2022-01-05 11:08 ` Ray O'Donnell <ray@rodonnell.ie>
2022-01-05 11:10   ` Ray O'Donnell <ray@rodonnell.ie>
2022-01-05 11:12 ` hubert depesz lubaczewski <depesz@depesz.com>
2022-01-05 11:22   ` Shaozhong SHI <shishaozhong@gmail.com>
2022-01-05 11:26     ` Shaozhong SHI <shishaozhong@gmail.com>
2022-01-05 17:42       ` Merlin Moncure <mmoncure@gmail.com>
2022-01-05 11:34     ` hubert depesz lubaczewski <depesz@depesz.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox