Home » SQL & PL/SQL » SQL & PL/SQL » Hide declaration or declare it inside the body of a package
Hide declaration or declare it inside the body of a package [message #447068] Thu, 11 March 2010 16:43 Go to next message
akabir77
Messages: 6
Registered: May 2009
Junior Member
Hi

I have a package which has couple of Procedures and functions. I use some constants between the functions and procedure and also functions r called from the other procedure and stuff...

So I declared all these in the header

Like this
CREATE OR REPLACE PACKAGE       "PROCESS_HISTORY" IS
   type table_name_i is varray(100) of VARCHAR2(30);
   c_add  constant number := 1;
   c_del  constant number := 2;
   c_select_frm_tmp  constant number := 1;
   c_nipr_date  constant number := 2;
   c_date  constant number := 3;
       
   PROCEDURE get_column_names (i_table_name IN VARCHAR2, o_columns OUT VARCHAR2);
   FUNCTION tableList RETURN table_name_i;
   FUNCTION runQuery(i_history_owner IN VARCHAR2, i_table_name IN  VARCHAR2, 
     i_add_del IN NUMBER, i_where_clause IN NUMBER, i_start_date IN DATE) 
   RETURN NUMBER;
   PROCEDURE display(i_archive_table IN table_name_i, i_archive_count IN table_name_i);
   PROCEDURE gwTranActive2History (i_history_owner IN VARCHAR2);
   --PROCEDURE gwTranHistory2Active (i_history_owner IN VARCHAR2);
END;



Now is there anyway I could hide the stuff that I don't want outside people to see? or can I declare them (constanst and some functions) some where inside the body and use them?

I am new to this pl sql. need help.

Thanks
Re: Hide declaration or declare it inside the body of a package [message #447075 is a reply to message #447068] Thu, 11 March 2010 19:06 Go to previous messageGo to next message
BlackSwan
Messages: 25045
Registered: January 2009
Location: SoCal
Senior Member
>Now is there anyway I could hide the stuff that I don't want outside people to see?

When I need to "hide stuff" I use correction fluid.
http://en.wikipedia.org/wiki/Correction_fluid

How will an independent observer conclude your problem has been solved?

Please clarify your requirement(s).

[Updated on: Thu, 11 March 2010 19:06]

Report message to a moderator

Re: Hide declaration or declare it inside the body of a package [message #447081 is a reply to message #447068] Thu, 11 March 2010 20:34 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
Constants declare in Package body will not Be accessible for other procs or packages. ( you can call it 'Hide' ) but other people can see your code and know what is the value of constant. Smile


CREATE OR REPLACE
PACKAGE hide
AS
PROCEDURE myProc;
END hide;

CREATE OR REPLACE
PACKAGE Body hide
                       IS
	c_add constant NUMBER := 1;
PROCEDURE myProc
IS
BEGIN
	dbms_output.put_line ('Constant :- ' || c_add) ;
END;
END;

SQL> set serverout on ;
SQL> exec hide.myproc;
Constant :- 1

PL/SQL procedure successfully completed.

SQL>


hope this help.

[Updated on: Thu, 11 March 2010 20:35]

Report message to a moderator

Re: Hide declaration or declare it inside the body of a package [message #447094 is a reply to message #447068] Thu, 11 March 2010 22:08 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Google for WRAP utility. DBMS_DDL will also help you.
Before working on it, please go through its docs and its limitations as well.

regards,
Delna
Re: Hide declaration or declare it inside the body of a package [message #447112 is a reply to message #447068] Thu, 11 March 2010 22:57 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
Thanks Delna.

akabir77 .. check follwing link WRAP
Re: Hide declaration or declare it inside the body of a package [message #447154 is a reply to message #447068] Fri, 12 March 2010 00:58 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You already got an answer to your question, so I won't go there, but since you mention being new to PL/SQL, I thought I'd give you some advice:
Do not use double quotes in Oracle (like you did around your package name). Never.
References to object names in Oracle are case insensitive. Adding double quotes removes this case insensitivity. You don't want to do that.
Re: Hide declaration or declare it inside the body of a package [message #447176 is a reply to message #447154] Fri, 12 March 2010 03:20 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
Frank wrote on Fri, 12 March 2010 00:58
Adding double quotes removes this case insensitivity. You don't want to do that.


I did not get it Frank.


SQL>CREATE OR REPLACE
  2  PACKAGE "HIDE"
  3  AS
  4  PROCEDURE myProc;
  5  END "HIDE";
  6  /

Package created.

Elapsed: 00:00:00.28
SQL>CREATE OR REPLACE
  2  PACKAGE Body "HIDE"
  3                         IS
  4   c_add constant NUMBER := 1;
  5  PROCEDURE myProc
  6  IS
  7  BEGIN
  8   dbms_output.put_line ('Constant :- ' || c_add) ;
  9  END;
 10  END;
 11  /

Package body created.

Elapsed: 00:00:00.29
SQL>desc hide
PROCEDURE MYPROC

SQL>desc HIDE
PROCEDURE MYPROC

SQL>set serverout on 
SQL>exec hide.myproc;
Constant :- 1

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.54
SQL>exec HIDE.myproc;
Constant :- 1

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.54
SQL>



its woking for me !! OR am I missing something?


Re: Hide declaration or declare it inside the body of a package [message #447178 is a reply to message #447176] Fri, 12 March 2010 03:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
its woking for me !! OR am I missing something?

So you don't need the quotes.
Imagine one day you make a typo on CREATE statement like "HiDE".
Then the name will be "HiDE" not hide, HIDE...
This is why you must not use them (unless you like trouble).

Regards
Michel

[Updated on: Fri, 12 March 2010 03:23]

Report message to a moderator

Re: Hide declaration or declare it inside the body of a package [message #447180 is a reply to message #447176] Fri, 12 March 2010 03:50 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
The question should not be "Why should I not use double quotes", but "Why should/would I use double quotes".
The default is not using them. You chose to use them. Why?
Re: Hide declaration or declare it inside the body of a package [message #447482 is a reply to message #447068] Mon, 15 March 2010 07:38 Go to previous message
akabir77
Messages: 6
Registered: May 2009
Junior Member
rahulvb
Thanks for the suggestion. I am going to try it out.

And Frank. Thanks for the advice. I will remove the double quotes. Why i used them? well I probably saw it on a example in the net and followed it...
Previous Topic: unable to recreate an object
Next Topic: Rank
Goto Forum:
  


Current Time: Wed Dec 07 18:24:35 CST 2016

Total time taken to generate the page: 0.11186 seconds