Enumeration in plsql.

hi
I want to restrict plsql to be assigned from a certain set of values without if clause here is what i am trying to do
declare
subtype t_char is varchar2(10) in ('valid', 'invalid','obsolete');
l_status t_char
begin
     l_status :='valid';
END;
how can i accomplish this
thanks

> I want to restrict plsql to be assigned from a certain set of values without if clause
Yes, it is possible. No, it is not possible.
IMO, PL/SQL is a bit of a mess under the hood. Yes you can create enumerated types in PL/SQL.
SQL> declare
2 huh Fuzzy; -- declared as: type FUZZY is (YES,NO,MAYBE);
3 begin
4 huh := maybe;
5* end;
SQL> /
PL/SQL procedure successfully completed.
However.. the no part. This cannot be done in "normal" PL/SQL code mode. The definition needs to reside the in the STANDARD package of the PL/SQL engine. Which is a terrible idea to hack to create an enumerated type.
The workaround is to create such an enumerated type as a SQL advance (aka user) data type (ADT). I have posted some sample code in [url http://forums.oracle.com/forums/thread.jspa?messageID=2352848]this thread that shows how ADTs can be used to create custom data types - the TBoolean ADT is an example of an enumerated integer type that only accepts 0 and 1.

Similar Messages

  • Error while trying to access a SSWA PLSQL function

    Hi,
    I am trying to access a report as a web page by defining the function as follows :
    Type : SSWA PLSQL FUNCTION
    HTML Call : OracleOASIS.RunReport
    Parameters : report=EMPDET
    This function is attached to the menu and when I try to access the page I get this error.
    "Error: The requested URL was not found, or cannot be served at this time.
    Incorrect usage."
    The URL that shows in the page is as follows(<server:port> I removed the server name and port) :
    http://<server:port>/dev60cgi/rwcgi60?GDEV_APPS+DESFORMAT=HTML+SERVER=GDEV_APPS+report=EMPDET+p_session_id=A9C71A70B9B1D9BD2DCC0FC3AF9BC324+p_user_id=1133+p_responsibility_id=50230+p_application_id=800+p_security_group_id=0+p_language_code=US+NLS_LANG=AMERICAN_AMERICA+NLS_DATE_FORMAT=DD-MON-RRRR+NLS_NUMERIC_CHARACTERS=.%2C+NLS_DATE_LANGUAGE=AMERICAN+NLS_SORT=BINARY+paramform=NO
    Surprisingly other functions which are defined in this manner work fine. Do I need to register my report anywhere or are there any other settings I need to do for the report to show up.
    Can someone let me know.
    Thanks

    Hi ;
    pelase check below which could be similar error like yours
    Troubleshooting of Runtime Errors of Customer Intelligence Reports [ID 284829.1]
    Regard
    Helios

  • Error while consuming PLSQL Webservice through BPEL

    HI ,
    I have created a simple PLSQL Web service called "HelloWorld" and it got successfully deployed .
    When I tried to test this webservice through BPEL Process Manager , its showing me error everytime that ( Could not create object of class 'dimple.HelloWorldWebServiceUser'; nested exception is: java.lang.ClassNotFoundException: dimple.HelloWorldWebServiceUser</summary> ) .
    Please anyone help me out with this problem .
    Thanks
    Prashant Dwivedi

    HI ,
    I have created a simple PLSQL Web service called "HelloWorld" and it got successfully deployed .
    When I tried to test this webservice through BPEL Process Manager , its showing me error everytime that ( Could not create object of class 'dimple.HelloWorldWebServiceUser'; nested exception is: java.lang.ClassNotFoundException: dimple.HelloWorldWebServiceUser</summary> ) .
    Please anyone help me out with this problem .
    Thanks
    Prashant Dwivedi

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • Generate Query in PLSQL to return Well Formed XML with Multiple records

    Hi there
    This is very urgent. I am trying to create a PLSQL query that should retrieve all records from oracle database table "tbl_Emp" in a well formed xml format. The format is given below
    *<Employees xmlns="http://App.Schemas.Employees" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">*
    *<Employee>*
    *<First_Name></First_Name>*
    *<Last_Name></Last_Name>*
    *</Employee>*
    *<Employee>*
    *<First_Name></First_Name>*
    *<Last_Name></Last_Name>*
    *</Employee>*
    *</Employees>*
    To retrieve data in above format, I have been trying to create a query for long time as below
    SELECT XMLElement("Employees",
    XMLAttributes('http://App.Schemas.Employees' AS "xmlns",
    *'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"),*
    XMLElement("Employee", XMLForest(First_Name, Last_Name)))
    AS "RESULT"
    FROM tbl_Emp;
    But it does not give me the required output. It creates <Employees> tag with each individual record which I don't need. I need <Employees> tag to be the root tag and <Employee> tag to repeat and wrap each individual record. Please help me in this as this is very urgent. Thanks.

    Hi,
    Please remember that nothing is "urgent" here, and repeating that it is will likely produce the opposite effect.
    If you need a quick answer, provide all necessary details in the first place :
    - db version
    - test case with sample data and DDL
    That being said, this one's easy, you have to aggregate using XMLAgg :
    SELECT XMLElement("Employees"
           , XMLAttributes(
               'http://App.Schemas.Employees' AS "xmlns"
             , 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
           , XMLAgg(
               XMLElement("Employee"
               , XMLForest(
                   e.first_name as "First_Name"
                 , e.last_name  as "Last_Name"
           ) AS "RESULT"
    FROM hr.employees e
    ;

  • Business Event not triggering the PLSQL procedure.. What to do?

    We need to call a plsql procedure when the GL Approval workflow has ended with approval. I thought i could do this by customizing the relevant business event.
    We are on EBS 12.1.3 with RDBMS : 11.2.0.3.0.
    I saw that the business event oracle.apps.gl.Journals.journal.approve was disabled currently. I enabled it and created a subscription for it. Subscription was a PLSQL procedure. Currently, for test purpose only thing it is doing is to insert a row into a table.
    Business Event Subscription settings:
    System: ORDEBS.SYSTEM.COM
    Triggering Event
    Source Type:Local
    Event Filter: oracle.apps.gl.Journals.journal.approve
    Execution Condition
    Phase: 100
    Status: Enabled
    Rule Data: Message
    Action Type:Custom
    On Error: Stop and Rollback
    Action
    PL/SQL Rule Function: XX_GL_APPROVE_BE_PKG.Get_Attributes
    Priority: Normal
    Documentation (Not sure what value to be given for these. I went with the below values.)
    Owner: Company Name
    Owner Tag: Custom Schema
    Using the below query i can see that the business event is getting called when the approval happens (One row added each time approval happened). But I cant see any rows in the table where it should insert a row. What could be going wrong? How can i verify that the procedure has been called?
    select * from WF_DEFERRED where corrid ='APPS:oracle.apps.gl.Journals.journal.approve'
    Procedure:
    CREATE OR REPLACE PACKAGE BODY APPS.XX_GL_APPROVE_BE_PKG
    AS
    PROCEDURE Get_Attributes
    IS
    BEGIN
    INSERT INTO xx.xx_test_table VALUES ('From BE');
    COMMIT;
    END Get_Attributes;
    END XX_GL_APPROVE_BE_PKG;

    Thanks Alejandro. Now this is working.
    Changes i made:
    1. Added the WFERROR workflow as a subscription to this event. So i could see that the function i am calling from the event did not have proper signature.
    2. Changed the function signature to have standard parameters like:
    CREATE OR REPLACE PACKAGE BODY XX_GL_APPROVE_BE_PKG
    AS
    function subscription(p_subscription_guid in raw,
    p_event in out nocopy wf_event_t) return varchar2 is
    l_result varchar2(20);
    begin
    insert into xxvtv.xxvtv_test_table values ('From BE');
    commit;
    exception
    when others then
    wf_core.context('XX_GL_APPROVE_BE_PKG','function subscription', p_event.getEventName(), p_event.getEventKey());
    wf_event.setErrorInfo(p_event, 'ERROR');
    return 'ERROR';
    end subscription;
    END XX_GL_APPROVE_BE_PKG;
    3. Changed the owner name and owner tag both to the custom schema name (XX)

  • Problems with enumerated type and DataSocket

    I am publishing an enumerated type variable using DataSocket write and I am having problems subscribing to this with other clients on the network. I can get the program to work ok if I replace the enumerated type with a straight numeric or a Text Ring for example. Is there anything special I should be looking out for when using enumerated types in this type of application.
    Thanks Kelly

    Updating to the latest version of LabVIEw (6.0.2) should correct this problem:
    http://digital.ni.com/softlib.nsf/websearch/F983BDA17B8F401B862569EC005A11C2
    Also, I would suggest updating to the latest version DataSocket:
    http://digital.ni.com/softlib.nsf/web%2Fall%20software?OpenView&Start=1&Count=500&Expand=6#6
    Chris_Mitchell
    Product Development Engineer
    Certified LabVIEW Architect

  • Null value in List Binding (enumeration mode)

    Hi,
    how can I declare a NULL value in a List binding with enumeration mode?
    A user should be able to select an empty entry in a combobox to update an attribute with a null value.
    I'm using JDev9052 and JClient.
    Any hints?
    Thanks,
    Markus

    Adding '-1' in JComboBox (addItem(new Integer(-1))) or in the control binding does not change the picture. Sorry.
    While play with different List bindings I have discovered that a Button LOV Binding works when using a "select * UNION select null from dual" view object. It does not work with a Combobox LOV binding. Why?
    Still, my problem List binding in enumeration mode (with Combobox) is unsolved. any hints or samples?
    My current combobox binding:
    <DCControl
    id="Job"
    DefClass="oracle.jbo.uicli.jui.JUComboBoxDef"
    SubType="DCComboBox"
    BindingClass="oracle.jbo.uicli.jui.JUComboBoxBinding"
    IterBinding="EmpView1Iterator"
    ApplyValidation="false"
    isDynamic="false"
    ListOperMode="0"
    StaticList="true"
    Editable="false" >
    <AttrNames>
    <Item Value="Job" />
    </AttrNames>
    <ValueList>
    <Item Value="ANALYST" />
    <Item Value="CLERK" />
    <Item Value="MANAGER" />
    <Item Value="PRESIDENT" />
    <Item Value="SALESMAN" />
    <Item Value="-1" />
    </ValueList>
    </DCControl>
    My current Button LOV binding:
    <DCControl
    id="Job2"
    DefClass="oracle.jbo.uicli.jui.JULovButtonDef"
    SubType="DCLovButton"
    BindingClass="oracle.jbo.uicli.jui.JULovButtonBinding"
    IterBinding="EmpView1Iterator"
    DTClass="oracle.adf.dt.objects.JUDTCtrlListLOV"
    ApplyValidation="false"
    isDynamic="false"
    ListOperMode="0"
    ListIter="JobListView1Iterator" >
    <AttrNames>
    <Item Value="Job" />
    </AttrNames>
    <ListAttrNames>
    <Item Value="Job" />
    </ListAttrNames>
    <ListDisplayAttrNames>
    <Item Value="Job" />
    </ListDisplayAttrNames>
    </DCControl>

  • Difference between empty plsql record and null plsql record

    Hi there,
    I am kinda getting confused with empty plsql record and null plsql record.
    How do I assign plsql record to be empty and to be null?
    create type emp_obj as object (enum number, ename varchar2);
    CREATE OR REPLACE TYPE emp_type AS TABLE OF emp_obj;
    Thanks

    First of all, do not use term PL/SQL record in this context. Record type in PL/SQL is completely different from object type. Secondly, there are 2 states of a nested table:
    1. Unintialized:
    SQL> create or replace
      2    type emp_obj_type as object(enum number, ename varchar2(10));
      3  /
    Type created.
    SQL> create or replace
      2    type emp_tbl_type as table of emp_obj_type
      3  /
    Type created.
    SQL> declare
      2      v_emp_tbl emp_tbl_type;
      3  begin
      4      v_emp_tbl.extend;
      5  end;
      6  /
    declare
    ERROR at line 1:
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 4
    SQL> 2 Empty:
    SQL> set serveroutput on
    SQL> declare
      2      v_emp_tbl emp_tbl_type := emp_tbl_type();
      3  begin
      4      dbms_output.put_line('Nested table v_emp_tbl has ' || v_emp_tbl.count || ' element(s).');
      5  end;
      6  /
    Nested table v_emp_tbl has 0 element(s).
    PL/SQL procedure successfully completed.
    SQL> NULL aplies to nested table element, not to nested table itself:
    SQL> declare
      2      v_emp_tbl emp_tbl_type := emp_tbl_type();
      3  begin
      4      v_emp_tbl.extend;
      5      if v_emp_tbl(1) is null
      6        then
      7          dbms_output.put_line('Nested table v_emp_tbl first element is NULL.');
      8      end if;
      9  end;
    10  /
    Nested table v_emp_tbl first element is NULL.
    PL/SQL procedure successfully completed.
    SQL> SY.

  • How to create APEX report from data in PLSQL table

    Hi, I have a procedure that is creating/inserting records into multidimensional pslql table. I want to create a report and graph based on the data stored in plsql table. Can someone please advice how to can I select this data in apex OR point me to any sample code?
    Thanks
    Aali

    Hi,
    try to google something about ORACLE TABLE CAST
    SELECT ot.yourcolumn
    FROM
       TABLE(CAST(yourplsqltablevariable AS userdefinedoracletype)) otE.g.
    http://it.toolbox.com/blogs/oracle-guide/using-a-plsql-table-in-sql-11013
    Regards,
    R.

  • More fun with enumerated dropdowns - Binding to table

    Hi All,
    I'm having some trouble with enumerated dropdowns.
    My context is as follows:
    node DATA 1...1
    ---> node FLIGHTS 0...N
       -->CARRID etc from SFLIGHTS
    --->DDL (element type string)
    I have successfully tried to add a simple dropdown with the following code on the component controller:
    method wddoinit .
        data lo_nd_data type ref to if_wd_context_node.
        data lo_el_data type ref to if_wd_context_element.
        data ls_data type wd_this->element_data.
        data lv_ddl like ls_data-ddl.
        data node_info type ref to if_wd_context_node_info.
        data vals type table of  wdr_context_attr_value.
        data: s_element type wdr_context_attr_value.
        data: str type string.
    *   navigate from <CONTEXT> to <DATA> via lead selection
        lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
    *   get element via lead selection
        lo_el_data = lo_nd_data->get_element(  ).
        lo_el_data->get_static_attributes(
          importing
            static_attributes = ls_data ).
    *      get node info
        call method lo_nd_data->get_node_info
          receiving
            node_info = node_info.
         do 25 times.
           str = sy-index.
           condense str no-gaps.
           s_element-text = str.
           s_element-value = str.
           append s_element to vals.
        enddo.
    *    Set Value_sets to node_info
         call method node_info->set_attribute_value_set
          exporting
            name      = 'DDL'
            value_set = vals
    endmethod.
    This works fine, however now I am trying the same thing with a field from the SFLIGHTS table.
    I want to display a table of the retrieved SFLIGHTS but a field as a dropdown with valid entries from the database. I have added the following code to the view.
    method WDDOINIT .
        data lo_nd_data type ref to if_wd_context_node.
        data lo_nd_flights type ref to if_wd_context_node.
        data lo_el_flights type ref to if_wd_context_element.
        data ls_flights type wd_this->element_flights.
        data gt_flights type table of sflights.
        select * from sflights into table gt_flights.
    *   navigate from <CONTEXT> to <DATA> via lead selection
        lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).
    *   navigate from <DATA> to <FLIGHTS> via lead selection
        lo_nd_flights = lo_nd_data->get_child_node( name = wd_this->wdctx_flights ).
        lo_nd_flights->bind_table( gt_flights ).
           types: begin of ty_carrname,
         carrname type s_carrname,
         end of ty_carrname.
       data: gt_carrname type table of ty_carrname.
       select distinct carrname
          from sflights
          into table gt_carrname.
         data lv_carrname like ls_flights-carrname.
         data node_info type ref to if_wd_context_node_info.
         data vals type table of  wdr_context_attr_value.
         data: s_element type wdr_context_attr_value.
         data: str type string.
          lo_nd_flights->get_static_attributes(
          importing
            static_attributes = ls_flights ).
          call method lo_nd_flights->get_node_info
          receiving
            node_info = node_info.
         field-symbols: <carrname> like line of gt_carrname.
         loop at gt_carrname assigning <carrname>.
           str = <carrname>-carrname.
           s_element-text = str.
           s_element-value = str.
           append s_element to vals.
         endloop.
         call method node_info->set_attribute_value_set
          exporting
            name      = 'CARRNAME'
            value_set = vals.
    endmethod.
    I can display all the entries with a repeating subform but when I bind the CARRNAME to an enumerated dropdown I get an ADS rendering error:
    WebDynpro Exception: The ADS call has failed. You can find information about the cause in the error.pdf on the application server
    I have looked in the Error PDF but it is blank.
    Does anyone have any suggestions on what is goign wrong or how to diagnose the problem.
    I am assuming you can have a data element that has a 0..N cardinality (i.e a table element) and is also of type enumerated dropdown.
    I'm guessing this is something to do with cardinality but I have no way to find out.
    Thanks,
    Gregor

    I have looked in the defaultTrace file and found the following errors:
    1.  A pdf document with 0 pages.
        Return Status: Render Failure
        Output Trace returned: <?xml version="1.0" encoding="UTF-8"?>
    <log>
       <m mid="29184" tid="10064.4896" sev="f" d="2008-11-12T15:20:01.722Z">Malformed SOM expression: $record.sap-vhlist.FLIGHTS\\.DATA[*]\\.CARRNAME.item[*]</m></log>
    Has anybody else used the enumerated dropdown element bound to dynamic data?
    I am using the latest releases and the "Specify Item Values" on the Object->Binding tab is filled in with what looks correct ($record.sap-vhlist.FLIGHTS\.Data etc) but greyed out.
    Thanks

  • How to read enumerated values from an OPC server via Datasocket

    Hi Labviewers,
    I am using LV8.2 and I am trying to find if it is possible to read enumerations from an OPC server via Datasocket, not just the values.
    I can successfully read a value for an OPC server via Datasocket and I get a value for example 3, is it possible to get the enumeration/string that corresponds to this value i.e. "Open".
    Many thanks in advance
    Dimitris

    Hi Sarah,
    With the input type as variant I get the following response:
    1                                     <-This is the current numeric value of the parameter
    4 Attribute(s):
       'Quality' -> 192
       'TimeHigh' -> 29861723
       'TimeLow' -> -665408304
       'Timestamp' -> 39.238E+3
    With the Input set to         Enum constant I get no values or strings coming back. With the Input set to                Ring constant I just get the numeric value   
    Dimitris   

  • Get distinct values from plsql array

    Hi,
    I have declared a variable as below in plsql proc.
    type t_itemid is table of varchar2(10);
    inserted set of items in to this using a program
    now i want distinct values from that array how can i get it.

    I am using 9i so i cannot use set operator and more over my problem is that i am declaring the variable inside the plsql block . when i tried i am getting the below errors:
    SQL> r
    1 declare
    2 type t_type is table of varchar2(10);
    3 v_type t_type;
    4 begin
    5 v_type := t_type('toys','story','good','good','toys','story','dupe','dupe');
    6 for i in (select column_value from table(v_type)) loop
    7 dbms_output.put_line(i.column_value);
    8 end loop;
    9* end;
    for i in (select column_value from table(v_type)) loop
    ERROR at line 6:
    ORA-06550: line 6, column 41:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 6, column 35:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    ORA-06550: line 6, column 10:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 7, column 22:
    PLS-00364: loop index variable 'I' use is invalid
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored

  • Problem with CLOB in PLSQL Web Service.

    Hi-
    I have Oracle Package that accepts CLOB as IN parameter and another CLOB as an OUT parameter. I went thru the tutorial in how to publish a database
    PLSQL package as a web service with out any problem. I was able to publish and call successfully my PLSQL web service thru a browser and thru a simple C# application. It's been working fine until I receive an XML file which is bigger than 32766:
    java.sql.SQLException: setString can only process strings of less than 32766 chararacters at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)]
    JDeveloper version: JDeveloper 10g (10.1.2.2.0) Build 1929
    Oracle Application Server 10g
    I'm newbie in JDeveloper so any help is greatly appreciated.
    Thanks!

    well Shay,
    i've used JDev's tools to developer and to deploy the web service: the war and ear files are automatically generates you to the end of the process.
    I have included all the files java and the compiled classes, but I do not have files jar.
    But don't works: if i create only one java class with all code inside then it works fine!!
    Daniele

  • Performance in plsql report

    hi guru's.
    i have a doubt in plsql performnace, i have been using many GTT in my project now, i feel to remove all GTT's intead of i plan to introduce collections.
    is it really improve the performance, i am thinking to avoid the context-switch?

    Memory usage depends mainly on WHAT is processed, and partly by WHICH means it is processed.
    So if you process a lot of data, it possible to lead nearly every report to dump.
    Your information is much to poor to say more.
    Siegfried

Maybe you are looking for