Declaring a variable to be of a type of a table's column in another schema

Hi,
Can anyone please explain why is the below procedure not working, but the same is working when written in a declare begin block:
--exception:Compilation errors for PROCEDURE BOOK_STG.TEST
Error: PLS-00201: identifier 'BOOK.POLICY_METHOD' must be declared
CREATE OR REPLACE PROCEDURE test(out_test VARCHAR2) IS
test_it book.policy_method.policy_type%TYPE;
BEGIN
SELECT policy_type INTO test_it FROM book.policy_method WHERE rownum < 2;
out_test := test_it;
dbms_output.put_line(out_test);
END;
--below block is working:
declare
test book.policy_method.policy_type%TYPE;
BEGIN
SELECT policy_type INTO test FROM book.policy_method WHERE rownum < 2;
dbms_output.put_line(test);
END;

user13491035 wrote:
Hi,
Can anyone please explain why is the below procedure not working, but the same is working when written in a declare begin block:
--exception:Compilation errors for PROCEDURE BOOK_STG.TEST
Error: PLS-00201: identifier 'BOOK.POLICY_METHOD' must be declared
CREATE OR REPLACE PROCEDURE test(out_test VARCHAR2) IS
test_it book.policy_method.policy_type%TYPE;
BEGIN
SELECT policy_type INTO test_it FROM book.policy_method WHERE rownum < 2;
out_test := test_it;
dbms_output.put_line(out_test);
END;
--below block is working:
declare
test book.policy_method.policy_type%TYPE;
BEGIN
SELECT policy_type INTO test FROM book.policy_method WHERE rownum < 2;
dbms_output.put_line(test);
END;Check how the GRANT for the object BOOK.POLICY_METHOD is given for the current user. If it is through a ROLE then you cannot use it inside a SP. To use an OBJECT inside a SP you need Grant given directly.

Similar Messages

  • In need of column type given a table and column.

    Hello,
    Currently I'm using in JDBC the following query to get the column's type (via ResultSetMetaData Java object):
    "select "+aColumnName+" from "+aTableName+" WHERE ROWNUM < 0"
    When the column is a Spatial column I'm getting the following exception:
    java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-00932: inconsistent datatypes: expected NUMBER got MDSYS.SDO_GEOMETRY
    The question that I have is:
    1. Why am I getting that exception when on other columns (Number, Varchar2, etc) I'm not getting an exception
    OR
    2. Is there a better way to query the database for a column's type when the user/pwd (most likely) has no other permissions to the database but to read/write data to the database.
    Also I have a flat file that has approximately ~150 rows of table.column values that I'm currently calling ~150 times w/ the above SQL. So hopefully w/ #2 I can get some better performance.
    Thanks,
    Jim

    2. Is there a better way to query the database for a column's typeYou can query »user_tables« or »all_tables« instead ....

  • Dynamic declaration for variable.

    Can we declare a variable dynamic with varing data type.
    My req is i have to define a variable to store output from a dynamic select statement. Now since SELECT is dynamic, its output type changes each time and for the same I need a variable defined dynamically.
    Regards,
    Arpit

    Hi Arpit Gattani,
        To store output of an dynamic Select statement you can use dynamic data objects and field symbols.
        To create a data object dynamically during a program, you need a data reference variable and the following statement:
    CREATE DATA <dref> TYPE <type>|LIKE <obj>.
    This statement creates a data object in the internal session of the current ABAP program. After the statement, the data reference in the data reference variable <dref> points to the object. The data object that you create does not have its own name. You can only address it using a data reference variable. To access the contents of the data object, you must dereference the data reference.
    You must specify the data type of the object using the TYPE or LIKE addition. In the TYPE addition, you can specify the data type dynamically as the contents of a field (this is not possible with other uses of TYPE).
    CREATE DATA <dref> TYPE (<name>).
    Here, <name> is the name of a field that contains the name of the required data type.
    <b>Example:</b>
    A specific field is read from database table X031L. Neither the field name nor the table name is known until runtime:
    Read a field from the table X031L
    PARAMETERS:
      TAB_NAME    LIKE SY-TNAME,           "Table name
      TAB_COMP    LIKE X031L-FIELDNAME,   "Field name
      ANZAHL      TYPE I DEFAULT 10.       Number of lines
    FIELD-SYMBOLS: <WA>   TYPE ANY,
                   <COMP> TYPE ANY.
      DATA: WA_REF TYPE REF TO DATA.
      CREATE DATA WA_REF TYPE (TAB_NAME). "Suitable work area
      ASSIGN WA_REF->* TO <WA>.
    SELECT * FROM (TAB_NAME) INTO <WA>
      UP TO anzahl ROWS.
      WRITE: / TAB_COMP, <COMP>.
      ENDSELECT.
    Dont Forget to give points if it helps ;>)
    Regards
    Rakesh.

  • Declare webservice variable types

    Hi,
    How can I load the object types from a web service in Powershell?
    $url = http://wserver/v1.asmx?WSDL
    $ws = New-WebServiceProxy -uri $url -Namespace myWS
    $wsObj = New-Object -TypeName "myWS.AddObjectData"
    When I now do a $wsObj.GetType() the BaseType is "System.Object" and not "AddObjectData".
    Trying to declare a variable like [myWS.StringVal]$Test ("StringVal" is valid and found in the WSDL), I get an error that the assembly is not loaded.
    How can I load this into PowerShell?
    Note: This works fine in C#.
    Thanks

    Hi,
    I would like to suggest you run below command to get all properties and methods for the created object first:
    $url = 'http://wserver/v1.asmx?WSDL'
    $ws = New-WebServiceProxy -uri $url -Namespace myWS
    $ws | gm
    And based on my understanding, myWS is only a string, so I don't think it has AddObjectData property.
    Regards,
    Yan Li
    Regards, Yan Li

  • Is there any reason (laziness aside) to declare instance variables public?

    Why would you declare one public, save for the fact that object.field is quicker to type than object.getField()? It is a pain to have to write get/set methods for private variables, but later on, if you ever need to do something with a variable when it's been accessed or modified, it's much easier to go back and edit just those methods, instead of everywhere the variable's been directly accessed. On the other hand, I see no benefit of declaring a variable public. Is there one?

    Never, Never, Never !!!That's a tad extreme.
    In most cases, you'll want get and set, and even then you need to examine whether you really want another class to have that direct control over your object's state.
    But there are cases where you can make your instance variables public. If it's a pure data container, with no behavior, and you don't expect it to ever be used in a multithreaded context or to be used as a JavaBean, then you can make the instance variables public.

  • Why should i declare a variable serialVersionUID?

    hello all,
    the following code giving warning saying that
    The serializable class newFrame does not declare a static final
    serialVersionUID field of type long.
    why should i need to declare a static final
    serialVersionUID variable? is their any resason
    public class newFrame extends JFrame{
         public ContentPaneTest() {
             super("Content pane");
             getContentpane().add(new JLabel("hello all"););
             setVisible(true);
             pack();
             setDefaultCloseOperation(EXIT_ON_CLOSE);
         public static void main(String args[]){
              new newFrame();
    }thanks
    daya

    two options:
    1) You could explicitly specify a serialVersionUID to remove the warnings.
    2) If you just want to remove those specific warnings, you could do so by changing the compiler settings of your IDE (for Eclipse, "Potential programming problems" / "Serializable class without serialVersionUID").
    serialVersionUID is used during deserialization to verify that the sender and receiver of a serialized object have compatible corresponding classes (for that object).
    If you don't care about serialization, 2) would be your choice.

  • Declare a variable in an Interface

    hi all
    can i declare a variable in a interface , something like
    public static final String dsn=" // something";
    so that i dont have to declare the same thing in all the classes that implement this interface
    regards

    You don't need the public, static, or final. All fields in interfaces are implictly public static final fields.

  • Would like to declare a variable Public/Global in an IF statement

    Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
    I have it like this
    if (!sei_second_jsp.equals("1"))
    public int[] mecitem;
    public String[] sei_mfg_prod_cat;
    public String[] sei_part_number;
    public String[] sei_descrip;
    public String[] sei_price;
    public int[] sei_onhand;
    public int[] sei_demand;
    mecitem = new int[20000];
    sei_mfg_prod_cat = new String[20000];
    sei_part_number = new String[20000];
    sei_descrip = new String[20000];
    sei_price = new String[20000];
    sei_onhand = new int[20000];
    sei_demand = new int[20000];
    for (int i=0; i<=19999; i++)
    mecitem[i] = 0;
    sei_mfg_prod_cat[i] = " ";
    sei_part_number[i] = " ";
    sei_descrip[i] = " ";
    sei_price[i] = " ";
    sei_onhand[i] = 0;
    sei_demand[i] = 0;
    Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
    When I use the above code, I get the following error
    1809 }' expected. { 
    1811 Statement expected. public int[] mecitem;
    1827 Identifier expected. mecitem = new int[20000];
    1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
    1827 Identifier expected. mecitem = new int[20000];
    1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
    1837 Identifier expected. sei_onhand = new int[20000];
    1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
    1839 Identifier expected. sei_demand = new int[20000];
    3117 Class or interface declaration expected. }

    Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
    thnks a lot for your time.. !!!

  • Why do we declare the variables private in a bean

    Hi,
    when we create a bean in the MVC architecture why do we declare the variables private. Also when do we use the access specifier private.
    Regards,
    Prashant

    pksingh79 wrote:
    Hi ^^,
    thanks for replying.I had a discussion with one of my trainers and he was of the opinion that the variables should generally be declared private. In this way we prevent classes from accessing and setting illegal values to those variables.
    Say for instance we have the class person as follows:
    public class Person
    int age;
    setAge(int age)
    if (age < 0)
    return null
    Person p = new Person() ;
    p.age = -2;
    //this would be perfectly legal
    //where as if we declare the variable as private as follows:
    public class Person
    private int age;
    setAge(int age)
    if (age < 0)
    return null
    Person p = new Person() ;
    // P.age = -2;   this would be illegal as age is private and would have to be accessed by the method defined above.
    p.setAge(-2);
    //the cbove line would retun null values.
    public class Person {
        private int age;
        public void setAge(int age) {
            if (age < 0) {
                throw new IllegalArgumentException("...");
            this.age = age;
    }

  • How to declare local variables in PL/SQL stored programs

    Where do I declare local variables in a PL/SQL stored program?
    I get compiler errors with either of the options below:
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    TOTAL_BALANCE NUMBER;
    BEGIN
    RETURN TOTAL_BALANCE;
    END;
    FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
    BEGIN
    TOTAL_BALANCE NUMBER;
    RETURN TOTAL_BALANCE;
    END;

    Your local variable cannot have the same name as the formal out parameter. This is a procedure example, but since functions should not have out parameters anyway ...
    session2> CREATE PROCEDURE p (p_id IN NUMBER, p_did OUT NUMBER) AS
      2     p_did NUMBER;
      3  BEGIN
      4     p_did := p_id * 2;
      5  END;
      6  /
    Warning: Procedure created with compilation errors.
    session2> show error
    Errors for PROCEDURE P:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    1/1      PLS-00410: duplicate fields in RECORD,TABLE or argument list are
             not permittedThe proper way to create a function would be something like:
    CREATE FUNCTION f (p_id IN NUMBER) RETURN NUMBER AS
       l_did NUMBER;
    BEGIN
      l_did := p_id * 2;
      RETURN l_did;
    END;You should really assign a value to the variable before you return it.
    John

  • How to declare a variable in form

    how to declare a variable in form?

    Hi,
       do you want to create variable in script or smartform?
    In scripts to define a variable use the following declaration statement.
    DEFINE &<VARIABLE_NAME>&
    place this statement as command. we can assign initial value for this by adding VALUE ' ' to above statement.
    If your requirement is for smartforms go to global declaration, create a variable there that will be applicable only for smartform.
    Hope this will help you,
    Regards,
    Aswini.

  • TYPE and SIZE, 2 more columns to the variable in the Command behavior?

    DW 8.02 added 2 more columns to the variable in the Command
    behavior, TYPE and SIZE. What do you put in here?
    What is the difference for Access text, Date/Time, number and
    Memo columns.
    The Dreamweaver DOCS don't cover this update and you can't OK
    the COMMAND without these two columns

    This will be of some help:
    http://www.w3schools.com/ado/ado_datatypes.asp
    You should be able to gather the column size from the
    database's table
    definition. Typically, columns that hold text are one byte
    per character
    (two for Unicode), whereas integers are 4 bytes. Other
    numeric types and
    date types vary among database systems.
    "lovewebdev" <[email protected]> wrote in
    message
    news:ec0it5$h20$[email protected]..
    > DW 8.02 added 2 more columns to the variable in the
    Command behavior, TYPE
    > and
    > SIZE. What do you put in here?
    > What is the difference for Access text, Date/Time,
    number and Memo
    > columns.
    >
    > The Dreamweaver DOCS don't cover this update and you
    can't OK the COMMAND
    > without these two columns
    >

  • Declaring a variable in a function: either the function or the eventListener I'm using doesn't work

    Can anyone help me with this?
    I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc.
    Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. Can someone help?
    The error message I get is:
    1120: Access of undefined property theAnswer.
    I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
    var theAnswer;
    vid.addEventListener(MetadataEvent.CUE_POINT, cueAnswers);
    function cueAnswers(e:MetadataEvent):void{
    var cuePointNames = e.info.name;
    if (cuePointNames =="start")
    theAnswer = "C";
    else if (cuePointNames =="q2")
    theAnswer = "A";
    else if (cuePointNames =="q3")
    theAnswer = "C";
    else if (cuePointNames =="q4")
    theAnswer = "A";
    else if (cuePointNames =="q5")
    theAnswer = "D";
    else if (cuePointNames =="q6")
    theAnswer = "C";
    else if (cuePointNames =="q7")
    theAnswer = "A";
    else if (cuePointNames =="q8")
    theAnswer = "D";
    else if (cuePointNames =="q9")
    theAnswer ="B"
    else if (cuePointNames =="q10")
    theAnswer ="B";
    The function is called by this later:
    function nkAinfo(e:MouseEvent):void {
    if (theAnswer=="C")
    trace("You clicked right");
    else
    trace("You clicked wrong");
    What's going on? Is the function not being called or are my variable declarations wrong?

    Probably not the answer to your question, but it could help anyways....
    First there is another command that, to me at least, is much easier to read that a bunch of nested if/if elses. And that is the switch.
    switch (e.info.name){
    case "start":
    theAnswer="C";
    break;
    case "q2":
    theAnswer="A"
    break;
    //and so on
    To me that is easier to maintain and read. But I don't think that is really what you need here. So just file that one away for the future.
    In this case, what I think you need is an array.
    var currentAnswer:String;
    var correctAnswers:Array=new Array();
    correctAnswers["start"]="C"
    correctAnswers["q2"]="A"
    // and so on.
    Then your cuepoint handler function becomes something like this:
    function cueAnswers(e:MetadataEvent):void{
         currentAnswer=correctAnswers[e.info.name];
    And I'm a little confused by your mouse click handler. It would seem to suggest that the answer is always "C"? But I"m guessing that it is supposed to compare what the user clicked on to what the cuePoint has told it is the correct answer? Well if that is the case then it would probably look something like:
    function nkAinfo(e:MouseEvent):void {
    if(e.currentTarget.clickedProperty==currentAnswer){
         trace("Correct");
    } else {
         trace("Incorrect");
    With the way you are currently doing this I'm guessing that you have a bunch of repeated functions for each time there is a mouse click and that your code is a lot more complicated that it needs to be. And that somewhere hiding in all those lines there is an error that would be simple to fix if you could see it.
    What the error is telling you is that somewhere your are trying to assign or retrieve theAnswer and it hasn't been defined yet.

  • Syntax for declaring global variable in report

    Hello all,
    Kindly let me know syntax for declaring global variable in report?
    Thnks,
    SUnny

    Hi Sunny,
    All data declaration in the main program is global.
    Only if you do some data declaration withtin the subroutines then the scope of the variable is limited to that FORM ....ENDFORM.
    As you read in the above reply for a global variable in FM you need to declare in the top include.
    This means that you want this variable to be made available to all the Function Modules in that Function Group.
    If you want to make the variabe be available only within that FM then do the declaration in the source code itself.
    hope this explaination helps,
    Taher.

  • Declare global variable and retrive?

    Hi,
    we are working in live project in webtool, we wants to create global variable,
    calling that variable in a required pages, our questions is that where to declare global variable and how to declare in which page we have to declare?   pls guide us its very urgent and send the code.
    Regards
    Kannan.D
    Edited by: kannan desikan on Jan 14, 2008 8:07 AM

    Hi Kannan,
    I would suggest using a comma delimied list or putting it in the database.
    ArrayList myList = new ArrayList();
    myList.Add("one");
    myList.Add("two");
    myList.Add("three");
    string comma = "";
    // store the array in the session state
    foreach (string s in myList){
      Session["persistedArray"] += comma + s;
      comma = ",";
    To get the array back
    if (Session["persistedArray"] != null){
      ArrayList myList = Session["persistedArray"].ToString().Split(new char[1] {','});
    If your array is storing objects, you should use the database.

Maybe you are looking for

  • 2.1 Stability?

    Hi, Because of Ike, my wife, daughter and I have had to leave our home in Houston and are now in a hotel room in Austin. I have a 3g, both of them have the original iPhone. We have not upgraded from 2.0.2 to 2.1 (couldn't because of the storm). I've

  • Convert Imovie 8.0.6 to 10

    Have numerous 8mm tapes.  Imported one to iMovie 8.  Worked fine.  Upgraded to iMovie 10.  That first one converted okay.  Was going to use 10 for future imports but it does not read most of my tapes.  So I use 8.  Is there a way to convert these 8 i

  • Net Due date in F-32 t-code

    Hi Experts, I have a small query, as I am beginner, I am posteing this here, In F-32 initial screen, under 'Additional Selections' , i need to have one more radio button 'NetDue date'. Can it be done by SPRO? if yes.. pls suggest the path... Thanks i

  • My Computer goes to sleep on its own, then just gets mad and shuts down?

    I have a problem i hope some of you wonderful people can help me with. I have no idea why but when i am in the middle of something, doesn't matter what i am doing. my computer fan speeds up, then my computer goes into what appears to be sleep mode (

  • Where is Safari 4.0.4 located in my system?

    I just did a software update and installed the new safari 4.0.4 for tiger. I restarted the mac as instructed after installation completed. Now i can't find any newly installed safari 4.0.4 Could someone provide any info ? Thanks twzz