the variables should be declared within spec PKG too?

create or replace package test_pkg
as 

procedure test_proc (id in number, para2 in number default null );

end;
/


create or replace package body test_pkg
as 

procedure test_proc (id in number, para2 in number default null)
as 
 var1  varchar2();
 var2  varchar2();
 begin
   insert into tgt_tbl 
   select * from tabl1 where tbl1.col1 = id;
   
  
 end 
 



my question is 

- Do the variables needs to be declared in spec too ?? or is it not necessary to declare the variables in pkg spec, only parameters is fine  ???

i,e var1 and var2 

Thank you!!!
Published by: user642297 on April 12, 2010 20:32

Hello

user642297 wrote:

create or replace package test_pkg
as 

procedure test_proc (id in number, para2 in number default null );

end;
/

create or replace package body test_pkg
as 

procedure test_proc (id in number, para2 in number default null)
as
var1  varchar2();
var2  varchar2();
begin
insert into tgt_tbl
select * from tabl1 where tbl1.col1 = id;

end 

my question is 

- Do the variables needs to be declared in spec too ?? or is it not necessary to declare the variables in pkg spec, 

It is not necessary to declare variables in the package specification. In fact, if you declare the variables var1 and var2 in package specifications, they will be different variables var1 and var2 in test_proc.

Variables used only within a procedure must be declared in the procedure, like var1 and var2 in your example.
The variables declared in the package body will be global to all, but not visible outside the package.
Variables declared in the package specification will be visiible outside the package.

only parameters is fine  ???

i,e var1 and var2 

Sorry, I don't understand the last part of the question.

Moreover, few matter where you declare a VARCHAR2 variable (not an argument), you must specify the maximum length.
For example

 var1  varchar2(100);

Tags: Database

Similar Questions

  • Error (17.14): samhi.oracle.apps.po.sample.server.SampleEOImpl of the class should be declared abstract. It defines no method setLastUpdateLogin (oracle.jbo.domain.Number) of the oracle.apps.fnd.framework.server.OAEntityImpl class

    Error (17.14): samhi.oracle.apps.po.sample.server.SampleEOImpl of the class should be declared abstract. It defines no method setLastUpdateLogin (oracle.jbo.domain.Number) of the oracle.apps.fnd.framework.server.OAEntityImpl class can help on this please

    Check once WHO columns are present or not table

    Last updated

    Last updated by

    Last updated connection

    Date of creation

    Created by

    These fields are required for the creation of EO.

    SANGU-

  • [ORACLE 9] OPEN for the variable binding USING declaration

    Hello

    I have a loop that retrieves only 1 sheet instead of 7:
    DECLARE
    
     lv_into varchar2(40);
     lv_qry  varchar2(400);
     
     type curtest_ref is ref cursor;
     
     curtest          curtest_ref;
     lv_compteur number(4) := 1;
     
     lv_client_loc   varchar2(100);
     BEGIN
     dbms_output.put_line( 'Début' );
     lv_qry := 'select client_loc from tmp_jbm where client_id = :A ';
     
     open curtest for lv_qry using lv_compteur;                 
     loop
                    fetch curtest into lv_client_loc ;
                    exit when curtest%notfound;
                    dbms_output.put_line( 'ligne: '       || to_char( lv_compteur )
                                       || ' Client Loc: ' || lv_client_loc );
                    lv_compteur := lv_compteur + 1;
                    exit when lv_compteur > 6;
         end loop;
    EXCEPTION
        when others then
                 dbms_output.put_line( 'Erreur exception: ' || sqlerrm );
    END; 
    [/END CODE]
    
    It looks like the cursor only fetches 1 record and then stops.
    
    Many thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Bind variables are evaluated when the cursor is opened. Not when extract you the data.
    I don't know why you use dynamic sql, here, you do not need.
    In any case, your code is incorrect.
    Assuming that the client_id is unique, Yes, your fetch fetch one line. When you loop the second time, retrieving a new record for the same statement, then you hit no_data_found.

    ---------
    Sybrand Bakker
    Senior Oracle DBA

  • Declare the Variable step in a package

    Hello

    Is it obligatory to declare a variable in a package, even when we are refreshing or set the value of this variable in the package? What are the problems that occur in the case where a variable is not declared in the package?

    Please note that I understand that the variable must be romance in the package in case it is not be refreshed or set or incremented but is used by any step in the package.

    Thank you and best regards,

    PV

    Hi PV.

    You must declare a variable, unless it is explicitly used in the package to arm, refreshing or evaluate its value (as you mentioned).

    You must declare also specifically when:

    • You want its value to be passed during execution (runtime scenarios)
    • You want to use in the name of the resource to a data store in a scenario
  • How do to set the policy, the user should not change/reset password twice within 24 hours

    Hello

    I have a requirement in which, the user should not change/reset password twice within 24 hours. Is there a way to achieve the IOM.

    Is there a property in IOM whereby we can set this property?

    I checked the password and all the properties of the system strategy, but he could find a?

    Could you please suggest, how to get there. all references are greatly appreciated.

    Thanks in advance

    If you set password history on don't allow orevious you can reference the table pwh.

    You can also create a UDF who inquire about the handler reset passwoed and check against it. IOM has many points of validation of your code to.

    -Kevin

  • SOA 12.1.3 ORABPEL-02118 - variable is not declared in the current scope

    Hello

    I'm trying to run a code example for the conversion of input XML XSD inside BPEL (SOA Suite 12.1.3). )

    1 file xsd

    <? XML version = "1.0" encoding = "windows-1252"? >

    " < xsd: Schema container = ' http://www.w3.org/2001/XMLSchema "xmlns =" " http://www.email.org "

    " targetNamespace = ' http://www.email.org "elementFormDefault ="qualified"> "

    < xsd: element name = "email" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "ovdTriggeredDate" type = "xsd: String" minOccurs = "1" / >

    < xsd: element name = "query" type = "RequestType" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: complexType name = 'RequestType' >

    < xsd: SEQUENCE >

    < xsd: element name = "requestId" type = "xsd: long" minOccurs = "1" / >

    < xsd: element name = "service" type = "xsd: String" minOccurs = "1" / >

    < xsd: element name = "action" type = "xsd: String" minOccurs = "1" / >

    < xsd: element name = "customer" type = "xsd: String" minOccurs = "1" / >

    < xsd: element name = "delivery" type = "xsd: String" minOccurs = "0" / >

    < xsd: element name = "local" type = "xsd: String" minOccurs = "0" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: Schema >

    2 BPEL code

    < variable name = "emailVar" element = "ns3:email" / > / / variable of type XSD

    < variable name = "emailDataVar" type = "xsd: String" / >

    < assign the name 'Assign2' = >

    < copy >

    < from > "& lt;" Email & gt; & lt; ovdTriggeredDate & gt; 16thFeb & lt; / ovdTriggeredDate & gt; & lt; request & gt; & lt; requestId & gt; 1111 & lt; / requestId & gt; & lt; Service & gt; OVDOngoing & lt; / service & gt; & lt; action & gt; Retry & lt; / action & gt; & lt; customer & gt; Batch & lt; / customer & gt; & lt; delivery & gt; Email & lt; / delivery & gt; & lt; local & gt; & lt; countryCode & gt; U.S. & lt; / countryCode & gt; & lt; languageCode & gt; English & lt; / languageCode & gt; & lt; / settings regional & gt; & lt; / request & gt; & lt; / e-mail & gt; "< / from >

    < to > $emailDataVar < /pour >

    < / copy >

    < copy >

    < from > ora: parseEscapedXML (ora: getContentAsString (bpws:getVariableData('$__emailDataVar__'))) < / from >

    < to > $emailVar < /pour >

    < / copy >

    < / assign >

    < / details >

    Get after exception when I run the application.

    < detail >

    XPath expression cannot run.

    An error occurs during the processing of the XPath expression; the term is ora:parseEscapedXML (ora:getContentAsString (bpws:getVariableData('$emailDataVar'))).

    The XPath expression cannot run; the reason was: ORABPEL-02118

    Variant could not be found.

    The variable '$emailDataVar' is not declared in the current scope. All variables must be declared in the scope before accessed. Component DN is "default/Project1!1.0*soa_c1383edb-7f32-4860-8d21-82d312a0e1da/BPELProcess1" and the corresponding Instance Id is 20 042

    There was an internal error. The flow was not generated correctly by the BPEL compiler.

    Contact Oracle Support Services. Please provide definition component of the "default/Project1!1.0*soa_c1383edb-7f32-4860-8d21-82d312a0e1da/BPELProcess1" trail and verification of instance id 20 042 using enterprise console manager.

    . Check the detailed origin described in the text of the exception message and verify that the XPath query is correct.

    -------------------------------------

    There is a solution, I found in the forum to add the following in bpel code. (Problem of access to the variables in BPEL - ORABPEL-02118)

    <>configurations

    < property name = "keepGlobalVariables" > true < / property >

    < / configuration >


    But when I add <>configurations in 12.1.3 BPEL, editor-in-Chief is showing 'element configurations is not supported'.


    Appreciate your quick help.

    Thank you

    Cdhar

    Hello

    The problem is "$", you don't need a dollar in this case

    bpws:getVariableData('emailDataVar')

    Please mark this message as useful/correct if it helps.

    Concerning

    Pradeep.

  • Declare the variable in the loop or abroad?

    What is the smartest, if the statement is a loop much like 100000. Is there a difference?

    * for(int i = 0; i < 100000; i++) {*}
    Dim myStr = getSomething();
    *}*

    or

    Dim myStr = "";
    * for(int i = 0; i < 100000; i++) {*}
    myStr = getSomething();
    *}*

    No, there is no performance difference (that's what you thought, weren't you).

    The basic rule by declaring variables is "the smallest scope possible. So in this case inside the loop for.

  • How can I list all the variables available within a movieClip

    I have a lot of movieclips in my folder and each movieclip has its own set of variables.

    There is no way to keep track of all the variables available within a movieclip? I mean, how do I know what variables and their values are within a clip!

    TKS,

    If your movieclip instance name mm, you can use:

  • The possibility of declaring the variable on request?

    Hello

    With the help of Oracle 9i. I'm new to the PL/SQL (coming from c#), I would like to know if it is possible to declare a variable around the where it is used. For example, in the execution of the procedure block, suppose I want to do:

    .. existing code...

    vTest whole;
    vTest: = 123;

    .. existing code (continued)...

    In doing so, the procedure could not compile. The only way I know to date is to declare the whole vTest. in the declaration block. Can you please let me know how to declare the variable in the body of the procedure?

    Thanks in advance.

    It is technically possible, but I wouldn't recommend it (I personally do not like this approach a LOT).

    ME_XE?create or replace procedure testin  2  as  3  4     vparamone   number default 123;  5  6  begin  7  8     declare  9        vparamtwo   number default 456; 10     begin 11        vparamone   := vparamtwo; 12     end; 13     dbms_output.put_line(vparamone); 14  end; 15  /
    
    Procedure created.
    
    Elapsed: 00:00:00.29ME_XE?exec testin;456
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.01ME_XE?
    
  • You should have seen the date using the variable of presentation

    Hi all

    I am facing a problem in the display of the selected date of the guest in the report using the variable of presentation. I have a guest of data (calendar prompt), where the user selects the value. I take this value in the variable RBAP of presentation and report when I try to display this value using the same presentation variable, I get my date in the following format

    "TIMESTAMP 2010-10-22 00:00:00 '.

    I'm just using ' @{RBAP}' in the formula in the column.

    I want to show my date in the format DD/MM/YYYY. How to do this?

    I have used CAST (' @{RBAP} {' as DATE} and tried to change the data to dd/mm/yyyy format, but it does not work.)

    Please suggest

    Thank you
    Ronny

    in the default section to write the SQL...

    Select the OPTION case SENSITIVE WHEN 1 = 0 THEN AnyExistedDateColumn CURRENT_DATE of OTHER END OF SubjectArea

  • Where the variables 'Form of Document' &amp; 'Form' should be used?

    Hai all,

    Could someone explain to me, what is the use of the variable 'Form of Document' & 'form '?

    And cases in which they are used?

    Even after going through help Document of the Workbench, I did not much understand...

    Everywhere, I could see only the variable "xfaForm" is used...

    Aswani.

    Thus, if a 'Document form' variable is used instead of 'xfaForm', is the rendered form in the same way?

    Yes. The only difference between the two is the content, you can put in variables. If you want to send the complete PDF, then you must use a form of Document.

    If you just want to send the data (xml), you can use xfaForm or document. I suggest you use xfaForm, because it is easier to use xPath to obtain the data item, you might need. If you use the form of documents, you may need to cast the content of the screen the Document in an xml variable before you can use xPath. So this is an additional step.

    Jasmine

  • How to access the variable in the child video clip

    I have a flash file that uses php to manipulate a database and returns a variable (data_xml) to document data in XML from the database. In this case, as well as others within the parent company. Now, I have a child movieclip that shows analyzed data, but I'm unable to access the variable from the child movieclip. The code associated with this is:

    var myXML:XML = new XML();
    var myXML = XML (event.currentTarget.root.data_xml);

    and I get the following two errors that point to the second line as the problem:

    1151: there is a conflict with definition myXML in the internal namespace.

    WARNING: 3596: duplicate variable definition.

    I unchecked automatically "declare instances of the scene" because I have seen the one proposed for the 1151: error, but I still have not the same two errors.

    Can anyone help? Thank you!

    You've declared the variable twice. Variable can be declared only once in any scope. So, your code should be:

    var myXML:XML = new XML();
    myXML = XML (event.currentTarget.root.data_xml); Note there is no before var

  • Get the value of the Variable

    Hello

    I use a simple pl/sql block to fill a variable based on a subquery, but the variable becomes correct value('thursday') but does not display the desired result ('-3' in this case "). I need to change this code to display '-3' instead of 'THURSDAY - REAL VALUE' '

    DECLARE

    V_DAY VARCHAR2 (100);

    BEGIN

    SELECT CASE WHEN DAY = 'TUESDAY' THEN '-1'.

    WHEN DAY = 'WEDNESDAY' THEN '-2'.

    WHEN DAY = 'THURSDAY' THEN '-3'.

    WHEN DAY = 'FRIDAY' AND THEN '-4'.

    WHEN DAY = 'SATURDAY' THEN '-5'.

    WHEN DAY = "SUNDAY" THEN '-6'.

    WHEN DAY = 'MONDAY' THEN '-7'.

    ANOTHER DAY |' -REAL VALUE ' END IN V_DAY

    FROM (SELECT TO_CHAR (TO_DATE (SYSDATE), 'DAY') DAY OF DOUBLE);

    DBMS_OUTPUT. PUT_LINE (V_DAY); -result should be '-3' not 'THURSDAY - REAL VALUE' '

    END;

    There is an extra SPACE being returned...

    Set serveroutput on

    > DECLARE

    V_DAY VARCHAR2 (100);

    BEGIN

    SELECT

    CASE

    WHEN DAY = "TUESDAY".

    THEN '-1'.

    WHEN DAY = "WEDNESDAY".

    THEN '-2'.

    WHEN DAY = "THURSDAY".

    THEN '-3'.

    WHEN DAY = 'FRIDAY ';

    THEN '-4'.

    WHEN DAY = "SATURDAY".

    THEN '-5'.

    WHEN DAY = "SUNDAY".

    THEN '-6'.

    WHEN DAY = "MONDAY".

    THEN '-7'.

    ANOTHER DAY

    ||' -REAL VALUE '

    END

    IN V_DAY

    Of

    (SELECT cut DAY (TO_CHAR (SYSDATE, 'DAY')) FROM DUAL)

    );

    DBMS_OUTPUT. PUT_LINE (V_DAY); -result should be '-3' not 'THURSDAY - REAL VALUE' '

    END;

    anonymous block filled

    -3

    TRN

    Sudhakar

  • How I can send the value of the variable of a film to other films

    Hello

    I have

    hand. DCR

    movA.dcr

    movB.dcr

    How can I send for review a = 500 to movA and movB and use

    I put this code in frame 1 of the main.dcr

    global one

    on enterFrame me

    a = 201

    end

    and put the cod in frame 1 of the movA.dcr

    on enterFrame me

    If a = 200 then

    switch to other

    on the other

    Halt

    end if

    end

    but these cod do not work!

    I think it must go stop and get out of movA.dcr but he continiue working.

    I want movA and movB catch one of main.dcr and so a = x (x evry we want) then movA and movB work of another release of film director.

    Post edited by: 200 x 200

    Hi 200 X 200,

    Unlike other language coding, Lingo requires global variables to be declared anywhere where they are used.

    Declare global one in the framework of movA.dcr and movB.dcr framework and that should work. I hope.

    Good luck

    Jack

  • Read through PL SQL (stored in the Variable Long) XML

    Hello

    We are 11g 2 database. We have content xml in the column/variable long.
    Can someone help me read the value of the xml attribute?


    for example.

    <? XML version = "1.0" encoding = "UTF-8" standalone = 'no '? >
    <! DOCTYPE tags SYSTEM "label.dtd" >
    < labels QUANTITY '1' = JOBNAME = "LBL213685" >
    < label FORMAT = "XEINSP_REQ_LBL.lwl" >
    < variable name = "L_DATE" > < variable / 4 January 2012 >
    < variable name = "L_TIME" > 10:45:17 < / variable >
    < variable name = "L_LPN" > K01-4713BE < / variable >
    < variable name = "L_ITEM" > XXXXWT88-002 < / variable >
    < variable name = "L_ITEMDESC" > SPRING, EXPANSION REVERSIBLE GE14 234C6745P001 REV.01 < / variable >
    < variable name = "L_QTY" > 1 < / variable >
    < variable name = "L_POREV" > < / variable >
    < variable name = "L_PONUM" > 837037254 < / variable >
    < variable name = "L_ITEMREF" > 834C6745P001 < / variable >
    < variable name = "L_PROJECT" > < / variable >
    < variable name = "L_ISIS" > < / variable >
    < variable name = "L_LABEL" > 1 < / variable >
    < variable name = "L_LINE_NO" > 1 < / variable >
    < variable name = "L_SUPPLIER" > CANCEL OIL, INC. < / variable >
    < / label >
    < / Label >


    We want to read next value of < variable name = "L_LPN" >. You must give K01-4713BE programmatically.


    Appreciate your help.

    Thank you
    Aerts

    Published by: user649769 on January 4, 2012 14:52

    Published by: user649769 on January 4, 2012 14:53

    Hello

    As you may know, the LONG data type is obsolete for some time now.
    If you can you should really consider migration on the CLOB type or store XML data in an XMLType column in this case.

    In particular, we cannot use XMLType constructor directly on a LONG.
    Here is a simple PL/SQL solution, provided that the data is not greater than 32 k:

    SQL> create table test_long (xmldoc long);
    
    Table created
    
    SQL> insert into test_long values('
      2  
      3  
      4  
     20  ');
    
    1 row inserted
    
    SQL> commit;
    
    Commit complete
    
    SQL> set serveroutput on
    SQL> DECLARE
      2
      3    v_xmldoc   varchar2(32767);
      4    v_result   varchar2(30);
      5
      6  BEGIN
      7
      8    select xmldoc into v_xmldoc from test_long;
      9
     10    /* disable DTD validation for the current session */
     11    execute immediate 'alter session set events = ''31156 trace name context forever, level 2''';
     12
     13    select xmlcast(
     14             xmlquery('/labels/label/variable[@name="L_LPN"]'
     15                      passing xmltype(v_xmldoc)
     16                      returning content)
     17             as varchar2(30)
     18           )
     19    into v_result
     20    from dual
     21    ;
     22
     23    execute immediate 'alter session set events = ''31156 trace name context off''';
     24
     25    dbms_output.put_line(v_result);
     26
     27  END;
     28  /
    
    K01-4713BE
    
    PL/SQL procedure successfully completed
     
    

    Note that I used the 31156 event to temporarily disable the DTD of the XML document validation and avoid this:

    ORA-31001: Invalid resource handle or path name "/label.dtd"
    

    If you really want to use validation, the DTD should be stored in the XML DB repository (in the root folder).

Maybe you are looking for

  • connect a samsung SGH-A886 to computer

    I'm trying to connect my Samsung SGH-A886 to my computer to download pictures from the Samsung phone. The PC studio software seems to be involved. I don't seem to be able to get the two pieces of material to talk... Any suggestions? Thanks RG

  • Im trying to print from the reinstall a new wireless router. Printer does not print.

    Brother printer. Clear spot wireless. can't understand why printer won't work/print.

  • Windows Picture and Fax Viewer

    The default program is WP & FV to open the pictures. Recently, he stopped the rotation function to rotate my photos. How can I solve this please?

  • Windows Vista is really a power hog?

    Well my laptop is running Windows XP service pack 3, but I'm looking at upgrading to a newer Windows operating system. I am interested in Vista because it's a cheaper option then 7 but many people said that it is a resource hog and has many problems

  • Problem with extraction of license keys

    A friend of mine laptop gave the just soul after he brought a new hard drive!He took the hard drive out of it, put it in a caddy in my test system, it can see the drive, but is there a way to extract the license key, considering the other discs are i