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
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
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.
add a comment |
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
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.
add a comment |
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
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
postgresql functions
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.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It depends on a bunch of factors and what you need to get done.
- Do you really need typing? What are you trying to accomplish?
- What language do you want to write the function in?
- 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?
- If you need plpgsql, the solution will have to be a little more creative with a dynamically created
DOblock. - How many profile specific functions do you need. I'm assuming you want to store the
profile_specific_functionspecific function on the table? Are you just looking to call an externalprofile_specific_function?
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
It depends on a bunch of factors and what you need to get done.
- Do you really need typing? What are you trying to accomplish?
- What language do you want to write the function in?
- 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?
- If you need plpgsql, the solution will have to be a little more creative with a dynamically created
DOblock. - How many profile specific functions do you need. I'm assuming you want to store the
profile_specific_functionspecific function on the table? Are you just looking to call an externalprofile_specific_function?
add a comment |
It depends on a bunch of factors and what you need to get done.
- Do you really need typing? What are you trying to accomplish?
- What language do you want to write the function in?
- 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?
- If you need plpgsql, the solution will have to be a little more creative with a dynamically created
DOblock. - How many profile specific functions do you need. I'm assuming you want to store the
profile_specific_functionspecific function on the table? Are you just looking to call an externalprofile_specific_function?
add a comment |
It depends on a bunch of factors and what you need to get done.
- Do you really need typing? What are you trying to accomplish?
- What language do you want to write the function in?
- 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?
- If you need plpgsql, the solution will have to be a little more creative with a dynamically created
DOblock. - How many profile specific functions do you need. I'm assuming you want to store the
profile_specific_functionspecific function on the table? Are you just looking to call an externalprofile_specific_function?
It depends on a bunch of factors and what you need to get done.
- Do you really need typing? What are you trying to accomplish?
- What language do you want to write the function in?
- 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?
- If you need plpgsql, the solution will have to be a little more creative with a dynamically created
DOblock. - How many profile specific functions do you need. I'm assuming you want to store the
profile_specific_functionspecific function on the table? Are you just looking to call an externalprofile_specific_function?
answered Oct 7 '17 at 19:44
Evan CarrollEvan Carroll
32.4k970221
32.4k970221
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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