Stack type from oracle website

I am trying to create the stack type from oracle's site:
http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96624/10_objs.htm#4139
However, I don't know how to use it exactly as it yields NULL SELF error every time I try to initialize it! How do I pop and push?
CREATE TYPE Stack AS OBJECT (
max_size INTEGER,
top INTEGER,
position IntArray,
MEMBER PROCEDURE initialize,
MEMBER FUNCTION full RETURN BOOLEAN,
MEMBER FUNCTION empty RETURN BOOLEAN,
MEMBER PROCEDURE push (n IN INTEGER),
MEMBER PROCEDURE pop (n OUT INTEGER)
Finally, you write the object type body:
CREATE TYPE BODY Stack AS
MEMBER PROCEDURE initialize IS
BEGIN
top := 0;
/* Call constructor for varray and set element 1 to NULL. */
position := IntArray(NULL);
max_size := position.LIMIT; -- get varray size constraint
position.EXTEND(max_size - 1, 1); -- copy element 1 into 2..25
END initialize;
MEMBER FUNCTION full RETURN BOOLEAN IS
BEGIN
RETURN (top = max_size); -- return TRUE if stack is full
END full;
MEMBER FUNCTION empty RETURN BOOLEAN IS
BEGIN
RETURN (top = 0); -- return TRUE if stack is empty
END empty;
MEMBER PROCEDURE push (n IN INTEGER) IS
BEGIN
IF NOT full THEN
top := top + 1; -- push integer onto stack
position(top) := n;
ELSE -- stack is full
RAISE_APPLICATION_ERROR(-20101, 'stack overflow');
END IF;
END push;
MEMBER PROCEDURE pop (n OUT INTEGER) IS
BEGIN
IF NOT empty THEN
n := position(top);
top := top - 1; -- pop integer off stack
ELSE -- stack is empty
RAISE_APPLICATION_ERROR(-20102, 'stack underflow');
END IF;
END pop;
END;

I would write it using a collection rather than a varray myself:
SQL> create type IntArray AS table of integer
  2  /
Type created.
SQL>
SQL> CREATE TYPE Stack AS OBJECT (
  2    max_size INTEGER,
  3    top INTEGER,
  4    position IntArray,
  5    MEMBER PROCEDURE initialize(p_max_size IN INTEGER),
  6    MEMBER FUNCTION full RETURN BOOLEAN,
  7    MEMBER FUNCTION empty RETURN BOOLEAN,
  8    MEMBER PROCEDURE push (n IN INTEGER),
  9    MEMBER PROCEDURE pop (n OUT INTEGER)
10    );
11  /
Type created.
SQL>
SQL> CREATE TYPE BODY Stack AS
  2    MEMBER PROCEDURE initialize(p_max_size IN INTEGER) IS
  3    BEGIN
  4      max_size := p_max_size;
  5      top := 0;
  6      position := IntArray(NULL);
  7      position.EXTEND(max_size - 1, 1);
  8    END initialize;
  9    --
10    MEMBER FUNCTION full RETURN BOOLEAN IS
11    BEGIN
12      RETURN (top = max_size); -- return TRUE if stack is full
13    END full;
14    --
15    MEMBER FUNCTION empty RETURN BOOLEAN IS
16    BEGIN
17      RETURN (top = 0); -- return TRUE if stack is empty
18    END empty;
19    --
20    MEMBER PROCEDURE push (n IN INTEGER) IS
21    BEGIN
22      IF NOT full THEN
23        top := top + 1; -- push integer onto stack
24        position(top) := n;
25      ELSE -- stack is full
26        RAISE_APPLICATION_ERROR(-20101, 'stack overflow');
27      END IF;
28    END push;
29    --
30    MEMBER PROCEDURE pop (n OUT INTEGER) IS
31    BEGIN
32      IF NOT empty THEN
33        n := position(top);
34        top := top - 1; -- pop integer off stack
35      ELSE -- stack is empty
36        RAISE_APPLICATION_ERROR(-20102, 'stack underflow');
37      END IF;
38    END pop;
39  END;
40  /
Type body created.
SQL>
SQL> DECLARE
  2    v_stack Stack := Stack(null,null,null);
  3    v_n INTEGER;
  4  BEGIN
  5    v_stack.initialize(10);
  6    FOR i in 1..20
  7    LOOP
  8      IF NOT v_stack.full THEN
  9        v_stack.push(i);
10        dbms_output.put_line('Pushed: '||i);
11      ELSE
12        dbms_output.put_line('Stack Full: '||i);
13      END IF;
14    END LOOP;
15    FOR i in 1..20
16    LOOP
17      v_stack.pop(v_n);
18      dbms_output.put_line('Popped: '||i||' : '||v_n);
19    END LOOP;
20  END;
21  /
Pushed: 1
Pushed: 2
Pushed: 3
Pushed: 4
Pushed: 5
Pushed: 6
Pushed: 7
Pushed: 8
Pushed: 9
Pushed: 10
Stack Full: 11
Stack Full: 12
Stack Full: 13
Stack Full: 14
Stack Full: 15
Stack Full: 16
Stack Full: 17
Stack Full: 18
Stack Full: 19
Stack Full: 20
Popped: 1 : 10
Popped: 2 : 9
Popped: 3 : 8
Popped: 4 : 7
Popped: 5 : 6
Popped: 6 : 5
Popped: 7 : 4
Popped: 8 : 3
Popped: 9 : 2
Popped: 10 : 1
DECLARE
ERROR at line 1:
ORA-20102: stack underflow
ORA-06512: at "SCOTT.STACK", line 36
ORA-06512: at line 17
SQL>When you instantiate the object, you have to supply values for the object attributes, but those values can simply be null. This is the nature of object instantiation because, without values, it wouldn't be an object, it would just be a null declaration of the object class. You don't have to declare variables outside of the object and pass those in, as you did for your varray.

Similar Messages

  • Download from oracle website..

    hi,
    download from oracle website  is  trail one??
    as i want to download oracle 10g database for self study..
    thnxxxx

    If you mean trial version, then yes, all the commercial Licenses (PE, SE1, SE, EE) you download and install need a license if you start developing applications for commercial purpose. If you only want to try certain features, than you can install said licences for testing purposes on your system. Aside from that you can get the XE (eXpress Edition) which you can use both for testing and production use, if you can cope with its restriction in size (disk 4G, memory 1G) and processing (1 CPU, 1 Server) and its lack of support (patches, etc.) from Oracle Corp.
    Please bear in mind that I'm not associated in any way with Oracle Corp. You may want to check on license restrictions with Oracle Corp. or one its partners to be on the safe side.
    C.
    Edited by: cd_2 on Feb 11, 2010 3:36 PM

  • Convert Data type from Oracle Data time string to SQL Date time data type

    I have a time stamp column pulled from oracle into a SQL server db table varchar datatype column.
    Now i want to change that column to date time.
    Following is the data present in the table:
    01-APR-11 02.15.00.026000 AM -08:00
    01-APR-11 04.15.00.399000 AM -08:00
    01-APR-11 06.15.00.039000 AM -08:00
    I want to convert this data into sql server datetime data type.
    Please advice.
    Thanks,
    Sam.
    I am unable to find the solution in other sites which is why I have posted it in Oracle forum for seeking solution.
    Thanks in Advance.
    Sam.

    Sam,
    How are you actually loading the data into SQL*Server - are you using something like an Oracle gateway, BCP or another Microsoft utility of some sort ?
    If you are using an Oracle problem then we may be able to help but if using a Microsoft utility then you should really follow up with Microsoft to know what format the data should be in to use a Microsoft utility.
    Regards,
    Mike

  • Data Types from Oracle Sample Schema

    Hi,
    I was trying to push some data from an Oracle Sample schema (Schema: OE Table: Customers) to a target schema. The interface was erroring out because of undefined data types in the model.
    I chkd the model, only to find that some of the data types were undefined.
    I DESCribed the table in the using SQL Client, The data types returned were
    CUST_ADDRESS_TYP
    PHONE_LIST_TYP
    MDSYS.SDO_GEOMETRY
    I DESCribed the datatypes, They seem to be flexfields of some kind,
    Please advise on how to define these data types into ODI:
    Heres the DESC output
    SQL> desc customers;
    Name Null? Type
    CUSTOMER_ID NOT NULL NUMBER(6)
    CUST_FIRST_NAME NOT NULL VARCHAR2(20)
    CUST_LAST_NAME NOT NULL VARCHAR2(20)
    CUST_ADDRESS CUST_ADDRESS_TYP
    PHONE_NUMBERS PHONE_LIST_TYP
    NLS_LANGUAGE VARCHAR2(3)
    NLS_TERRITORY VARCHAR2(30)
    CREDIT_LIMIT NUMBER(9,2)
    CUST_EMAIL VARCHAR2(30)
    ACCOUNT_MGR_ID NUMBER(6)
    CUST_GEO_LOCATION MDSYS.SDO_GEOMETRY
    DATE_OF_BIRTH DATE
    MARITAL_STATUS VARCHAR2(20)
    GENDER VARCHAR2(1)
    INCOME_LEVEL VARCHAR2(20)
    SQL> desc CUST_ADDRESS_TYP;
    Name Null? Type
    STREET_ADDRESS VARCHAR2(40)
    POSTAL_CODE VARCHAR2(10)
    CITY VARCHAR2(30)
    STATE_PROVINCE VARCHAR2(10)
    COUNTRY_ID CHAR(2)
    SQL> desc phone_list_typ;
    phone_list_typ VARRAY(5) OF VARCHAR2(25)

    To create MDSYS.SDO_GEOMETRY datatype, goes to Topology module, Oracle Techonology, Datatypes, and add a new datatype GEOMETRY. (try to fill all information fields with GEOMETRY and see what happens maybe you have to ajust this after but it is a start point).
    add information in from and to tabs according your source and target desired tech.
    Reverse againg your model, or change the datatype in the model datastore. Re-run your interface

  • Stacked canvas from Oracle designer 10g

    Hi,
    I want to create a stacked canvas using designer 10g, how can I do it?
    thanks.
    Hichem

    Since you ask this question inside the Oracle Designer Headstart forum, you have Oracle Headstart. Inside Oracle Headstart there is a demo application you can have a look inside the demo application. For instance module hsd0016f will show you a stacked tab canvas inside a tab canvas.

  • How to read char() for bit data DB2's type in Oracle?

    Hello,
    I am developing an application (from JDeveloper) to operate with two data base. In one hand threre is Oracle and in the other one DB2 (AS400).
    I am trying to read a DB2'sfield with the "char() for bit data" type from Oracle, but I can't read it.
    I have trying:
    rset.getObject(1) -->[B@1a786c3
    rset.getBinaryStream(1) --> java.io.ByteArrayInputStream@1a786c3
    rset.getAsciiStream(1) --> java.io.ByteArrayInputStream@2bb514
    rset.getCharacterStream(1) -->java.io.StringReader@1a786c3
    Do you have any solution to see the value of this type of field?
    Thank you and regards

    I have to synchronize unidirectionally from the Oracle database to DB2. And I'd like to save the information of the record of DB2 prior to the update operation.
    And here is where the problem arises for me, because when I try to read from Java with the connection established on DB2 is unable to interpret the information. While there are no problems from Oracle to consume the information, it happens that DB2 field types are not common with Oracle, such as char () for bit data. From what I could find the equivalent in Oracle would be raw (), but since Java is possible to read this type of information... And this is my doubt, it is necessary to do any type of cast or to do a special view to retrieve this information?

  • Runnig forms in oracle 10g after  migrating them from oracle 6i

    Guyz ....i have developed forms in oracle 6i and when i presented them to the my manager he says that he wants them to be web based.....arghhhh.!!!!!! shud have told me at the beginning itself....anyways i downloaded the forms 10g from oracle website and migrates my forms from 6i to 10g ....
    1.The forms are getting compiled and i can run them on my laptop.. i wanna noe whats the procedure to run them on other system .....the port number is 8889
    I mean running them on a web on some other LP or system.???
    2.And my 2nd problem is that ...The records are not being saved in 10g as in 6i. I created the forms in 6i using the data block wizard and set the block accordingly as told by u people in this forum

    Look at the existing formsweb.cfg configuration file located in your <DEVSUITE_HOME>/forms/server folder. It allows you to create different sections to start your Forms applications.
    For instance, if you create a application_1 section, give this name in your URL.
    Francois

  • My iTunes won't update, it starts to install then just says it can't. I decided to try uninstall it but it won't even uninstall anymore, there is some type of ERROR going on. I tried to just install iTunes from the website and that won't even work.

    My iTunes won't update, it starts to install then just says it can't. I decided to try uninstall it but it won't even uninstall anymore, there is some type of ERROR going on. I tried to just install iTunes from the website and that won't even work. I'm using a Windows Vista.

    Hi there,
    I've got a couple of articles that may help you out. This first one goes over how to properly remove and reinstall iTunes.
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    This next one goes over some of the troubleshooting steps if you are having issues reinstalling iTunes.
    Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Hope that helps,
    Griff W.

  • Import IMAGE type from SQL Server to BLOB in Oracle

    Hello,
    Is there a way to import a IMAGE type from SQL Server to BLOB type in Oracle from one table to another through a database link?
    I'm waiting for an answer as soon as possible.
    Best regards,
    Florin
    Edited by: Florin Manole on Sep 10, 2008 11:53 AM

    Have you already configured a Heterogeneous Services and Generic Connectivity to create a database link from Oracle to SQL Server? I haven't tried copying IMAGE data from SQL Server via Heterogeous Services myself, but from the [data type map|http://download.oracle.com/docs/cd/B19306_01/server.102/b14232/apb.htm#sthref509] in the documentation, I would expect that it would work so long as the SQL Server ODBC driver maps the IMAGE data type to SQL_LONGVARBINARY
    Justin

  • Return type Boolean From Oracle Function

    1. How do I get a return type of Boolean from Oracle function in Java?
    2. I have a function fx overloaded in Oracle (8 variances) and I have trouble getting the right one in Java. Is 8 too high a figure or Java does not support calling overloaded functions or what?
    Thanks for any help.

    I am facing a similar situation, where I have defined an overloaded function in one package (2 variants) which both return a type BOOLAN value.
    I am having trouble to setting up an CallableStatemnt to call one of this functions from Java. Whenever I set the parameter with a BIT or NUMBER data type, I get an exception with java.lang.boolean during my
    callablestatement.setobject( indez, parameter, OracleTypes.BIT );
    or
    callablestatement.setobject( indez, parameter, OracleTypes.NUMBER );
    I have no problem calling the function from SQLPlus, but doing so from Java raises the exception. I have found no exact match in OracleTypes or java.sql.Types for a BOOLEAN data type.
    In your response do you mean to modify the Function to return a NUMBER instead of a BOOLEAN, or do you mean to set the parameter as Types.NUMBER in the calling java code?
    Thanks,
    Fedro

  • How can I make Terminal run Java 7 downloaded from the Oracle Website?

    I've downloaded Java 7 from the Oracle website, and I want the Terminal application to run that Java 7 download. I try to run Java programs that require Java 7, but it runs with the Apple Internal Java 6 release. How can I make it so my MacBook Pro runs the download of Java that I downloaded? I know this sounds stupid, but am I routing my machine to run the internal Java 6 version? I have seen many videos in which people with the same software version as me run Java like this with no problem. Could you please let me know why this is happening and how I can fix it? I really want to be able to use the Java 7, particularly because I'm always getting this "Unsupported Major Minor Version 51.0" from many applications that are Terminal based.
    Thanks!

    I think I've answered your question. The Oracle JRE is a web plugin. The JDK is a development kit for applications with embedded Java. Neither one replaces the Apple-distributed Java frameworks for running standalone applications without embedded Java. Any other questions you have should be answered by the Oracle documentation.

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • My bookmarks used to appear in dropdown menu from the address bar on my iMac G5. I switched to Mac Notebook & from Leopard to Lion. Now my bookmarks are not accessible from the address bar anymore (the line where you type in the website address)

    '''My bookmarks used to appear in dropdown menu from the address bar on my iMac G5. I switched to Mac Notebook & from Leopard to Lion. Now my bookmarks are not accessible from the address bar anymore (the line where you type in the website address)'''

    There appears to be a problem with Firefox 20 with UNC paths when using roaming profiles on a server.
    *[[/questions/955140]] why is the 20.0 address bar unresponsive?
    This is currently investigated and tracked via this bug report.
    *[https://bugzilla.mozilla.org/show_bug.cgi?id=857672 bug 857672] - Address Bar not working (roaming profiles;UNC path support OS.File)
    <i>(please do not comment in bug reports: [https://bugzilla.mozilla.org/page.cgi?id=etiquette.html])</i>

  • PL/SQL Object Type - Java oracle.jbo.domain

    PL/SQL Object Type <-> Java oracle.jbo.domain
    can anybody help me, getting my domains to work?
    Following scenario:
    in pl/sql we have an object type called MULTI_LANGUAGE. This type is used for storing multilingual texts as nested table in one(!) column.
    So the object MULTI_LANGUAGE contains a member variable LANGUAGE_COLLECTION of type LANGUAGE_TABLE, which itself is a nested table of objects
    of the type LANGUAGE_FIELD (this again is only a language id and the corresponding content)
    Also the methods setContent(langID, langContent) and getContent(langId) are defined on Object MULTI_LANGUAGE.
    For example: Table having primary key, 2 other columns and one column of object type MULTI_LANGAGE (=nested table of objects)
    |ID|Column1|Column2|  multilingual Column  |
    |--|---------------------------------------|
    |  |       |       |  -------------------  |
    |  |       |       | | 1 | hello         | |
    |  |       |       |  -------------------  |
    |1 | foo   | bar   | | 2 | hallo         | |   <- Row Nr 1
    |  |       |       |  -------------------  |
    |  |       |       | | 3 | ola           | |
    |  |       |       |  -------------------  |
    |--|-------|-------|-----------------------|
    |  |       |       |  -------------------  |
    |  |       |       | | 1 | world         | |
    |  |       |       |  -------------------  |
    |2 | abc   | def   | | 2 | welt          | |   <- Row Nr 2
    |  |       |       |  -------------------  |
    |  |       |       | | 3 | ???  ;-)      | |
    |  |       |       |  -------------------  |
    |--|-------|-------|-----------------------|Now i've tried to modell this structure as an oracle.jbo.domain.
    class MultiLanguage extends Struct having this StructureDef:
    attrs[(0)] = new DomainAttributeDef("LanguageColl", "LANGUAGE_COLL", 0, oracle.jbo.domain.Array.class, 2003, "ARRAY", -127, 0, false, "campusonlinepkg.common.LanguageField");
    and
    class LanguageField extends Struct having this StructureDef:
    attrs[(0)] = new DomainAttributeDef("Id", "ID", 0, oracle.jbo.domain.Number.class, 2, "NUMERIC", -127, 0, false);
    attrs[(1)] = new DomainAttributeDef("Content", "CONTENT", 1, java.lang.String.class, 12, "VARCHAR", -127, 4000, false);
    Is there anything wrong with this StructureDef?
    When running the BC-Browser with -Djbo.debugoutput=console -Djbo.jdbc.driver.verbose=true parameters I get suspect warnings when browsing the records
    [196] Executing FAULT-IN...SELECT NR, NAME FROM B_THESAURI BThesauri WHERE NR=:1
    [197] SQLException: SQLState(null) vendor code(17074)
    [198] java.sql.SQLException: Ungültiges Namensmuster: XMLTEST.null
    ...snip: detail of stack...
    [240] SQLException: SQLState(null) vendor code(17060)
    [241] java.sql.SQLException: Deskriptor konnte nicht erstellt werden: Unable to resolve type "null"
    ...snip: detail of stack...
    [280] Warning:No element type set on this array. Assuming java.lang.Object.
    (XMLTEST is the name of the schema)
    Seems as if the framework can't read the TypeDescriptor or does not know which descriptor to read (XMLTEST.null??)
    Do I have to implement my own JboTypeMap?
    Please help, I'm stuck.
    Thanks in advance, Christian

    Thanks for your suggestion, but it seems to me as if there is one level missing.
    in pl/sql I have following structure:
    Struct MULTI_LANGUAGE (Object type) - outermost
      Array LANGUAGE_TABLE (nested table type)
        Struct LANGUAGE_FIELD (Object type simple) - innermostthe reason why i had to wrap another struct around the array was because it is not possible to define methods on a nested table. this is only possible on objects.
    on the outermost object type (which holds the array of language fields) I needed to define following 2 methods for direct access:
    getContent (langId in number) returns varchar2
    setContent (langId in number, langContent in varchar2)
    I would like to rebuild the same structure in java, because newly written java code should live in perfect harmony with legacy pl/sql code ;-)
    Both applications (Java and pl/sql) have to access the same data as long as migration to java goes on.
    Is this nested structure too much for a Domain?
    Any other suggestions?
    Thanks again, Christian

  • Problem after upgradation from Oracle 8.1.7 to Oracle 9i

    Hello ,
    I currently installed Oracle 9i, and i m using Mapx 4.5,
    and in the executable I am adding serverlayer
    (a layer formed by querying the geoloc column from oracle
    table), which was working fine with Oracle 8.1.7, but after
    installation of Oracle 9i , i encounter the following error
    while adding a serverlayer
    ORA-13373 Element of type Extent is not supported for Geodetic
    data
    Cause: Element type extent for a polygon geometry is not
    supported for
    geodetic data.
    Action: Convert the extent type polygon to a regular 5 point
    polygon
    and set
    etype accordingly.
    ORA-06512 at string line string
    Cause: Backtrace message as the stack is unwound by unhandled
    exceptions.
    Action: Fix the problem causing the exception or write an
    exception
    handler
    for this condition. Or you may need to contact your application
    administrator or database administrator
    Can anybody tell me what's going wrong ?
    As I urgently got to fix it.
    Thanks in advance
    Binoy.

    Hi,
    Oracle9i has a geodetic data model. Your data has a geodetic
    srid, which means that the data will need to conform to the rules
    associated with geodetic data. These rules include:
    No optimized rectangles are supported (my guess is the app is
    using an optimized rectangle as a query window, but the data
    could be the issue also).
    No arcs or circle types are supported.
    A single line segment cannot be equal to or greater than 1/2 the
    great circle distance.
    A polygon cannot have an area equal to or greater than 1/2 the
    surface area of the earth.
    You should try to find what version of Mapx supports Oracle9i.
    Regards,
    dan

Maybe you are looking for