Expression in a varchar2

Hi
I have a variable called 'TT' of type varchar2. Where in I store an expression created by the user like txt_baseprm+txt_depnd*txt_baseprm*0.075.
How to evaluate this expression in forms 10g DS and store the result into a number type variable. txt_baseprm and txt_depnd are already defined in the form. The user is able to generate any formula by the interface provided.
Thanks.
Rajan

I'm assuming that the 'txt_*' variables come from a limited set of parameters and you know the name and value of each. So, for each parameter, replace the parameter with the corresponding number:
TT := REPLACE(TT,'txt_baseprm',to_char(txt_baseprm));When finished, the string should be the formula you want to evaluate. You can evaluate it in a function on the server with Execute Immediate, passing the formula as a parameter:
execute immediate 'select ('||parameter|| ')  from dual' into returned_1;If you declare returned_1 as a number datatype then the function will automatically check that the result is numeric and raise an exception otherwise. It will also raise an exception if more than 1 column is selected (ie if the formula contains a comma).

Similar Messages

  • Error using Filter with SQL Expression

    Hey all -
    New to Oracle BI, and getting a problem with Filters that use SQL Expressions.
    The column I'm filtering on is a 4 digit year, expressed as a VARCHAR2(4 byte) in the physical database. My SQL Expression in the filter is:
    Column: CAL YEAR 4 DIGIT
    Operator: Is equal to/in
    SQL Expression: TO_CHAR(ADD_MONTHS(SYSDATE, -24), 'YYYY'))
    when I click on the "Results" Tab I get the following error message:
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <(>: Syntax error [nQSError: 26012] . (HY000)
    I've isolated the issue to the expression above. If I put in a literal value and supply a four digit year like below it works:
    Column: CAL YEAR 4 DIGIT
    Operator: Is equal to/in
    SQL Expression: *2008*
    Any ideas on what's causing my problem?
    Thanks!
    Mac

    macearl wrote:
    SQL View does not display unless data is returned by the query. Is that normal?
    Also, none of these options shows the literal result of the expression we built, i.e.:
    expression: CAST(YEAR(TIMESTAMPADD(SQL_TSI_MONTH, -24, CURRENT_DATE)) as CHAR)
    result: *2008*
    Having the ability to test expressions and see their results would be very helpful in debugging. If anyone knows how to do that please share!
    Thanks!
    MacOk, Probably shoud have figured this out before, but in response to my own question, the way to view the result of an expression is to add the expression as a column and include it in the Table Presentation.
    - Mac (he can be taught)

  • Regular expressions with multi character separator

    I have data like the
    where |`| is the separator for distinguishing two fields of data. I am having trouble writing a regular expression to display the data correctly.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> declare
      2  l_string varchar2 (200) :='123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes';
      3  v varchar2(40);
      4  begin
      5  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 1);
      6  dbms_output.put_line(v);
      7  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 2);
      8  dbms_output.put_line(v);
      9  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 3);
    10  dbms_output.put_line(v);
    11  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 4);
    12  dbms_output.put_line(v);
    13  v:=regexp_substr(l_string, '[^(|`|)]+', 1, 5);
    14  dbms_output.put_line(v);
    15  end;
    16  /
    123
    456
    789 10 here
    223
    5434I need it to display
    123` 456
    789 10 here
    |223
    5434|`}22
    yesI am not sure how to handle multi character separators in data using reg expressions
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:35 PM
    Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:37 PM

    Hi,
    Actually, using non-greedy matching, you can do what you want with regular expressions:
    VARIABLE     l_string     VARCHAR2 (100)
    EXEC  :l_string := '123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes'
    SELECT     LEVEL
    ,     REPLACE ( REGEXP_SUBSTR ( '|`|' || REPLACE ( :l_string
                                     , '|`|'
                                      , '|`||`|'
                                     ) || '|`|'
                        , '\|`\|.*?\|`\|'
                        , 1
                        , LEVEL
               , '|`|'
               )     AS ITEM
    FROM     dual
    CONNECT BY     LEVEL     <= 7
    ;Output:
    LEVEL ITEM
        1 123` 456
        2 789 10 here
        3 |223
        4 5434|`}22
        5 yes
        6
        7Here's how it works:
    The pattern
    ~.*?~is non-greedy ; it matches the smallest possible string that begins and ends with a '~'. So
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 1) returns '~SHALL~'. However,
    REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 2) returns '~COMPARE~'. Why not '~I~'? Because the '~' between 'SHALL' and 'I' was part of the 1st pattern, so it can't be part of the 2nd pattern. So the first thing we have to do is double the delimiters; that's what the inner REPLACE does. The we add delimiters to the beginning and end of the list. Once we've done prepared the string like that, we can use the non-greedy REGEXP_SUBSTR to bring back the delimited items, with a delimiter at either end. We don't want those delimiters, so the outer REPLACE removes them.
    I'm not sure this is any better than Sri's solution.

  • OWB 10gR2 - some enhancement requests

    Hi, I've been working with OWB 10gR2 for approximately a week now, and I've come across a few (minor) bugs, as well as a list of enhancements that I think would make the tool better. I'd like to surface these in this forum so they can be either disagreed with or have workarounds suggested, as well as getting this list in front of Oracle. Also I'm new to the tool, so maybe there are ways to accomplish what I want.
    p.s. as a side note - please don't take these as criticisms of the tool. I'm actually very impressed with OWB 10gR2, but just want to surface some ideas that I think would make the tool better.
    Thanks,
    Scott
    ---Bugs:
    1.     If I enter a quote character in one of the business description fields (i.e. for a cube or dimension), it causes the DDL scripts to blow up. It probably mentions the list of valid characters in the users guide somewhere - but if a character isn't legal, it should be flagged when I try to enter it originally – not when deploying
    2.     I can enter illegal strings in an expression operator that fail validation there, but the whole map still passes validation. For instance, I put in an expression (for a varchar2 field) using a single quote at the start, but mistakenly with a double quote at the end. I didn’t bother to validate this within the expression. The whole map validated fine, but (of course) blew up with the illegal syntax when generating the code.
    3.     I get the following error when trying to browse a cube (ROLAP, not MOLAP) through OWB, but I'm able to pull the cube up fine using either the excel add-in or biBeans: CubeDV_OLAPSchemaConnectionException_ENT_06952???
    ---Enhancement Requests:
    1.     Add a “deploy” button in control center next to the to “default actions” and “reset actions” buttons
    2.     Allow an option to have dimensions and cube defaults set to either “deploy all”, “deploy data only”, “deploy catalog only”, “deploy aggregations” (for cubes). Also, why is the default set to “deploy data only”? Does deploying the CMW2 metadata involve huge performance impacts or something? It seems like the CMW2 is almost “free” – so it should be turned on by default. Its a pain to use the dimension wizard, but then have to go in to each dimension afterwards to set this option.
    3.     When using “configure” on dims and cubes in control center, the first time the “configuration properties” dialog pops up, everything is fine. However, when you try to configure the 2nd object, the “background focus” switches from control center back to design center. This makes navigation very slow if you have lots of items to change. I've noticed this behavior in a few other places as well.
    4.     Some dialogs do not have maximize buttons (i.e. dimension wizard dialogs), and default to a very small size. It is possible to have size of dialogs dynamically scaled to screen resolutions, and attempt to size columns so they fit properly. Or better yet, have each dialog remember how large it was last time, and automatically open up to that size?
    5.     When generating the “autobind” relational table while creating a dimension, it seems to be “randomizing” the order of the attributes within a level (although it does sort the “top level” attributes first, followed by lower level attributes), at least when using the dimension wizard. It would be nice if the attributes in the relational table came out sorted in the same order as they are specified in the attributes tab.
    6.     When using a “unmapped” display set– there doesn’t seem to be a way to refresh the set (i.e. remove the items that have since been mapped) unless you select “all” and then “unmapped” again. Would be nice if you could simply choose “unmapped” again and have it refresh the object
    7.     While doing a mapping, right click on canvas allows option to “generate”. Would be nice to also add the “validate” option to this menu
    8.     Validating mappings takes a decent amount of time – would be nice if a “busy” icon was displayed to let user know that OWB hasn’t locked up.
    9.     default size of “job details” dialog is too small, and even if I maximize I still have to go through and manually adjust the size of each pane. Similar to enhancement #4
    10.     Horizontal size of operators in mapping seems to be determined by the length of the operator name, instead of tying directly to the icon. Looks strange. Very minor
    11.     When displaying dimension objects in a mapping:
    a.     For the “surrogate key” columns – add an icon to indicate this attribute is a surrogate key. Likewise, since its not legal to map anything to this column, remove the little “arrow” next to it (the one that turns gray when something is mapped to a column), or perhaps don't even show this column at all.
    b.     For the “business key” columns – add some type of icon to show which attributes represent the business natural key (or make color different, etc.)
    12.     Similar to #11, for the cube operator in a mapping:
    a.     For the “surrogate key” columns – if they can’t be mapped to, then don’t show them
    b.     For the “business key” columns – add some type of icon to show which attributes represent the business natural key
    c.     Separate the “measure” columns from the dimension columns
    13.     For the “Aggregation” operator – can you move the “<None>” default operator to the top of the list. At the bottom, it means you always have to scroll to use the most common operations (which are at the top of the list), i.e. sum and avg, etc.
    14.     In the log on prompt, if I choose SQL*Net connection, every time I start it up it defaults to the details being shown (even when I chose no detail last time), with cursor in the “host” box. I should be able to have the details hidden, and this dialog should ALWAYS default to having the active cursor in the password box on startup
    15.     When printing in a mapping, the “page setup” print dialog is very slow. Also, the “print setup” dialog shows margins, but you can’t adjust them. It would be nice if this could be changed here
    16.     Add a “print preview” icon to all of the toolbars. Printer icon is there, print preview should also be.
    17.     In the dimension attributes, we need a way to tag an attribute as being the “insert record” date or the “update record” date. The corresponding MERGE SQL should be updated to use these attributes.
    18.     It would be nice if the mapping canvas defaulted to an unlimited size…i.e. when I want to add new operators and the screen is already full, I either need to shrink the zoom factor down to the point where I can’t read the icons anymore, or I have to pick up the new operator and “drag” at the bottom / right side until it scrolls enough to drop it where I want. If the canvas had an unlimited size, I could simple use the scroll bars to scroll to where I want.
    19.     Scroll wheel functionality to zoom in / out (and have it zoom in around the currently selected object)
    20.     Option to have operations automatically resize when longer attribute names are added to them (can workaround by mimimizing and then maximizing, but would be better to have the operators automatically adjust size to fit)
    21.     Ability to sort output attributes in an operator (just like table column sort functionality). If I create a new operator, it would be nice to group it with related operators instead of always having it at bottom.
    22.     re: column sort functionality – drag and drop instead of up/down arrows would be nice
    23.     It would be nice if, when adding output attributes to (for example) the expression operator, it would choose the default data type the same way the dimension attribute wizard works (i.e. if it sees “ind” in name, automatically choose char(1)
    24.     Change the “zoom in” button so that it zooms in on the currently selected operator – i.e. if I click on a particular table and then hit the zoom in button, it should keep the table I selected centered
    25.     When in a mapping, clicking on a line should highlight the attributes on both the source and target operators (to allow easier visual ID of where data is coming from / going to)
    26.     AWM has a feature where table attributes can be sorted so that mappings between them don't have "crossed" lines. Similar functionality in OWB would be very appreciated. It may be harder to automate this, but even manual drag and drop of attributes within an operator would be nice.

    if you could copy/paste this whole thing into the submission form (see feedback option under the numbers menu). The more people that request these features, the more likely we are to see them in an update or the next version.
    Jason

  • 12c: redaction_policies table not visible in dba_tables, dictionary

    The table redaction_policies is visible when we describe it or search tab but is not listed in dictionary or dba_tables.
    NCDB@NCDB> desc redaction_policies
    Name                    Null?    Type
    OBJECT_OWNER            NOT NULL VARCHAR2(128)
    OBJECT_NAME             NOT NULL VARCHAR2(128)
    POLICY_NAME             NOT NULL VARCHAR2(128)
    EXPRESSION              NOT NULL VARCHAR2(4000)
    ENABLE                           VARCHAR2(7)
    POLICY_DESCRIPTION               VARCHAR2(4000)
    NCDB@NCDB> select table_name from dba_tables where table_name like '%REDA%';
    no rows selected
    NCDB@NCDB>  select table_name from dictionary  where table_name like '%REDA%';
    no rows selected
    NCDB@NCDB> select tname from tab where tname like '%REDA%';
    TNAME
    REDACTION_COLUMNS
    REDACTION_POLICIES
    REDACTION_VALUES_FOR_TYPE_FULL
    what could be the reason?
    Regards

    I'd say I wouldn't expect it to be returned from dba_tables, since it's a datadictionary view, just like V$SESSION etc.
    SQL> select * from dba_tables where table_name = 'V$SESSION';
    no rows selected
    However, based on the docs:
    Configuring Oracle Data Redaction Policies
    I'd expect to see it returned from dictionary, just like:
    SQL> select * from dictionary where table_name = 'V$SESSION';
    TABLE_NAME
    COMMENTS
    V$SESSION
    Synonym for V_$SESSION
    1 row selected.
    But, since I'm not on 12c now, I can't really add much more.

  • Unexpected "result of the string concatenation is too long" error

    Hello,
    I am using Oracle Database 11.2.0.
    When querying my database with a common table expression which concatenates VARCHAR2 strings, I receive an ORA-01489 error although I'm doubting that I am concatenating more than 4000 characters.
    To be more precise, I have a table entity which basically stores XML elements including their parent element and their sibling position among its siblings. The CREATE statement for this table is listed below.
    CREATE TABLE Entity (
    ID NUMBER(10,0) NOT NULL PRIMARY KEY,
    Name VARCHAR2(100) NOT NULL,
    Parent NUMBER(10,0) REFERENCES Entity(ID),
    Sibling_Pos NUMBER(2,0) DEFAULT 0
    Now, I would like for all elements to be concatenated with their ancestor elements to a structure like this:
    "/root_element(sibling_pos)/.../ancestor_element(sibling_pos)/parent_element(sibling_pos)/current_element(sibling_pos)"
    (where root_element, ancestor_element, parent_element and current_element are just values from the name column of the entity table)
    In order to achieve this, I use a common table expression which concatenates the name and sibling_pos values as shown below:
    WITH entity_cte (lvl, id, path) AS (
    SELECT 1 AS lvl, id, '/' || name || '(0' || sibling_pos || ')' AS path
    FROM entity
    WHERE parent IS NULL
    UNION ALL (
    SELECT lvl + 1 AS lvl, e.id, entity_cte.path || '/' || e.name || '(' || cast(e.sibling_pos AS VARCHAR2(2)) || ')' AS path
    FROM entity_cte, entity e
    WHERE entity_cte.id = e.parent
    SELECT lvl, id, path
    FROM entity_cte e
    After inserting certain values, I get the ORA-01489 error, that the result of the string concatenation is too long. The maximum is referred to as being 4000 characters for VARCHAR2 in the oracle documentation and in various websites. Of course, it is clear to me by just using the common table expression like that, I could run into such an error. However, due to the structure of my XML documents, I doubted that the resulting strings would be more than 4000 characters long.
    So, I rearranged my query in order to count the characters to be concatenated instead of actually concatenating them. The query is stated below as well, the changes are marked bold:
    WITH entity_cte (lvl, id, path) AS (
    SELECT 1 AS lvl, id, length('/' || name ||  '(0' || sibling_pos || ')') AS path
    FROM entity
    WHERE parent IS NULL
    UNION ALL (
    SELECT lvl + 1 AS lvl, e.id, entity_cte.path + length('/' || e.name || '(' || cast(e.sibling_pos AS VARCHAR2(2)) || ')') AS path
    FROM entity_cte, entity e
    WHERE entity_cte.id = e.parent
    SELECT lvl, id, path
    FROM entity_cte e
    ORDER BY path DESC
    The result of the query gives me a maximum length of 319 characters.
    To be sure, I also checked the maximum level depth (indicated by the column named lvl in the common table expression), meaning the maximum number of elements in my path (the concatenated string). The result is 18. As I use VARCHAR2(100) for the name column and add 5 charcaters in each level, the maximum number of characters expected for 18 levels would be 1890.
    So, now I wonder is the ORA-01489 maybe raised for another reason? Or is there something else I am missing?
    Any help would be appreciated. Further suggestions to track down the error are more than welcome. Thanks in advance.

    Thanks for the hint, BluShadow.
    Still, I don't reach that limit of 1000 characters with my actual data (yet). I understand that if my data changes, I might run into that error with the given query. But I don't understand why this error is raised with the given data I have. The longest string in the column "name" is 32 characters long up to now. When I'm adding 5 characters on each level and I only have max 18 levels that should only result in max 2664 bytes.
    @odie_63
    The database characterset is: AL32UTF8. If I googled correctly, than it just confirms what BluShadow said, that one character is represented by max 4 byte.
    Regarding the sample data, the XML document that I am inserting and which causes the error comprises 1058 nodes. That means I have 1058 entries in my entity table. I think it would be no sense posting all of it here, but is there a way that I can attach a text file containing an insert script to this post?
    Some sample data from the entity table orderd by the length of the string in the name column are shown below.
    "ID"     "NAME"     "TYPE"     "PARENT"     "SIBLING_POS"
    90     "representedCustodianOrganization"     1     89     0
    109     "serviceProviderOrganization"     1     108     0
    58     "standardIndustryClassCode"     1     55     2
    186     "standardIndustryClassCode"     1     173     7
    150     "standardIndustryClassCode"     1     137     7
    106     "dischargeDispositionCode"     1     99     4
    35     "administrativeGenderCode"     1     29     3
    932     "substanceAdministration"     1     931     0
    950     "substanceAdministration"     1     949     0
    1043     "representedOrganization"     1     1041     1
    71     "representedOrganization"     1     61     6
    137     "representedOrganization"     1     128     5
    173     "representedOrganization"     1     163     6
    504     "substanceAdministration"     1     503     0
    223     "representedOrganization"     1     221     1
    252     "representedOrganization"     1     250     1
    272     "representedOrganization"     1     270     1
    477     "substanceAdministration"     1     476     0
    481     "manufacturedLabeledDrug"     1     480     0
    207     "representedOrganization"     1     205     1
    802     "specimenPlayingEntity"     1     801     0
    830     "specimenPlayingEntity"     1     829     0
    844     "specimenPlayingEntity"     1     843     0
    858     "specimenPlayingEntity"     1     857     0
    99     "encompassingEncounter"     1     98     0
    788     "specimenPlayingEntity"     1     787     0
    676     "specimenPlayingEntity"     1     675     0
    704     "specimenPlayingEntity"     1     703     0
    718     "specimenPlayingEntity"     1     717     0
    746     "specimenPlayingEntity"     1     745     0
    Any help or further suggestion are appreciated. Thank you.

  • How can i use this expression in DECODE function?

    My PNO table formart is
    PNO PDate PCount
    P001 08/27/05 09:45 20
    P001 08/27/05 09:50 10
    P002 08/27/05 03:40 20
    P003 08/28/05 11:00 20
    P003 09/28/05 10:00 20
    P003 08/27/05 11:00 10
    P003 09/27/05 04:00 50
    I want to display total pcount for shift1(morning) and shift2(evening) & the date is 08/27/05
    PNO Shift1(08/27/2005 08:00 to 12:30) Shift2(08/27/2005 02:00 to 05:30)
    P001 30 0
    P002 0 20
    P004 10 50
    So for shift1 condition is:
    pdate>=08/27/2005 08:00 and pdate<=08/27/2005 12:30
    So for shift2 condition is:
    pdate>=08/27/2005 02:00 and pdate<=08/27/2005 05:30
    If i tried to give this expression in decode function , its not working.
    Please give me the sql query to solve this problem.
    Millions of thanks in advacne

    forgot to paste the output for a given date.
    SQL> create table pno
      2  (pno    varchar2(32)
      3  ,pdate  date
      4  ,pcount number)
      5  /
    Table created.
    SQL>
    SQL> insert into pno values('P001', to_Date('08/27/05 09:45', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P001', to_Date('08/27/05 09:50', 'mm/dd/yy hh:mi') ,10)
      2  /
    1 row created.
    SQL> insert into pno values('P002', to_Date('08/27/05 03:40', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL>
    SQL> insert into pno values('P003', to_Date('08/28/05 11:00', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('09/28/05 10:00', 'mm/dd/yy hh:mi') ,20)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('08/27/05 11:00', 'mm/dd/yy hh:mi') ,10)
      2  /
    1 row created.
    SQL> insert into pno values('P003', to_Date('09/27/05 04:00', 'mm/dd/yy hh:mi') ,50)
      2  /
    1 row created.
    SQL> select pno,sum(pcount) "Morning Shift Count"
      2  from pno
      3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 08:00'
      4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 12:30'
      5  group by pno
      6  /
    PNO                              Morning Shift Count                           
    P001                                              30                           
    P003                                              10                           
    SQL> select pno,sum(pcount) "Evening Shift Count"
      2  from pno
      3  where to_char(pdate, 'mm/dd/yyyy hh:mi') >= '08/27/2005 02:00'
      4    and to_char(pdate, 'mm/dd/yyyy hh:mi') <='08/27/2005 05:30'
      5  group by pno
      6  /
    PNO                              Evening Shift Count                           
    P002                                              20                           

  • 'expression is of wrong type' - but which and where..?

    hello.
    Hopefully this will be clear as day to someone.. Please could someone tell me why I'm getting the following error message..
    [061010_042222995][][EXCEPTION] SQLException encounter while executing data trigger....
    java.sql.SQLException: ORA-06550: line 4, column 20:
    PLS-00382: expression is of wrong type
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignoreddata template where trigger is called..
      <?xml version="1.0" encoding="utf-8" ?>
    - <dataTemplate name="UofS_OutstandngExpenses_Report" defaultPackage="SUBIXCLT" dataSourceRef="FINDEV" version="1.0">
    - <properties>
      <property name="xml_tag_case" value="upper" />
      <property name="include_parameters" value="true" />
      <property name="debug_mode" value="on" />
      </properties>
    - <parameters>
      <parameter name="p_claimant" dataType="character" defaultValue="" />
      <parameter name="p_expense_date_from" dataType="date" defaultValue="" />
      <parameter name="p_expense_date_to" dataType="date" defaultValue="" />
      <parameter name="p_raisedby" dataType="character" defaultValue="" />
      <parameter name="p_status" dataType="character" defaultValue="" />
      <parameter name="p_ordered_by" dataType="varchar2" defaultValue="" />
      </parameters>
    - <dataQuery>
    - <sqlStatement name="Q1">
    - <![CDATA[
    SELECT DISTINCT
    erh.invoice_num,
    pap.full_name EMP_CLAIMING,
    DECODE(NVL(erh.expense_status_code, 'Not yet Submitted (NULL)'), 'CANCELLED', 'CANCELLED',
         'EMPAPPR', 'Pending Individuals Approval',      'ERROR', 'Pending System Administrator Action',
         'HOLD_PENDING_RECEIPTS     ', 'Hold Pending Receipts', 'INPROGRESS', 'In Progress', 'INVOICED', 'Ready for Payment',
         'MGRAPPR', 'Pending Payables Approval', 'MGRPAYAPPR', 'Ready for Invoicing', 'PAID', 'Paid',
         'PARPAID', 'Partially Paid',     'PAYAPPR', 'Payables Approved',     'PENDMGR', 'Pending Manager Approval',
         'PEND_HOLDS_CLEARANCE', 'Pending Payment Verification',     'REJECTED', 'Rejected',     'RESOLUTN',     'Pending Your Resolution',
         'RETURNED',     'Returned',     'SAVED',     'Saved',     'SUBMITTED',     'Submitted',     'UNUSED',     'UNUSED',
         'WITHDRAWN','Withdrawn',     'Not yet Submitted (NULL)') "EXPENSE_STATUS" ,
    NVL(TO_CHAR(erh.report_submitted_date,'dd-MON-yyyy'),'NULL') SUBMIT_DATE,
    NVL(TO_CHAR(erh.expense_last_status_date,'dd-MON-yyyy'),'NULL') LAST_UPDATE,
    erh.override_approver_name ER_Approver,
    fu.description EXP_ADMIN,
    erh.total,
    erh.description 
    FROM
    AP_EXPENSE_REPORT_HEADERS_all erh,
    per_all_people_f pap, fnd_user fu
    WHERE erh.employee_id = pap.person_id
    AND fu.user_id = erh.created_by
    AND NVL(erh.expense_status_code, 'Not yet Submitted') NOT IN  ('MGRAPPR', 'INVOICED', 'PAID', 'PARPAID')
    AND pap.full_name = NVL(:p_claimant, pap.full_name)
    AND TRUNC(erh.report_submitted_date) BETWEEN NVL(:p_expense_date_from, '01-JAN-1999') AND NVL(:p_expense_date_to,'31-DEC-2299')
    AND fu.description = NVL(:p_raisedby,fu.description)
    AND erh.expense_status_code = NVL(:p_status,erh.expense_status_code) &L_ORDERED_BY
      ]]>
      </sqlStatement>
      </dataQuery>
      <dataTrigger name="beforeReport" source="SUBIXCLT.beforeReportTrigger" />
    - <dataStructure>
    - <group name="G_XP_CLM_TRACKNG" source="Q1">
      <element name="INVOICE_NUM" value="INVOICE_NUM" />
      <element name="EMP_CLAIMING" value="EMP_CLAIMING" />
      <element name="EXPENSE_STATUS" value="EXPENSE_STATUS" />
      <element name="SUBMIT_DATE" value="SUBMIT_DATE" />
      <element name="LAST_UPDATE" value="LAST_UPDATE" />
      </group>
      </dataStructure>
      </dataTemplate>and the package spec & body..
    --THE SPEC...
    CREATE OR REPLACE PACKAGE Subixclt IS
    FUNCTION beforeReportTrigger RETURN VARCHAR2;
    p_order_by VARCHAR2(50);
    l_ordered_by VARCHAR2(350);
    p_claimant  VARCHAR2(80);
    expense_date_from DATE;
    expense_date_to DATE;
    p_raisedby   VARCHAR2(80);
    p_status   VARCHAR2(80);
    p_ordered_by   VARCHAR2(80);
    --RETURN VARCHAR2;
    END;
    --THE BODY...
    REATE OR REPLACE PACKAGE BODY Subixclt IS
    FUNCTION BeforeReportTrigger RETURN VARCHAR2 IS
    BEGIN
    Fnd_File.PUT_LINE(Fnd_File.LOG,'L_ORDERED_by'||L_ORDERED_BY);
    DECLARE
    L_ORDERED_BY VARCHAR2(50);
    P_ORDERED_BY  VARCHAR2(50);
    P_RAISEDBY VARCHAR2(50);
    P_STATUS VARCHAR2(50);
    P_CLAIMANT VARCHAR2(100);
    P_EXPENSE_DATE_FROM DATE;
    --P_EXPENSE_DATE_FROM  VARCHAR2(50);
    --P_EXPENSE_DATE_TO  VARCHAR2(50);
    P_EXPENSE_DATE_TO DATE;
    BEGIN
    IF (P_ORDERED_BY='Expense Report Number') THEN
         L_ORDERED_BY :='order by 1 asc;';
      ELSIF (P_ORDERED_BY='Person Claiming') THEN
         L_ORDERED_BY :='order by 2 asc;';
      ELSIF (P_ORDERED_BY='Submit Date') THEN
      L_ORDERED_BY :='order by 4 asc;';
      END IF;
    RETURN(L_ORDERED_BY);
    --RETURN NULL;
    END;
    END;
    END;Many thanks for looking..
    D

    Thanks for the suggestion. I initially didnt have the RETURN TRUE after every IF statement and have since removed the 'WHEN OTHERS' section but I'm still getting the same error message. If its to be believed, doesn't it sound like its not finding any of the 3 possible parameter entries available? This can't be so, I've checked the ConC Program parameter name is correct, and the value set linked to it only has available the 3 options where I make the choice..
    Body now reads:
    CREATE OR REPLACE PACKAGE BODY Subixclt
    AS
    FUNCTION BEFOREREP (P_ORDERED_BY IN VARCHAR2)RETURN BOOLEAN IS
    BEGIN
    --FND_FILE.PUT_LINE(FND_FILE.LOG,'L_ORDERED_by'||L_ORDERED_BY);
    DECLARE
    L_ORDERED_BY VARCHAR2(50);
    --P_RAISEDBY VARCHAR2(50);
    --P_STATUS VARCHAR2(50);
    --P_CLAIMANT VARCHAR2(100);
    --P_EXPENSE_DATE_FROM DATE;
    --P_EXPENSE_DATE_TO DATE;
    BEGIN
    IF (P_ORDERED_BY='Expense Report Number') THEN
         L_ORDERED_BY :='order by 1 asc;';
      ELSIF (P_ORDERED_BY='Person Claiming') THEN
         L_ORDERED_BY :='order by 2 asc;';
      ELSIF (P_ORDERED_BY='Submit Date') THEN
      L_ORDERED_BY :='order by 4 asc;';
      RETURN TRUE;
      END IF;
    -- EXCEPTION WHEN OTHERS THEN RETURN FALSE;
    --RETURN(L_ORDERED_BY);
    END;
    END;
    END;error log reads:
    XDO Data Engine Version No: 5.6.3
    Resp: 20707
    Org ID : 102
    Request ID: 2484872
    All Parameters: p_raisedby=SUSAN HOLLIDAY:p_status=:p_claimant=:p_expense_date_from=:p_expense_date_to=:P_ORDERED_BY=Person Claiming
    Data Template Code: SUBIXCLT
    Data Template Application Short Name: PO
    Debug Flag: N
    {p_claimant=, p_expense_date_to=, p_status=, p_raisedby=SUSAN HOLLIDAY, p_expense_date_from=, P_ORDERED_BY=Person Claiming}
    Calling XDO Data Engine...
    [061110_114425280][][STATEMENT] Start process Data
    [061110_114425282][][STATEMENT] Process Data ...
    [061110_114425284][][STATEMENT] Executing data triggers...
    [061110_114425284][][STATEMENT] BEGIN
    SUBIXCLT.p_claimant := :p_claimant ;
    SUBIXCLT.p_expense_date_from := :p_expense_date_from ;
    SUBIXCLT.p_expense_date_to := :p_expense_date_to ;
    SUBIXCLT.p_raisedby := :p_raisedby ;
    SUBIXCLT.p_status := :p_status ;
    SUBIXCLT.p_ordered_by := :p_ordered_by ;
    :XDO_OUT_PARAMETER := 1;
    END;
    [061110_114425287][][STATEMENT] 1: :
    [061110_114425287][][STATEMENT] 2:null :
    [061110_114425287][][STATEMENT] 3:null :
    [061110_114425288][][STATEMENT] 4:SUSAN HOLLIDAY :
    [061110_114425288][][STATEMENT] 5: :
    [061110_114425288][][STATEMENT] 6:null :
    [061110_114425291][][STATEMENT] Executing data triggers...
    [061110_114425292][][STATEMENT] Declare
    l_flag Boolean;
    BEGIN
    l_flag := SUBIXCLT.beforerep(:p_ordered_by) ;
    if (l_flag) then
    :XDO_OUT_PARAMETER := 1;
    end if;
    end;
    [061110_114425293][][STATEMENT] 1:null :
    [061110_114425302][][EXCEPTION] SQLException encounter while executing data trigger....
    java.sql.SQLException: ORA-06503: PL/SQL: Function returned without value
    ORA-06512: at "APPS.SUBIXCLT", line 27
    ORA-06512: at line 4Many thanks for staying with this..
    S

  • On the use of VARCHAR2 vs. CHAR

    I'm posting an e-mail thread that has been moving around in my organization, whith guidance from an Oracle representative.
    The basic issue concerns the use of CHAR vs. VARCHAR2 when defining a table in Oracle.
    I would like to get some comments from the community at large.
    1. Business semantics should be represented in every aspect of a database, application, and design as far as I am concerned. Noteably, if the business rule at a corporate entity is clearly stated that when using Oracle the use of CHAR should be limited to those attribute implementations which have the following characteristics; a) The attribute may not be null, b) The attribute must have a character in each of the declared positions.
    2. When the Visual Basic application began writing data to the CHAR columns in your application someone should have had a discussion with the developer to find out why this was happening. If the business semantics changed then the logical implemention of the business semantics should have changed as well. That the two were disconnected is not a problem with the CHAR type, it is a problem with the designer or the developer. The bottom line on this instance is that the column should have been defined as a VARCHAR2 data type since the business semantics no longer complied with the criteria set forth in the previous paragraph.
    3. I think Oracle trys to load as much of the data from a table or index into shared memory, in this case the database block buffers, as it can in order to facilitate query operations. If Oracle has enough memory and can load a table or index into memory, it will do so. At the same time the database engine will move previously cached data out of memory to accommodate the new requirement.
    -----Original Message-----
    Thank you for the detail information on CHAR and VARCHAR2. It got me thinking with a DBA hat. I worked as a DBA before and I did use the CHAR type and I will share my experience/thought on CHAR.
    I don't like to use the char type like Tom has advised because Oracle does not check to see if the value being inserted fills up the column or not which can lead to a problem. And there is no performance gain or save space in Oracle.
    I worked as a DBA before, I used char type on the "must fill/always filled" column (pre DMDC). The application was written in VB with Oracle back end. At some point, VB started inserting values that are short of the column width and created a minor problem (it was supposed to be filled column). The problem was quickly identified and fixed, but it caused an issue.
    I realize that I don’t want to define it as a "must fill/always filled" column if you can't enforce it by simply defining the char data type on a table and prevent possible issue in the future.
    For a manager, in order to use the char properly, you have to hire client developers with Oracle experience or provide a basic Oracle training in order to avoid the problem I mentioned above in order to use the char type correctly.
    I think you, Tom and I are saying the same thing really. Only difference is that Tom and I can not think of a good reason why anyone would like to indicate the business semantics using column type on the database, when it can lead to more work/issues.
    In regards to wasted 25 million byes, why would Oracle load the table with 25 million rows? Shouldn't it use an index? Don't you have a serious problem if Oracle is loading table with the 25 million rows?
    Just my two cents... : )
    -----Original Message-----
    May I beg to differ?
    CHAR plays a vital role in the intuitive interpretation of a database schema. If designed correctly, the use of CHAR tells anyone who is in the know that this is a must fill column. Thus if a column is defined as CHAR(3) everyone should know that the column will always contain three characters. Defining the column as VARCHAR2(3) does not tell you anything about the data other than that the column may contain 0-3 characters.
    Also, If a column is defined as CHAR the column should always be populated. One of the nice features of VARCHAR2 is that if the column is defined at the end of a table, there is no storage overhead until that column is actually populated. Thus if you have a table that has an identifier that is nine characters in length and will always be populated with nine characters, an attribute which describes the type of identifier which is contained in the first column and which must always be populated and is a must fill attribute, and another column which is descriptive and may vary in length or not be populated at time of insert; the following definition does not express the business semantics of the entity:
    COL_CD VARCHAR2(9)
    COL_TYP_TXT VARCHAR2(26)
    COL_TYP_CD VARCHAR2(2)
    The above definition also does not take advantage of inherent storage features of Oracle; notably there is a wasted place holder between COL_CD and COL_TYP_TXT and between COL_TYP_TXT and COL_TYP_CD. The next definition does take advantage of the storage features but does not represent the business semantics of the entity:
    COL_CD VARCHAR2(9)
    COL_TYP_CD VARCHAR2(2)
    COL_TYP_TXT VARCHAR2(26)
    The above definition does not waste space storing a place holder between COL_TYP_CD and COL_TYP_TXT if the COL_TYP_TXT may be null. The column separator will only be used when the column contains data. The below definition satisfies both the storage and business semantics issues:
    COL_CD CHAR(9)
    COL_TYP_CD CHAR(2)
    COL_TYP_TXT VARCHAR2(26)
    This may seem pedantic in nature until you consider the situation where there are 25 million rows in the table represented by the above entity. If each row has a NULL COL_TYP_TXT value then the first example wasted 25 million bytes of storage and 25 million bytes of memory if the full table is loaded into memory. This is an issue which cannot be ignored in high volume databases.
    You may wish to know why it is important to define a must fill/always fill column as a CHAR to express the business semantics of an attribute. I can't give a definitive answer to that other than to say that it is just good database manners.
    So please, continue to use CHAR when the shoe fits. Don't throw something away that has use just because it is not popular or in the mode.
    Also, if I am mistaken in any of the above, please feel free to educate me.
    Thanks.
    -----Original Message-----
    Subject: RE: Oracle on the use of VARCHAR2 vs. CHAR
    Ignore if you already got this. This is just FYI.
    -----Original Message-----
    Below is a detailed answer to your VARCHAR2 or CHAR questions from our Database expert Tom Kyte. The short answer is VARCHAR2 is what you want to use. If you have any questions or want to discuss this in more detail let me know.
    A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
    The difference between a CHAR and a VARCHAR is that a CHAR(n) will ALWAYS be N bytes long, it will be blank padded upon insert to ensure this. A varchar2(n) on the other hand will be 1 to N bytes long, it will NOT be blank padded.
    Using a CHAR on a varying width field can be a pain due to the search semantics of CHAR.
    Consider the following examples:
    ops$tkyte@8i> create table t ( x char(10) ); Table created.
    ops$tkyte@8i> insert into t values ( 'Hello' );
    1 row created.
    ops$tkyte@8i> select * from t where x = 'Hello';
    X
    Hello
    ops$tkyte@8i> variable y varchar2(25)
    ops$tkyte@8i> exec :y := 'Hello'
    PL/SQL procedure successfully completed.
    ops$tkyte@8i> select * from t where x = :y; no rows selected
    ops$tkyte@8i> select * from t where x = rpad(:y,10);
    X
    Hello
    Notice how when doing the search with a varchar2 variable (almost every tool in the world uses this type), we have to rpad() it to get a hit.
    If the field is in fact ALWAYS 10 bytes long, using a CHAR will not hurt -- HOWEVER, it will not help either.
    The only time I personally use a CHAR type is for CHAR(1). And that is only because its faster to type char(1) then varchar2(1) -- it offers no advantages.
    If you just use varchar2 everywhere, no problem
    My advice is, has been, will be very loudly stated as:
    IGNORE THE EXISTENCE OF CHAR.
    period. If you never use char, you never compare char to varchar2, problem solved.
    And if you use char and compare a char(n) to a char(m) they will never compare either.
    Just say NO TO CHAR.
    **************************************************

    Hi,
    >>A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
    Ok, but on the other hands:
    SGMS@ORACLE10> create table x (name char(10), name2 varchar2(10));
    Table created.
    SGMS@ORACLE10> insert into  x values ('hello','hello');
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select vsize(name),vsize(name2) from x;
    VSIZE(NAME) VSIZE(NAME2)
             10            5
    SGMS@ORACLE10> select dump(name),dump(name2) from x;
    DUMP(NAME)                                         DUMP(NAME2)
    Typ=96 Len=10: 104,101,108,108,111,32,32,32,32,32  Typ=1 Len=5: 104,101,108,108,111Cheers

  • Need to convert the Varchar2 to decimal

    Hi,
    I need to convert source sybase varchar2 record in to decimal record in Target DB2 table by using the function in Oracle data integrator.
    In my source table, column is defined as varchar2 (4) and in target table same column has defined as Decimal (2). So, is there any function to convert the varchar2 data to decimal record.
    thanks,
    keshav.

    Hi SH,
    Thanx so much for your answer!
    Well actually I have managed to do the filters, and right now dealing with the convertion of formats.
    Right now I am working with Oracle DB 11g, and Excel; and what i would like to do is now that is passing from my uploaded excel the info to my Oracle DB would like to control the ways it pases the info.
    Let's say for example, that I have gotten a Field A in my source table (Excel uploaded to ODI), and that on my Orazle Table on Field A i would like to change the data type of the field, or just make sure that the data inserted will always be of certain type? Can I do this with ODI? Could you please give me some advice in how to it? I assume that it should be done on my interface, in the Diagram tab > Target Database > Mapping Area > Implementation Tab > Expression Editor and modify it there, is it?
    As this is mapping from excel, can I just use the excel function? it does not make any sense for me as it is all in Oracle. I am sorry but I am kinda confused now.
    Once again I do really appreciate your help.

  • How to get a subset of text from a varchar2 field

    Hello.  I am trying to select a subset of text from a varchar2 field.  This is login information from dba_audit_trail view.  Here's an example of the field (comment_text from dba_audit_trail):
    Authenticated by: DIRECTORY PASSWORD;EXTERNAL NAME: cn=orcladmin,cn=Users,dc=idacorp,dc=local; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=555.555.555.555)(PORT=99999))
    I am trying to just select the "orcladmin" text - i.e. everything after the first "=" up to the first ","
    I can get everything after the first "=" with this:
    select substr(comment_text, instr(comment_text, '=') + 1) from dba_audit_trail
    ... but I don't know how to stop at the first ","
    Any help would be greatly appreciated.
    Thanks!
    Message was edited by: DRC

    Hi,
    Here's one way to do it:
    WITH got_pos    AS
        SELECT  comment_text    -- and whatever other columns you need
        ,       INSTR (cooment_text, '=')   AS equal_pos
        ,       INSTR (cooment_text, ',')   AS comma_pos
        FROM    dba_auit_trail
        WHERE   ...             -- any filtering goes here
    SELECT  SUBSTR ( comment_text
                   , equal_pos + 1
                   , comma_pos - (equal_pos + 1)
                   )   AS first_cn
    FROM    got_pos
    You could do it without a sub-query; you'd just have to do the exact same INSTR 2 times, where I used equal_pos 2 times.
    You could also get the results you want using regular expressions, such as:
    SELECT  REGEXP_SUBSTR ( comment_text
                          , '=([^,]*),'
                          , 1
                          , 1
                          , NULL
                          , 1
                          )      AS first_cn
    FROM    dba_audit_trail
    Although this uses less code, it's slower than using INSTR and SUBSTR .

  • Expression or Function as field in Object Type

    I am trying to use an expression or call a function as a return value for a field in an OBJECT TYPE.
    Here's the obj def:
    CREATE OR REPLACE TYPE OUTAGE_REPEAT_CALL_T2 AS OBJECT (
         INITCALL_TS      DATE,
         LASTCALL_TS      DATE,
         CALL_SRC      CHAR(8),
         ELAPSED_TIME     NUMBER,
         REP_ID           CHAR(8),
         CALL_CNT      NUMBER(3)
    The ELAPSED_TIME field should be the differnece in minutes from the LASTCALL_TS and SYSDATE...
    I'm not sure how to select into this OBJECT to get my result...
    Sample table and data:
    SQL> desc oms.outage_repeat_call
    Name Null? Type
    ACCT NOT NULL NUMBER(10)
    INITCALL_TS NOT NULL DATE
    LASTCALL_TS NOT NULL DATE
    CALL_CNT NOT NULL NUMBER(3)
    CALL_SRC NOT NULL CHAR(8)
    REP_ID NOT NULL CHAR(8)
    The ELAPSED_TIME is not part of the underlying table..
    sample data from tbl:
    ACCT INITCALL_ LASTCALL_ CALL_CNT CALL_SRC REP_ID
    123456 02-JAN-02 02-JAN-02 1 CBIS MJB2302
    I want to have this as a result:
    INITCALL_ LASTCALL_ CALL_SRC ELAPSED_TIME REP_ID CALL_CNT
    02-JAN-02 02-JAN-02 CBIS 9997 MJB2302 1
    But by doing a select from the OBJECT TYPE:
    i.e.
    SELECT OUTAGE_REPEAT_CALL_T2(     ORPC.INITCALL_TS,
                        ORPC.LASTCALL_TS,
    ORPC.CALL_SRC,
                        'expression or func' AS ELAPSED_TIME,
    ORPC.REP_ID,
    ORPC.CALL_CNT)
    FROM
    OMS.OUTAGE_REPEAT_CALL ORPC
    WHERE
    ORPC.ACCT=123456;
    I am using DBMS_XMLQUERY to eventually get this:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <INITCALL_TS>1/2/2002 12:45:0</INITCALL_TS>
    <LASTCALL_TS>1/2/2002 12:45:0</LASTCALL_TS>
    <CALL_SRC>CBIS </CALL_SRC>
    <ELAPSED_TIME>10009</ELAPSED_TIME>
    <REP_ID>MJB2302 </REP_ID>
    <CALL_CNT>1</CALL_CNT>
    </ROW>
    </ROWSET>
    Here's the real query... this OBJECT TYPE is embedded as an attribute of another OBJECT TYPE def.
              sQuery := 'SELECT '
                   || iNumAcct || ' AS NUMACCT,
                   SITE_T(S.ACCT,
                        S.SITE,
                        S.PHONE,
                        S.CUST_NM,
                        S.MED_IND,
                        S.MAC_IND,
                        S.HPP_IND,
                        S.STREET,
                        S.CITY,
                        S.STATE,
                        S.ZIP,
                        S.EUC,
                        S.STATUS,
                        S.AGR_TYP,
                        S.PRICE_SCHED,
                        S.OL_IND,
                        S.TRANS_IND,
                        S.CIRCUIT,
                        S.SUBSTATION,
                        S.OP_CENTER,
                        OUTAGE_STATUS_T(O.OUT_ID,
                             O.OUT_STATUS,
                             O.PO_DEV,
                             O.DEV_TYP,
                             O.CREW,
                             O.ETOR_TS,
                             O.TRBL_CD,
                             O.FIRST_RPT_TS,
                             O.END_TS,
                             O.CUST_CNT,
                             O.O_CALL_CNT,
                             OUTAGE_REPEAT_CALL_T(ORC.INITCALL_TS,
                                  ORC.LASTCALL_TS,
                                  ORC.CALL_SRC,
                                  ORC.REP_ID,
                                  ORC.CALL_CNT),
                             LIGHT_REPEAT_CALL_T(LRC.INITCALL_TS,
                                  LRC.LASTCALL_TS,
                                  LRC.CALL_SRC,
                                  LRC.REP_ID,
                                  LRC.CALL_CNT)
                             ) AS OUTCUST
                   FROM
                   OMS.SITE S,
                   OMS.OUTAGE O,
                   OMS.OUTAGE_REPEAT_CALL ORC,
                   OMS.LIGHT_REPEAT_CALL LRC,
                   OMS.OUTAGE_TRANSFORMER OT
                   WHERE
                   S.ACCT = ' || pi_acctNum || ' AND
                   S.TRNFRMR_ID = OT.TRNFRMR_ID(+) AND
                   OT.OUT_ID = O.OUT_ID(+) AND
                   S.ACCT = ORC.ACCT(+) AND                         
                   S.ACCT = LRC.ACCT(+)';
    I know this may sound confusing...but I apprecitate anyone's/everyone's suggestions!
    MJB
    DUKEPOWER CO.

    yes... here's the function that I also used as the expression...
    FUNCTION uf_minutesDiff(pi_beginDte IN VARCHAR2, pi_endDte IN VARCHAR2) RETURN NUMBER
    ||     FUNC name: uf_minutesDiff
    ||     purpose: this function accepts A BEGINNING DATE AND ENDING DATE AND
    ||               RETURNS THE DIFFERENCE IN MINUTES
    ||
    ||     date:     12/19/2001
    ||     author: Mark J Brooks
    ||
    ||     history:
    ||
    ||
    IS
         iMinutes     NUMBER;
    /*      LINE 280          */
    BEGIN
         select (to_date(pi_endDte,'DD-MON-YYYY:HH24:MI') -
              to_date(pi_beginDte,'DD-MON-YYYY:HH24:MI'))*24*60
              INTO iMinutes from dual;
         IF iMinutes = 0
         THEN
              iMinutes := 1;
         END IF;
         RETURN iMinutes;
    END uf_minutesDiff;
    I also just used:
    SQL> SELECT OUTAGE_REPEAT_CALL_T2( ORPC.INITCALL_TS,
    2 ORPC.LASTCALL_TS,
    3 ORPC.CALL_SRC,
    4 (ORPC.LASTCALL_TS - SYSDATE) AS ELAPSED_TIME,
    5 ORPC.REP_ID,
    6 ORPC.CALL_CNT)
    7 FROM
    8 OMS.OUTAGE_REPEAT_CALL ORPC
    9 WHERE
    10 ORPC.ACCT=123456;
    (ORPC.LASTCALL_TS - SYSDATE) AS ELAPSED_TIME,
    ERROR at line 4:
    ORA-00907: missing right parenthesis
    with and without the parens
    tx

  • PL/SQL ORA-00936 missing expression

    Hello all,
    I'm having an issues and need help with this script... Please help, thanks.
    error:
    ====
    31 32 /
    AST_UPDATED_BY,LAST_UPDATE_LOGIN) values(i,'ERROR_LOG_ID'||i, 'PROCEDURE_NAME'||i||, 'REQUEST_ID' |i||, 'PROCESS_NAME' ||i||, 'ERROR_TYPE'|i|, 'MESSAGE_DETAILS' ||i||, 'ERROR_TIMESTAMP' |i|, 'STATUS' ||i||, 'CREATED_BY' ||i||, 'CREATION_DATE' ||i||, "to_char(last_update_date, 'dd-Mon-yyyy hh:mi:ss')" |i|, 'LAST_UPDATED_BY' ||i||, 'LAST_UPDATE_LOGIN');
    ERROR at line 28:
    ORA-06550: line 28, column 84:
    PL/SQL: ORA-00936: missing expression
    ORA-06550: line 27, column 1:
    PL/SQL: SQL Statement ignored
    script.
    ====
    declare
    CURSOR c_iostats IS
    SELECT * from XXFRO.XXFRO_ERRORS;
    ERROR_LOG_ID NUMBER;
    PROCESS_NAME VARCHAR2(50);
    ERROR_TYPE VARCHAR2(20);
    STATUS VARCHAR2(20);
    MESSAGE_DETAILS VARCHAR2(2000);
    ERROR_LOG_ID NUMBER;
    PROCEDURE_NAME VARCHAR2(50);
    REQUEST_ID NUMBER;
    PROCESS_NAME VARCHAR2(50);
    ERROR_TYPE VARCHAR2(20);
    MESSAGE_DETAILS VARCHAR2(2000);
    ERROR_TIMESTAMP DATE;
    STATUS VARCHAR2(20);
    CREATED_BY NUMBER;
    CREATION_DATE DATE;
    LAST_UPDATE_DATE DATE;
    LAST_UPDATED_BY NUMBER;
    LAST_UPDATE_LOGIN NUMBER;
    Begin
    for i in 1..1000000 LOOP
    insert into IO_TEST(ERROR_LOG_ID
    ,PROCEDURE_NAME
    ,REQUEST_ID
    ,PROCESS_NAME
    ,ERROR_TYPE
    ,MESSAGE_DETAILS
    ,ERROR_TIMESTAMP
    ,STATUS,CREATED_BY
    ,CREATION_DATE
    ,LAST_UPDATE_DATE
    ,LAST_UPDATED_BY
    ,LAST_UPDATE_LOGIN)
    values(i,'ERROR_LOG_ID'||i, 'PROCEDURE_NAME'||i||, 'REQUEST_ID' |i||, 'PROCESS_NAME' ||i||, 'ERROR_TYPE'|i|, 'MESSAGE_DETAILS' ||i||, 'ERROR_TIMESTAMP' |i|, 'STATUS' ||i||, 'CREATED_BY' ||i||, 'CREATION_DATE' ||i||,'LAST_UPDATE_DATE' ||i||, 'LAST_UPDATED_BY' ||i||, 'LAST_UPDATE_LOGIN');
    END LOOP;
    end;
    Thanks,
    HCDBA

    Hi,
    Why are you using the concat(||) Symbol after i in the expression String 'CREATED_BY' ||i||. When you are padding between
    two text we use so.
    Ex: If you want to concat 'i' between String we use
    DBMS_OUTPUT.PUT_LINE('Five is between '|| i || 'and Six');The Insert Statement should be re-written as
    INSERT INTO io_test
                (error_log_id, procedure_name, request_id,
                 process_name, ERROR_TYPE, message_details,
                 error_timestamp, status, created_by,
                 creation_date, last_update_date,
                 last_updated_by, last_update_login
         VALUES (i, 'ERROR_LOG_ID' || i, 'PROCEDURE_NAME' || i,
                  'REQUEST_ID' || i, 'PROCESS_NAME' || i, 'ERROR_TYPE' || i,
                  'MESSAGE_DETAILS'
                  || i, 'ERROR_TIMESTAMP' || i, 'STATUS' || i,
                  'CREATED_BY' || i, 'CREATION_DATE' || i,
                  'LAST_UPDATE_DATE' || i, 'LAST_UPDATED_BY' || i,
                 'LAST_UPDATE_LOGIN'
                );Thanks,
    Shankar

  • Inserting values in a table from a view report in Application Express

    Hello.
    I have several tables with the sql bellow:
    Employee
    CREATE TABLE "Employee"
    (     "Employee_ID" NUMBER,
    "Name" VARCHAR2(12) CONSTRAINT "NAME_EMPLOYEE_NN" NOT NULL ENABLE,
    "Surname" VARCHAR2(10) CONSTRAINT "SURNAME_EMPLOYEE_NN" NOT NULL ENABLE,
    "Address" VARCHAR2(50) CONSTRAINT "ADDRESS_EMPLOYEE_NN" NOT NULL ENABLE,
    "Telephone" VARCHAR2(10),
    "Personal_ID_Number" VARCHAR2(13),
    "Date_of_Employment" VARCHAR2(10) CONSTRAINT "DATA_NN" NOT NULL ENABLE,
    "Salary" NUMBER(6,0),
    CONSTRAINT "Employee_ID_con" PRIMARY KEY ("Employee_ID") ENABLE,
    CONSTRAINT "Employee_CON" UNIQUE ("Personal_ID_Number", "Telephone") ENABLE
    Patient
    CREATE TABLE "PATIENT"
    (     "Patient_ID" NUMBER,
         "Name_Patient" VARCHAR2(13) CONSTRAINT "NAME_PAT_NN" NOT NULL ENABLE,
         "Surname_Patient" VARCHAR2(10) CONSTRAINT "SURNAME_PAT_NN" NOT NULL ENABLE,
         "ADSRESS_PATIENT" VARCHAR2(50),
         "TELEPHONE_PATIENT" VARCHAR2(10) CONSTRAINT "TEL_PAT_NN" NOT NULL ENABLE,
         "EMPLOYEE_ID" NUMBER CONSTRAINT "DENTIST_PAT_NN" NOT NULL DISABLE,
         CONSTRAINT "PK_PATIENT" PRIMARY KEY ("PATIENT_ID") ENABLE,
         CONSTRAINT "PACIENT_CON" UNIQUE ("TELEFON_PACIENT") ENABLE
    ALTER TABLE "PATIENT" ADD CONSTRAINT "PATIENT_CON3" FOREIGN KEY ("Employee_ID")
         REFERENCES "Dentist" ("Employee_ID") ON DELETE SET NULL ENABLE
    Appointment
    CREATE TABLE "Appointment"
    (     "Appointment_ID" NUMBER,
         "Employee_ID" NUMBER CONSTRAINT "NN_Dentist_Appointment" NOT NULL ENABLE,
         "Patient_ID" NUMBER CONSTRAINT "NN_PATIENT_Appointment" NOT NULL ENABLE,
         "Who_Made" NUMBER,
         "Who_Changed" NUMBER,
         "Who_Canceled" NUMBER,
         "Content" VARCHAR2(1000),
         "DATE" DATE,
         CONSTRAINT "PK_Appointment" PRIMARY KEY ("Appointment_ID") ENABLE
    ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_CON" FOREIGN KEY ("Patient_ID")
         REFERENCES "PATIENT" ("Patient_ID") ENABLE
    ALTER TABLE "Appointment" ADD FOREIGN KEY ("Employee_ID")
         REFERENCES "Dentist" ("Employee_ID") ENABLE
    ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Made")
         REFERENCES "Employee" ("Employee_ID") ENABLE
    ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Changed")
         REFERENCES "Employee" ("Employee_ID") ENABLE
    ALTER TABLE "Appointment" ADD FOREIGN KEY ("Who_Canceled")
         REFERENCES "Employee" ("Employee_ID") ENABLE
    Dentist
    CREATE TABLE "Dentist"
    (     "Employee_ID" NUMBER,
    "Qualifications" VARCHAR2(50),
    CONSTRAINT "RB_VRAB_STOMATOLOG_PK" PRIMARY KEY ("Employee_ID") ENABLE
    ALTER TABLE "Employee_ID" ADD CONSTRAINT "Dentist_CON" FOREIGN KEY ("Employee_ID")
    REFERENCES "Employee" ("Employee_ID") ON DELETE CASCADE ENABLE
    I'm trying to make an application in Oracle Application Express and I've tried making an SQL report using the following SQL query:
    CREATE OR REPLACE FORCE VIEW "Appointment_REPORT" ("DOCTOR", "PATIENT", "Content", "Date") AS
    select concat(concat(v.name,' '),v.surname) as doctor, concat(concat(pa.name_patient,' '),pa.surname_patient) as pactent, p.content, p.date
    from Appointment p, Amployee v, Patient pa
    where
    v.employee_id=p.employee_id
    and p.patient_id=pa.patient_id
    The SQL works fine and gives me lovely results in my report. However, I don't know how to link the SQL to my actual Appointment table. Deleting, updating or creating new appointments through this view is impossible because I get the following error Unexpected error, unable to find item name at application or page level.
    I understand how to make a form on the Appointment table but given how that table contains lots of primary keys (numbers) it's not preferable for the user to have to deal with that.
    Can I have some help with linking the two and making it functional?
    Thanks in advance.

    982909 wrote:
    Hello.
    I have several tables with the sql bellow:You are digging yourself a DEEP hole by using double quote marks & Mixed Case table & column names!
    >
    CREATE TABLE "Appointment"
    (     "Appointment_ID" NUMBER,
         "Employee_ID" NUMBER CONSTRAINT "NN_Dentist_Appointment" NOT NULL ENABLE,
         "Patient_ID" NUMBER CONSTRAINT "NN_PATIENT_Appointment" NOT NULL ENABLE,
         "Who_Made" NUMBER,
         "Who_Changed" NUMBER,
         "Who_Canceled" NUMBER,
         "Content" VARCHAR2(1000),
         "DATE" DATE,
    AVOID using Reserved Words like "DATE" as column or table names!
    >
    I'm trying to make an application in Oracle Application Express and I've tried making an SQL report using the following SQL query:
    CREATE OR REPLACE FORCE VIEW "Appointment_REPORT" ("DOCTOR", "PATIENT", "Content", "Date") AS
    select concat(concat(v.name,' '),v.surname) as doctor, concat(concat(pa.name_patient,' '),pa.surname_patient) as pactent, p.content, p.date
    from Appointment p, Amployee v, Patient pa
    where
    v.employee_id=p.employee_id
    and p.patient_id=pa.patient_id
    The SQL works fine and gives me lovely results in my report. However, I don't know how to link the SQL to my actual Appointment table. Deleting, updating or creating new appointments through this view is impossible because I get the following error Unexpected error, unable to find item name at application or page level.
    I understand how to make a form on the Appointment table but given how that table contains lots of primary keys (numbers) it's not preferable for the user to have to deal with that.
    Any table can have only ONE Primary Key.
    Can I have some help with linking the two and to which "two" do you refer?
    making it functional?Since you have told us what functionality is desired or expected,
    I don't know what might be a solution.

  • How can you SELECT via Database Link CLOB data using Application Express?

    Customer Issue:
    Developer using Oracle's Application Express 3.1. The Developer is trying to SELECT a CLOB datatype column from a remote (10.2.0.3) database, via a database link on her 10.2.0.4 based client Application. The Developer wants to be able to select CLOB data from the remote database which has limitation that she can't make any changes to the remote database.
    Developer's Comments:
    I do a select and get the error. Getting error ORA-22992: cannot use LOB locators selected from remote tables. So she feels she can't use dbms_lob.substr in this configuration I can do a "select into" but that is for one value. I am trying to run a select statement for a report that brings back more than one row. I do not have permission to change anything on the remote database. I want to access the remote database and multiple tables.
    This is not something I work with, would greatly appreciate help or ideas. Is this a limitation of the 3.1; or does she just not have this set up correctly; or should she be using a Collection (if yes, please share example)
    Thanks very much,
    Pam
    Edited by: pmoutrie on Jun 4, 2009 12:01 PM
    Hello???
    Would really appreciate an answer.
    Thanks,
    Pam

    This may not be a perfect solution for you but it worked for my situation.
    I wanted to grab some data from Grid Control's MGMT$JOB_STEP_HISTORY table but I couldnt' create an Interactive Report due to the existance of a CLOB column. I cheated this by creating a view on the GC DB, grabbing the first 4000 characters and turning it into a varchar2 column:
    create view test_job_step_history as
    select job_Name, target_name, status, start_time, end_time, to_char(substr(output,1,4000)) output
    from MGMT$JOB_STEP_HISTORY where trunc(end_time) > trunc(sysdate)-90
    In an APEX Interactive Report:
    select * from test_job_step_history@GCDB
    Granted, the output looks aweful right now but I am only looking for a very particular output (failed, denied, ORA-, RMAN-, etc) so the formatting isn't the most important thing to me right now.
    If anyone can improve -- and I'm sure you can -- on this I'd love to hear about it.
    Thanks,
    Rich

Maybe you are looking for

  • Regarding: material report

    Hi, I am making a report in ehihc i have to display the minimum,maximum,reorder point and stock level of a material . plzz tell me the tables where i can have these data as i want to display the cureent status of stock level . reagrds, ric.s Edited b

  • Configuring Apache httpd.conf for Multiple Web Servers

    After successfully serving a single web site from my MacMini, I'm having trouble configuring httpd.conf to add an additional site. My httpd.conf file looks something like this: NameVirtualHost *:80 <VirtualHost *:80> ServerName www.domain1.net Docume

  • Help with Loadmovie

    Hi! First, I would like you to forgive me for my poor English and thank the ones that will take time to understand my questions. I´m having a hard time to build a data base for a tire company Web site, but it's almost done. I'll do my best to explain

  • Overexposed image saved in new Camera Raw 7

    I took an image (Camera raw format)  that was shot of a colorful tree last year, but overexposed; the sky was white. I edited it with camera raw in Photoshop CS5  and, then, cleared the settings in the Bridge and did it with Photoshop CS6 and camera

  • Mac Mini Server running os X lion general help

    hi just wondered if anyone else was struggling to work out how to set up an os x mac mini server with lion server on it - with no obvious help system, manual etc. Can someone point me at any resources that might help as to be honest I am struggling w