Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7277881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:48:02+00:00 2026-05-28T22:48:02+00:00

I want to use some smart procedures I wrote, but not store them. For

  • 0

I want to use some smart procedures I wrote, but not store them. For example here is this quite big select, that retrieves the primary keys for a table:

SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = 'TABLE_NAME'
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position;

I don’t want to remember this, not even type it every time I need the constraints of a table. BUT I don’t want to create a procedure for this into the DB, because it is a prod DB, and noone else needs my procedure. Just me. Just for developing.

So here is where I am now:

SQL> declare procedure hello as begin dbms_output.put_line('Hello world!'); end; begin hello; end;
  2  /
Hello world!

PL/SQL procedure successfully completed.

SQL> hello;
SP2-0042: unknown command "hello" - rest of line ignored.

… so I can declare and define hello function from command line. I can call it from the begin – end block after the declare, but after that the hello procedure is gone.

Question: is there a solution to make the second “hello;” work, so I can create clever and useful procedures and not make any trash in the DB itself?

If this would work, I would create a file with that, and make the alias for sqlplus to execute that file at startup.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:48:03+00:00Added an answer on May 28, 2026 at 10:48 pm

    You could put each of your queries (are they really procs?) in its own file in your SQLPATH directory, but with positional parameters; e.g. a file called pkeys.sql:

    SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
    FROM all_constraints cons, all_cons_columns cols
    WHERE cols.table_name = '&1'
    AND cons.constraint_type = 'P'
    AND cons.constraint_name = cols.constraint_name
    AND cons.owner = cols.owner
    ORDER BY cols.table_name, cols.position;
    

    The from SQL*Plus you can just do:

    @pkeys TABLE_NAME
    

    If it is a procedure you can still have your declare procedure ... begin ... end form, and have the call pass &1 to the procedure. Actually, this is pretty much what StevieG was getting at, but with the positional parameter to remove the need to edit the file each time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m creating a game, in that i want to use some animation, but
I use some code to encrypt & decrypt string in C# but i want
I want to use smart pointers in my code but I can't figure out
I'm doing some math with really big numbers (I'm using Python, but this question
i want use some data from a website with web service. i have a
I want to use some of the widgets found in JQuery UI in my
I want to use some Python libraries to replace MATLAB. How could I import
I want to use some thing unique for a licensing system. i decided to
I want to use some NSAssert stuff and other things to enable better debugging
I want to use some kind of trigger to change a button in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.