How can we execute Oracle sequence in Postgres?












0














In between migration from Oracle to Postgres, I need to execute some insert statement for an Oracle table from Postgres (in which the primary key field is using a sequence for uniqueness).



Now at the time of the migration I am converting some procedure that is used to insert a row in a table, but I can't move table directly from oracle to Postgres due to a higher dependency on the table.



That's why I need to execute an Oracle sequence from Postgres.










share|improve this question
























  • Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
    – Tim Biegeleisen
    Nov 12 at 5:45
















0














In between migration from Oracle to Postgres, I need to execute some insert statement for an Oracle table from Postgres (in which the primary key field is using a sequence for uniqueness).



Now at the time of the migration I am converting some procedure that is used to insert a row in a table, but I can't move table directly from oracle to Postgres due to a higher dependency on the table.



That's why I need to execute an Oracle sequence from Postgres.










share|improve this question
























  • Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
    – Tim Biegeleisen
    Nov 12 at 5:45














0












0








0







In between migration from Oracle to Postgres, I need to execute some insert statement for an Oracle table from Postgres (in which the primary key field is using a sequence for uniqueness).



Now at the time of the migration I am converting some procedure that is used to insert a row in a table, but I can't move table directly from oracle to Postgres due to a higher dependency on the table.



That's why I need to execute an Oracle sequence from Postgres.










share|improve this question















In between migration from Oracle to Postgres, I need to execute some insert statement for an Oracle table from Postgres (in which the primary key field is using a sequence for uniqueness).



Now at the time of the migration I am converting some procedure that is used to insert a row in a table, but I can't move table directly from oracle to Postgres due to a higher dependency on the table.



That's why I need to execute an Oracle sequence from Postgres.







postgresql oracle-fdw






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 6:59









Laurenz Albe

44.1k102746




44.1k102746










asked Nov 12 at 5:44









Kailash Dhaker

315




315












  • Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
    – Tim Biegeleisen
    Nov 12 at 5:45


















  • Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
    – Tim Biegeleisen
    Nov 12 at 5:45
















Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
– Tim Biegeleisen
Nov 12 at 5:45




Please add some more detail and/or code to your question to make it concrete. Not sure what you are asking here.
– Tim Biegeleisen
Nov 12 at 5:45












1 Answer
1






active

oldest

votes


















0














The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.



Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.



Wheb you INSERT into the foreign table, the column will get filled by the trigger.






share|improve this answer





















  • You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
    – a_horse_with_no_name
    Nov 12 at 6:57










  • Sure, that's an option if you never want to explicitly fill the column.
    – Laurenz Albe
    Nov 12 at 7:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f53256476%2fhow-can-we-execute-oracle-sequence-in-postgres%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














The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.



Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.



Wheb you INSERT into the foreign table, the column will get filled by the trigger.






share|improve this answer





















  • You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
    – a_horse_with_no_name
    Nov 12 at 6:57










  • Sure, that's an option if you never want to explicitly fill the column.
    – Laurenz Albe
    Nov 12 at 7:01
















0














The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.



Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.



Wheb you INSERT into the foreign table, the column will get filled by the trigger.






share|improve this answer





















  • You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
    – a_horse_with_no_name
    Nov 12 at 6:57










  • Sure, that's an option if you never want to explicitly fill the column.
    – Laurenz Albe
    Nov 12 at 7:01














0












0








0






The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.



Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.



Wheb you INSERT into the foreign table, the column will get filled by the trigger.






share|improve this answer












The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.



Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.



Wheb you INSERT into the foreign table, the column will get filled by the trigger.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 6:54









Laurenz Albe

44.1k102746




44.1k102746












  • You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
    – a_horse_with_no_name
    Nov 12 at 6:57










  • Sure, that's an option if you never want to explicitly fill the column.
    – Laurenz Albe
    Nov 12 at 7:01


















  • You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
    – a_horse_with_no_name
    Nov 12 at 6:57










  • Sure, that's an option if you never want to explicitly fill the column.
    – Laurenz Albe
    Nov 12 at 7:01
















You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
– a_horse_with_no_name
Nov 12 at 6:57




You don't really need the view - the trigger could simply ignore any value supplied for that column or check for NULL and only then use the sequence
– a_horse_with_no_name
Nov 12 at 6:57












Sure, that's an option if you never want to explicitly fill the column.
– Laurenz Albe
Nov 12 at 7:01




Sure, that's an option if you never want to explicitly fill the column.
– Laurenz Albe
Nov 12 at 7:01


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2fstackoverflow.com%2fquestions%2f53256476%2fhow-can-we-execute-oracle-sequence-in-postgres%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

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues