how to put procedure inside package












0















I have a package:



CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
CREATE OR REPLACE PROCEDURE details
IS
BEGIN
select *
FROM table1;
END details;
END;
/


But I am getting error message



Warning: Package Body created with compilation errors.


I am new to pl/sql, and trying to learn how to use package and procedure. I know my code might be far from correct. Tell me what changes i can do in my code to make it work










share|improve this question

























  • Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

    – Kaushik Nayak
    Nov 21 '18 at 5:48











  • Instead of just showing the code that worked, why not show what didn't work?

    – Jeffrey Kemp
    Nov 26 '18 at 7:45











  • @JeffreyKemp see the above code..this is the code which is not working

    – shubham
    Nov 27 '18 at 8:50











  • You need to store the result of the select somewhere. You can't just run a select like that and discard the result

    – a_horse_with_no_name
    Nov 27 '18 at 9:01











  • @a_horse_with_no_name can you tell me how to store the result of select?

    – shubham
    Nov 27 '18 at 9:02
















0















I have a package:



CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
CREATE OR REPLACE PROCEDURE details
IS
BEGIN
select *
FROM table1;
END details;
END;
/


But I am getting error message



Warning: Package Body created with compilation errors.


I am new to pl/sql, and trying to learn how to use package and procedure. I know my code might be far from correct. Tell me what changes i can do in my code to make it work










share|improve this question

























  • Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

    – Kaushik Nayak
    Nov 21 '18 at 5:48











  • Instead of just showing the code that worked, why not show what didn't work?

    – Jeffrey Kemp
    Nov 26 '18 at 7:45











  • @JeffreyKemp see the above code..this is the code which is not working

    – shubham
    Nov 27 '18 at 8:50











  • You need to store the result of the select somewhere. You can't just run a select like that and discard the result

    – a_horse_with_no_name
    Nov 27 '18 at 9:01











  • @a_horse_with_no_name can you tell me how to store the result of select?

    – shubham
    Nov 27 '18 at 9:02














0












0








0








I have a package:



CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
CREATE OR REPLACE PROCEDURE details
IS
BEGIN
select *
FROM table1;
END details;
END;
/


But I am getting error message



Warning: Package Body created with compilation errors.


I am new to pl/sql, and trying to learn how to use package and procedure. I know my code might be far from correct. Tell me what changes i can do in my code to make it work










share|improve this question
















I have a package:



CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
CREATE OR REPLACE PROCEDURE details
IS
BEGIN
select *
FROM table1;
END details;
END;
/


But I am getting error message



Warning: Package Body created with compilation errors.


I am new to pl/sql, and trying to learn how to use package and procedure. I know my code might be far from correct. Tell me what changes i can do in my code to make it work







plsql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 8:57







shubham

















asked Nov 20 '18 at 22:41









shubhamshubham

75




75













  • Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

    – Kaushik Nayak
    Nov 21 '18 at 5:48











  • Instead of just showing the code that worked, why not show what didn't work?

    – Jeffrey Kemp
    Nov 26 '18 at 7:45











  • @JeffreyKemp see the above code..this is the code which is not working

    – shubham
    Nov 27 '18 at 8:50











  • You need to store the result of the select somewhere. You can't just run a select like that and discard the result

    – a_horse_with_no_name
    Nov 27 '18 at 9:01











  • @a_horse_with_no_name can you tell me how to store the result of select?

    – shubham
    Nov 27 '18 at 9:02



















  • Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

    – Kaushik Nayak
    Nov 21 '18 at 5:48











  • Instead of just showing the code that worked, why not show what didn't work?

    – Jeffrey Kemp
    Nov 26 '18 at 7:45











  • @JeffreyKemp see the above code..this is the code which is not working

    – shubham
    Nov 27 '18 at 8:50











  • You need to store the result of the select somewhere. You can't just run a select like that and discard the result

    – a_horse_with_no_name
    Nov 27 '18 at 9:01











  • @a_horse_with_no_name can you tell me how to store the result of select?

    – shubham
    Nov 27 '18 at 9:02

















Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

– Kaushik Nayak
Nov 21 '18 at 5:48





Just go through any tutorial online, for eg: this tutorialspoint.com/plsql/plsql_packages.htm

– Kaushik Nayak
Nov 21 '18 at 5:48













Instead of just showing the code that worked, why not show what didn't work?

– Jeffrey Kemp
Nov 26 '18 at 7:45





Instead of just showing the code that worked, why not show what didn't work?

– Jeffrey Kemp
Nov 26 '18 at 7:45













@JeffreyKemp see the above code..this is the code which is not working

– shubham
Nov 27 '18 at 8:50





@JeffreyKemp see the above code..this is the code which is not working

– shubham
Nov 27 '18 at 8:50













You need to store the result of the select somewhere. You can't just run a select like that and discard the result

– a_horse_with_no_name
Nov 27 '18 at 9:01





You need to store the result of the select somewhere. You can't just run a select like that and discard the result

– a_horse_with_no_name
Nov 27 '18 at 9:01













@a_horse_with_no_name can you tell me how to store the result of select?

– shubham
Nov 27 '18 at 9:02





@a_horse_with_no_name can you tell me how to store the result of select?

– shubham
Nov 27 '18 at 9:02












1 Answer
1






active

oldest

votes


















0














Use



PROCEDURE details


instead of



CREATE OR REPLACE PROCEDURE details


https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905



On the other hand, the SELECT statement needs a INTO statement. So the code could be:



CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
PROCEDURE details
IS
l_rec table1%ROWTYPE;
BEGIN
SELECT *
INTO l_rec
FROM table1;
END details;
END pack1;





share|improve this answer

























    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%2f53402682%2fhow-to-put-procedure-inside-package%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














    Use



    PROCEDURE details


    instead of



    CREATE OR REPLACE PROCEDURE details


    https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905



    On the other hand, the SELECT statement needs a INTO statement. So the code could be:



    CREATE OR REPLACE PACKAGE pack1
    AS
    PROCEDURE details;
    END pack1;
    /
    CREATE OR REPLACE PACKAGE BODY pack1
    AS
    PROCEDURE details
    IS
    l_rec table1%ROWTYPE;
    BEGIN
    SELECT *
    INTO l_rec
    FROM table1;
    END details;
    END pack1;





    share|improve this answer






























      0














      Use



      PROCEDURE details


      instead of



      CREATE OR REPLACE PROCEDURE details


      https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905



      On the other hand, the SELECT statement needs a INTO statement. So the code could be:



      CREATE OR REPLACE PACKAGE pack1
      AS
      PROCEDURE details;
      END pack1;
      /
      CREATE OR REPLACE PACKAGE BODY pack1
      AS
      PROCEDURE details
      IS
      l_rec table1%ROWTYPE;
      BEGIN
      SELECT *
      INTO l_rec
      FROM table1;
      END details;
      END pack1;





      share|improve this answer




























        0












        0








        0







        Use



        PROCEDURE details


        instead of



        CREATE OR REPLACE PROCEDURE details


        https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905



        On the other hand, the SELECT statement needs a INTO statement. So the code could be:



        CREATE OR REPLACE PACKAGE pack1
        AS
        PROCEDURE details;
        END pack1;
        /
        CREATE OR REPLACE PACKAGE BODY pack1
        AS
        PROCEDURE details
        IS
        l_rec table1%ROWTYPE;
        BEGIN
        SELECT *
        INTO l_rec
        FROM table1;
        END details;
        END pack1;





        share|improve this answer















        Use



        PROCEDURE details


        instead of



        CREATE OR REPLACE PROCEDURE details


        https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905



        On the other hand, the SELECT statement needs a INTO statement. So the code could be:



        CREATE OR REPLACE PACKAGE pack1
        AS
        PROCEDURE details;
        END pack1;
        /
        CREATE OR REPLACE PACKAGE BODY pack1
        AS
        PROCEDURE details
        IS
        l_rec table1%ROWTYPE;
        BEGIN
        SELECT *
        INTO l_rec
        FROM table1;
        END details;
        END pack1;






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 3 at 19:24

























        answered Jan 3 at 19:18









        DonDorianDonDorian

        765




        765
































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402682%2fhow-to-put-procedure-inside-package%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

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)