pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
plpgsql function-parsing
2+ messages / 2 participants
[nested] [flat]

* plpgsql function-parsing
@ 2018-03-06 15:51  chris <chrisk@pgsqlrocket.com>
  0 siblings, 1 reply; 2+ messages in thread

From: chris @ 2018-03-06 15:51 UTC (permalink / raw)
  To: pgsql-general

Hi,

I am trying to create a function that gets passed a statement as a 
string and then I need to change the table_name within the string by 
adding a "_cdc" to it, then execute the statement

ex:

string passed could be GRANT all ON authors TO bob.

then

EXECUTE GRANT all ON authors_cdc TO bob


I'm looking into parsing the string but i can't find a way to parse in a 
way that'll work. Any ideas?


Thanks,

Chris





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

* Re: plpgsql function-parsing
@ 2018-03-06 18:11  Pavel Stehule <pavel.stehule@gmail.com>
  parent: chris <chrisk@pgsqlrocket.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Pavel Stehule @ 2018-03-06 18:11 UTC (permalink / raw)
  To: chris <chrisk@pgsqlrocket.com>; +Cc: pgsql-general

Hi

2018-03-06 16:51 GMT+01:00 chris <chrisk@pgsqlrocket.com>:

> Hi,
>
> I am trying to create a function that gets passed a statement as a string
> and then I need to change the table_name within the string by adding a
> "_cdc" to it, then execute the statement
>
> ex:
>
> string passed could be GRANT all ON authors TO bob.
>
> then
>
> EXECUTE GRANT all ON authors_cdc TO bob
>
>
> I'm looking into parsing the string but i can't find a way to parse in a
> way that'll work. Any ideas?
>

The extension Orafce  https://github.com/orafce/orafce has some basic
library for parsing SQL PLVlex.

Another solution can be using regular expressions
https://www.postgresql.org/docs/current/static/functions-matching.html

Regards

Pavel



>
> Thanks,
>
> Chris
>
>
>

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


end of thread, other threads:[~2018-03-06 18:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 15:51 plpgsql function-parsing chris <chrisk@pgsqlrocket.com>
2018-03-06 18:11 ` Pavel Stehule <pavel.stehule@gmail.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