PostgreSQL: Store function pointers in tableEfficiently select beginning and end of multiple contiguous...

Booking honeymoon before name change

Which was the first story to feature space elevators?

Have any astronauts or cosmonauts died in space?

Badly designed reimbursement form. What does that say about the company?

How do I limit the number of rows that are loaded in a QGIS attribute table?

Can I legally make a website about boycotting a certain company?

1730 House how to make Ceiling Level

Build ASCII Podiums

Self-join example review in Books Online

What is the source for this Leonardo Da Vinci quote?

How should I ship cards?

text{ } subscript size in tikzmath macro is not correct

Is Apex Sometimes Case Sensitive?

How can guns be countered by melee combat without raw-ability or exceptional explanations?

What are Holorydmachines?

Automated testing of chained Queueable jobs in Salesforce

Is Screenshot Time-tracking Common?

Coworker is trying to get me to sign his petition to run for office. How to decline politely?

Can "ee" appear in Latin?

Buying a "Used" Router

Found a major flaw in paper from home university – to which I would like to return

How do I add a strong "onion flavor" to the biryani (in restaurant style)?

Boiling meatballs, how long?

How to encourage team to refactor



PostgreSQL: Store function pointers in table


Efficiently select beginning and end of multiple contiguous ranges in Postgresql queryPostgreSQL trigger function that selects from %current% tableArray of template type in PL/pgSQL function using %TYPELoop over string literals as input to function PostgreSQL 9.4PostgreSQL: Pass table as argument in functionFunction that returns table with an additional columnPostgreSQL: translating user-defined calculations into executable calculation in triggercreating postgresql function with table as inputHow to pass a function parameter into nested function callCustom return type of a function in Oracle PL SQl













0















I'm wondering if it's possible to have a column in a Postgres table be of a function type. For example, something to the effect of:



CREATE TABLE profile_logic(
profile text,
profile_specific_function (text, int) -> int
);


In this example, there is some application logic that is specific to each profile. For each profile, I'd like to take in a string and an integer to produce another integer. I'd like to be able to join with another table on the profile column and then run my profile_specific_function. Is this possible in PostgreSQL?










share|improve this question














bumped to the homepage by Community 2 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I'm wondering if it's possible to have a column in a Postgres table be of a function type. For example, something to the effect of:



    CREATE TABLE profile_logic(
    profile text,
    profile_specific_function (text, int) -> int
    );


    In this example, there is some application logic that is specific to each profile. For each profile, I'd like to take in a string and an integer to produce another integer. I'd like to be able to join with another table on the profile column and then run my profile_specific_function. Is this possible in PostgreSQL?










    share|improve this question














    bumped to the homepage by Community 2 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I'm wondering if it's possible to have a column in a Postgres table be of a function type. For example, something to the effect of:



      CREATE TABLE profile_logic(
      profile text,
      profile_specific_function (text, int) -> int
      );


      In this example, there is some application logic that is specific to each profile. For each profile, I'd like to take in a string and an integer to produce another integer. I'd like to be able to join with another table on the profile column and then run my profile_specific_function. Is this possible in PostgreSQL?










      share|improve this question














      I'm wondering if it's possible to have a column in a Postgres table be of a function type. For example, something to the effect of:



      CREATE TABLE profile_logic(
      profile text,
      profile_specific_function (text, int) -> int
      );


      In this example, there is some application logic that is specific to each profile. For each profile, I'd like to take in a string and an integer to produce another integer. I'd like to be able to join with another table on the profile column and then run my profile_specific_function. Is this possible in PostgreSQL?







      postgresql functions






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 7 '17 at 14:34









      MattMatt

      1012




      1012





      bumped to the homepage by Community 2 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 2 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          It depends on a bunch of factors and what you need to get done.




          1. Do you really need typing? What are you trying to accomplish?

          2. What language do you want to write the function in?

          3. You could write the function in plperl or plv8 as a string and then eval-compile it and provide the first column as an argument. Would that work?

          4. If you need plpgsql, the solution will have to be a little more creative with a dynamically created DO block.

          5. How many profile specific functions do you need. I'm assuming you want to store the profile_specific_function specific function on the table? Are you just looking to call an external profile_specific_function?






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f187931%2fpostgresql-store-function-pointers-in-table%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It depends on a bunch of factors and what you need to get done.




            1. Do you really need typing? What are you trying to accomplish?

            2. What language do you want to write the function in?

            3. You could write the function in plperl or plv8 as a string and then eval-compile it and provide the first column as an argument. Would that work?

            4. If you need plpgsql, the solution will have to be a little more creative with a dynamically created DO block.

            5. How many profile specific functions do you need. I'm assuming you want to store the profile_specific_function specific function on the table? Are you just looking to call an external profile_specific_function?






            share|improve this answer




























              0














              It depends on a bunch of factors and what you need to get done.




              1. Do you really need typing? What are you trying to accomplish?

              2. What language do you want to write the function in?

              3. You could write the function in plperl or plv8 as a string and then eval-compile it and provide the first column as an argument. Would that work?

              4. If you need plpgsql, the solution will have to be a little more creative with a dynamically created DO block.

              5. How many profile specific functions do you need. I'm assuming you want to store the profile_specific_function specific function on the table? Are you just looking to call an external profile_specific_function?






              share|improve this answer


























                0












                0








                0







                It depends on a bunch of factors and what you need to get done.




                1. Do you really need typing? What are you trying to accomplish?

                2. What language do you want to write the function in?

                3. You could write the function in plperl or plv8 as a string and then eval-compile it and provide the first column as an argument. Would that work?

                4. If you need plpgsql, the solution will have to be a little more creative with a dynamically created DO block.

                5. How many profile specific functions do you need. I'm assuming you want to store the profile_specific_function specific function on the table? Are you just looking to call an external profile_specific_function?






                share|improve this answer













                It depends on a bunch of factors and what you need to get done.




                1. Do you really need typing? What are you trying to accomplish?

                2. What language do you want to write the function in?

                3. You could write the function in plperl or plv8 as a string and then eval-compile it and provide the first column as an argument. Would that work?

                4. If you need plpgsql, the solution will have to be a little more creative with a dynamically created DO block.

                5. How many profile specific functions do you need. I'm assuming you want to store the profile_specific_function specific function on the table? Are you just looking to call an external profile_specific_function?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 7 '17 at 19:44









                Evan CarrollEvan Carroll

                32.4k970221




                32.4k970221






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f187931%2fpostgresql-store-function-pointers-in-table%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Parapolítica Índice Antecedentes El escándalo Proceso judicial Consecuencias Véase...

                    How to remove border from elements in the last row?Targeting flex items on the last rowHow to vertically wrap...

                    Tecnologías entrañables Índice Antecedentes Desarrollo Tecnologías Entrañables en la...