Writing queries in ActionScript

i have a book whose author is Ben Forta.
i've looked for getting query results for ActionScript but I
don't understand it. It is a bit confuse.
in coldfusion there is no problem about getting query result,
writing query result. But, when i wanna to send my queries to
actionscript i encounter a problem: "undefined"
this is mycoldfusion code:
<cfquery name="get_content_for_flash"
datasource="#dsn#">
SELECT * FROM CONTENT WHERE CONTENT_ID = #attributes.cntid#
</cfquery>
<cfset FLASH.result = get_content_for_flash>
Actionscript code :
thisText = new LoadVars();
var record = result.getItemAt(0);
thisText.onLoad = function(success) {
if (success) {
TextHolder.text = record.CONT_BODY
what can i do?
help pls..

I don't know Coldfusion... but I'm guessing its being
returned as the result property of your LoadVars.
thisText = new LoadVars();
//var record = result.getItemAt(0);
thisText.onLoad = function(success) {
if (success) {
TextHolder.text = this.result

Similar Messages

  • Enabling Drill Down Buttons on queries

    Dear experts,
      I have been writing queries on SAP query manager but for  some reason the orange drill down button does not appear. At other times it appears on default, Is there a way to have this button appear especially on master data , documents or transactions as you would like ?

    Hi Martin,
    The orange arrow will be displayed on all document transaction and mastercodes having a unique Id generate by SAP. specially numbers link BP codes, Item codes.
    You could try using "FOR BROWSE" at the end of your query.
    To your Query please find the solution in the below link SAP Note.
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1410595]
    Regards,
    Rakesh N

  • Join/from/where/ combine queries 3

    hello my query below is not working for my cf application can
    you help?
    thanks
    this is my previous question so i tried to do it my self.
    tcase_req.tcase_req_id is added
    tcase.case_id=tcase_req.case_id :note that this is not part of the
    inner join in the from clause. it does not depend on the rest of
    the inner join.
    the reaon for this is that i need to get
    WHERE tcase_req.case_req_typ_cd = cwc and
    tcase_req.case_req_typ_cd = cwnc
    here is the original question
    Hello ,
    I need help again on the inner join/and conditions in the
    where clause
    I have these 2 tables tcase and tcase_req where there common
    field Is the case_id.
    tcase is the parent table and the tcase_req is the child
    table.
    (1)I wanted to add this to the from clause using the inner
    join table . what do I do and where do I put it
    (2)I then need to put a condition in the where clause to
    replace
    WHERE TCASE.CASE_NBR Like '%HPOZ%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
    by
    WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR Like
    '%CWNC%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
    Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
    is this efficient??
    thanks
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id,
    tcase_req.case_req_typ_cd
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE TCASE.CASE_NBR Like '%CWC%'and
    tcase.case_id=tcase_req.case_id
    (3)To a tcase_req
    Suffix_id are equal to = cwc and cwnc ( in the tcase_req
    table)(Suffix_id is the field that cintains the suffix cwc and cwnc
    for the tcase_req)
    also,
    this is the original query and it works fine
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR Like
    '%CWNC%')

    For guys like us that are not writing queries everyday you
    might try a query
    builder like the one MS Access has.
    "Coldfusionstudent" <[email protected]>
    wrote in message
    news:[email protected]...
    > hello my query below is not working for my cf
    application can you help?
    > thanks
    >
    >
    > this is my previous question so i tried to do it my
    self.
    >
    >
    > tcase_req.tcase_req_id is added
    tcase.case_id=tcase_req.case_id :note
    > that
    > this is not part of the inner join in the from clause.
    it does not depend
    > on
    > the rest of the inner join.
    >
    > the reaon for this is that i need to get
    > WHERE tcase_req.case_req_typ_cd = cwc and
    tcase_req.case_req_typ_cd =
    > cwnc
    >
    > here is the original question
    >
    > Hello ,
    > I need help again on the inner join/and conditions in
    the where clause
    >
    > I have these 2 tables tcase and tcase_req where there
    common field Is the
    > case_id.
    > tcase is the parent table and the tcase_req is the child
    table.
    >
    > (1)I wanted to add this to the from clause using the
    inner join table .
    > what
    > do I do and where do I put it
    >
    > (2)I then need to put a condition in the where clause to
    replace
    > WHERE TCASE.CASE_NBR Like '%HPOZ%'
    > AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
    > by
    > WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR
    Like '%CWNC%'
    > AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
    > Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
    >
    > is this efficient??
    >
    >
    >
    > thanks
    > --------------------
    >
    > SELECT TLA_PROP.PIN,
    > TLA_PROP.ASSR_PRCL_NBR,
    > TCASE.CASE_NBR,
    > TLA_PROP.STR_NBR,
    > TLA_PROP.STR_NBR_RNG_END,
    > TLA_PROP.STR_FRAC_NBR,
    > Tref_plan_area.plan_area_desc,
    > TLA_PROP.STR_FRAC_NBR_RNG_END,
    > TLA_PROP.STR_DIR_CD,
    > TLA_PROP.STR_NM,
    > TLA_PROP.STR_SFX_CD,
    > TLA_PROP.STR_SFX_DIR_CD,
    > TLA_PROP.STR_UNIT_TYP_CD,
    > TLA_PROP.UNIT_NBR,
    > TLA_PROP.UNIT_NBR_RNG_END,
    > TLA_PROP.ZIP_CD,
    > TLA_PROP.ZIP_CD_SFX,
    > TLA_PROP.CNCL_DIST_NBR,
    > TLA_PROP.PLAN_AREA_NBR,
    > TLA_PROP.ZONE_REG_CD,
    > TAPLC.PROJ_DESC_TXT,
    > TCASE.CASE_ID,
    > TCASE.CASE_NBR,
    > taplc.aplc_id,
    > tcase_req.case_req_typ_cd
    > FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr =
    > tref_plan_area.plan_area_NBR INNER JOIN TLOC ON
    TLA_PROP.PROP_ID =
    > TLOC.LOC_ID
    > INNER JOIN TAPLC ON TLOC.APLC_ID = TAPLC.APLC_ID INNER
    JOIN TCASE ON
    > TAPLC.APLC_ID = TCASE.APLC_ID
    > WHERE TCASE.CASE_NBR Like '%CWC%'and
    tcase.case_id=tcase_req.case_id
    >
    >
    >
    >
    > (3)To a tcase_req
    > Suffix_id are equal to = cwc and cwnc ( in the tcase_req
    table)(Suffix_id
    > is
    > the field that cintains the suffix cwc and cwnc for the
    tcase_req)
    >
    > also,
    > this is the original query and it works fine
    > SELECT TLA_PROP.PIN,
    > TLA_PROP.ASSR_PRCL_NBR,
    > TCASE.CASE_NBR,
    > TLA_PROP.STR_NBR,
    > TLA_PROP.STR_NBR_RNG_END,
    > TLA_PROP.STR_FRAC_NBR,
    > Tref_plan_area.plan_area_desc,
    > TLA_PROP.STR_FRAC_NBR_RNG_END,
    > TLA_PROP.STR_DIR_CD,
    > TLA_PROP.STR_NM,
    > TLA_PROP.STR_SFX_CD,
    > TLA_PROP.STR_SFX_DIR_CD,
    > TLA_PROP.STR_UNIT_TYP_CD,
    > TLA_PROP.UNIT_NBR,
    > TLA_PROP.UNIT_NBR_RNG_END,
    > TLA_PROP.ZIP_CD,
    > TLA_PROP.ZIP_CD_SFX,
    > TLA_PROP.CNCL_DIST_NBR,
    > TLA_PROP.PLAN_AREA_NBR,
    > TLA_PROP.ZONE_REG_CD,
    > TAPLC.PROJ_DESC_TXT,
    > TCASE.CASE_ID,
    > TCASE.CASE_NBR,
    > taplc.aplc_id
    > FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr =
    > tref_plan_area.plan_area_NBR INNER JOIN TLOC ON
    TLA_PROP.PROP_ID =
    > TLOC.LOC_ID
    > INNER JOIN TAPLC ON TLOC.APLC_ID = TAPLC.APLC_ID INNER
    JOIN TCASE ON
    > TAPLC.APLC_ID = TCASE.APLC_ID
    > WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR
    Like '%CWNC%')
    >

  • Front end and back end questions

    Hi,
    If I want to develop a web base SOA application by using Jcaps, I have several question want to ask.
    1.) In the front end, if i create the page by using eVision to create the page
    flow and the page layout, how can I match the fields of the page (such
    as the username, email, tel no... with the back end web services?
    2.) Does the flow of the front end web pages are control by the page flow in
    eVision? When will the eVision supported AJAX or JSF?
    3.) What is the use of the eInsight Business process manager, does it
    control all the back end flow, such as the flow of each web services?
    Does Jcaps has the Bpel engine to control the flow of web services?
    4.) I know that in JBoss, there is a jBPM server to control the flow of the front
    end pages, does JCAPS has this kind of server?
    5.) If i want to connect to the Database? I know that there is a eTL to extract
    the data from the database, it is true? Or do u recommend to connect the
    database directly through the web services by using JDBC or other
    framework as well?
    6.) If I have an existing application that is developed by .Net (With no web
    services). How can i integrate with other systems? What can I do in order
    to reuse the system? Or what Jcaps can do in this manner?
    Thanks for you reply! ^ ^

    Generally, back-end would consist of the taks associated with configuration of data targets (ODS, Cubes), working with extractors, mapping data to the data targets, writing transfer/start rtn/update rules, and creating Infopkgs/ Process Chains.
    Front-end deals with the use of the BW - writing queries, workbooks, web (although I think some of the infrastructure aspects of web reporting. e.g. javascript/templates might really could be considered backend).  Think of Front-end as all of the client/customer/user facing components.

  • One table or many?

    I'm just starting to re-write a web app and looking at the
    database one of the tables is getting quite large (field wise)
    The table in question is for room attributes but is used in 3
    different apps. It's not particularly large in either direction and
    isn't high demand on records so I suspect the overall answer to
    this is in this case it doesn't matter but I'd be interested in
    people's thoughts.
    Do i have one large table with approx 90 fields which has
    less query load as I'm not joining tables so much or do i have 3
    tables (one for the basic room details (5-10 fields) one with the
    equipment in the room (30 fields) etc. which would need joining
    each time I used them but would be easier for writing queries as
    select * would be appropriate most of the time and would arguably
    be easier to maintain and modify (for both db and queries)?
    The floor is now open!

    Wow, hard to answer. What about your data model? Do you have
    data in your table that is not normalized? Single table
    "spreadsheet-like" database tables are an indicator of a missing or
    inadequate data model and design. However, it is almost impossible
    to know for sure without knowing the nature of your data, how your
    entities relate, and what attributes are associated with these
    entities, etc.
    Phil

  • MultiProvider report not functioning - overwriting protected field

    Hello,
    I have a multiprovider that combines data from the Sales Overview cube (0SD_C03) with a custom plan cube (data from COPA and SIS).  In writing queries off of the (active) multiprovider, short dumps occur except when only running against one infoprovider.  In other words, if the query is restricted to only show Sales data (0SD_C03), it works fine.  If the query is restricted to only show Plan data (custom plan cube), then it works fine.  However, the intersection of the two does not work - which is the entire functionality of the multiprovider (a join). 
    I've cut the query back to the very basics:  Fiscal Year and one Key Figure (that is present in both source infocubes).   Without specifying or splitting out the InfoProviders, it should combine the data (total the two), but instead creates a short dump.  Using a structure to split Actuals from Plan also results the short dump.  The only way to get the report to actually execute and return is to restrict it to just one InfoProvider.  I tried copying the MultiProvider and starting over, but that did not improve the situation.  The failure occurs after the variable screen has been filled in.  (Also tried w/out variables.)
    Using LISTCUBE, the data is found in a single execution (no filter applied to 0INFOPROV) and splits out to the two infoproviders w/ approp. fiscal year and Key Figure totals.  So there seems to be something at the reporting layer malfunctioning.
    Here's the ST22 short dump:
    Does anyone have any ideas?
    Runtime Error          MOVE_TO_LIT_NOTALLOWED_NODATA                                         
    Date and Time          07/17/2006 09:57:23                                                   
    ShrtText                                                                               
    Assignment error: Overwriting a protected field.                                        
    What happened?                                                                               
    Error in ABAP application program.                                                                               
    The current ABAP program "SAPLRSDRC" had to be terminated because one of the            
    statements could not be executed.                                                       
    This is probably due to an error in the ABAP program.
    rror analysis                                                                               
    The program tried to assign a new value to the field "<L_SX_OLAPQUERY>" even though it is protected against changes.                                                                               
    The following objects are protected:                                                       
       - Character or numeric literals                                                            
       - Constants (CONSTANTS)                                                                    
       - Parameters of the category IMPORTING REFERENCE for functions                             
         and methods                                                                               
    - Untyped field symbols to which a field has not yet been assigned                         
         using ASSIGN                                                                               
    - TABLES parameters if the corresponding actual parameter is protected                     
         against changes                                                                          
       - USING reference parameters and CHANGING parameters for FORMs if                          
         the actual parameter for this is protected against changes                               
       - Field symbols if the field assigned using ASSIGN or ASSIGNING                            
         is protected against changes                                                             
       - External write accesses to READ-ONLY attributes                                          
       - Key components of lines in internal tables of the type HASHED or                         
         SORTED TABLE                                                                               
    SORTED TABLE.    
    Message received in web report when failure occurs:
    Error when processing your request 
    Note
    The following error text was processed in the system BW1 : Assignment error: Overwriting a protected field.
    The error occurred on the application server bw_BW1_00 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Function: RSDRC_CUBE_DATA_GET_DISP of program SAPLRSDRC
    Function: RSDRC_MULTI_CUBE_DATA_GET_PARA of program SAPLRSDRC
    Function: RSDRC_MULTI_CUBE_DATA_GET of program SAPLRSDRC
    Form: DATA_GET of program SAPLRSDRC
    Function: RSDRC_CUBE_DATA_GET of program SAPLRSDRC
    Function: RSDRC_CUBE_DATA_GET_OLAP of program SAPLRSDRC
    Form: FILL_SP_1 of program SAPSRRK0
    Form: FILL_SP of program GP42GWU130B57UDR97PLRZOUC5Z
    Form: DATEN_LESEN of program SAPLRRK0
    Function: RRK_LIST_NOTIFY of program SAPLRRK0
    Thanks in advance!

    Hello
    Check OSS notes as below am not sure if it helps
    957439 - Query dumps with an error
    Below is for 3.5 and below ,just to let you know that there were similar problems in earlier version.
    941862 - *** Dump MOVE_TO_LIT_NOTALLOWED_NODATA with MultiProvider
    Chetan
    @CP..

  • PL/SQL 101 : Cursors and SQL Projection

    PL/SQL 101 : Cursors and SQL Projection
    This is not a question, it's a forum article, in reponse to the number of questions we get regarding a "dynamic number of columns" or "rows to columns"
    There are two integral parts to an SQL Select statement that relate to what data is selected. One is Projection and the other is Selection:-
    Selection is the one that we always recognise and use as it forms the WHERE clause of the select statement, and hence selects which rows of data are queried.
    The other, SQL Projection is the one that is less understood, and the one that this article will help to explain.
    In short, SQL Projection is the collective name for the columns that are Selected and returned from a query.
    So what? Big deal eh? Why do we need to know this?
    The reason for knowing this is that many people are not aware of when SQL projection comes into play when you issue a select statement. So let's take a basic query...
    First create some test data...
    create table proj_test as
      select 1 as id, 1 as rn, 'Fred' as nm from dual union all
      select 1,2,'Bloggs' from dual union all
      select 2,1,'Scott' from dual union all
      select 2,2,'Smith' from dual union all
      select 3,1,'Jim' from dual union all
      select 3,2,'Jones' from dual
    ... and now query that data...
    SQL> select * from proj_test;
             ID         RN NM
             1          1 Fred
             1          2 Bloggs
             2          1 Scott
             2          2 Smith
             3          1 Jim
             3          2 Jones
    6 rows selected.
    OK, so what is that query actually doing?
    To know that we need to consider that all queries are cursors and all cursors are processed in a set manner, roughly speaking...
    1. The cursor is opened
    2. The query is parsed
    3. The query is described to know the projection (what columns are going to be returned, names, datatypes etc.)
    4. Bind variables are bound in
    5. The query is executed to apply the selection and identify the data to be retrieved
    6. A row of data is fetched
    7. The data values from the columns within that row are extracted into the known projection
    8. Step 6 and 7 are repeated until there is no more data or another condition ceases the fetching
    9. The cursor is closed
    The purpose of the projection being determined is so that the internal processing of the cursor can allocate memory etc. ready to fetch the data into. We won't get to see that memory allocation happening easily, but we can see the same query being executed in these steps if we do it programatically using the dbms_sql package...
    CREATE OR REPLACE PROCEDURE process_cursor (p_query in varchar2) IS
      v_sql       varchar2(32767) := p_query;
      v_cursor    number;            -- A cursor is a handle (numeric identifier) to the query
      col_cnt     integer;
      v_n_val     number;            -- numeric type to fetch data into
      v_v_val     varchar2(20);      -- varchar type to fetch data into
      v_d_val     date;              -- date type to fetch data into
      rec_tab     dbms_sql.desc_tab; -- table structure to hold sql projection info
      dummy       number;
      v_ret       number;            -- number of rows returned
      v_finaltxt  varchar2(100);
      col_num     number;
    BEGIN
      -- 1. Open the cursor
      dbms_output.put_line('1 - Opening Cursor');
      v_cursor := dbms_sql.open_cursor;
      -- 2. Parse the cursor
      dbms_output.put_line('2 - Parsing the query');
      dbms_sql.parse(v_cursor, v_sql, dbms_sql.NATIVE);
      -- 3. Describe the query
      -- Note: The query has been described internally when it was parsed, but we can look at
      --       that description...
      -- Fetch the description into a structure we can read, returning the count of columns that has been projected
      dbms_output.put_line('3 - Describing the query');
      dbms_sql.describe_columns(v_cursor, col_cnt, rec_tab);
      -- Use that description to define local datatypes into which we want to fetch our values
      -- Note: This only defines the types, it doesn't fetch any data and whilst we can also
      --       determine the size of the columns we'll just use some fixed sizes for this example
      dbms_output.put_line(chr(10)||'3a - SQL Projection:-');
      for j in 1..col_cnt
      loop
        v_finaltxt := 'Column Name: '||rpad(upper(rec_tab(j).col_name),30,' ');
        case rec_tab(j).col_type
          -- if the type of column is varchar2, bind that to our varchar2 variable
          when 1 then
            dbms_sql.define_column(v_cursor,j,v_v_val,20);
            v_finaltxt := v_finaltxt||' Datatype: Varchar2';
          -- if the type of the column is number, bind that to our number variable
          when 2 then
            dbms_sql.define_column(v_cursor,j,v_n_val);
            v_finaltxt := v_finaltxt||' Datatype: Number';
          -- if the type of the column is date, bind that to our date variable
          when 12 then
            dbms_sql.define_column(v_cursor,j,v_d_val);
            v_finaltxt := v_finaltxt||' Datatype: Date';
          -- ...Other types can be added as necessary...
        else
          -- All other types we'll assume are varchar2 compatible (implicitly converted)
          dbms_sql.DEFINE_COLUMN(v_cursor,j,v_v_val,2000);
          v_finaltxt := v_finaltxt||' Datatype: Varchar2 (implicit)';
        end case;
        dbms_output.put_line(v_finaltxt);
      end loop;
      -- 4. Bind variables
      dbms_output.put_line(chr(10)||'4 - Binding in values');
      null; -- we have no values to bind in for our test
      -- 5. Execute the query to make it identify the data on the database (Selection)
      -- Note: This doesn't fetch any data, it just identifies what data is required.
      dbms_output.put_line('5 - Executing the query');
      dummy := dbms_sql.execute(v_cursor);
      -- 6.,7.,8. Fetch the rows of data...
      dbms_output.put_line(chr(10)||'6,7 and 8 Fetching Data:-');
      loop
        -- 6. Fetch next row of data
        v_ret := dbms_sql.fetch_rows(v_cursor);
        -- If the fetch returned no row then exit the loop
        exit when v_ret = 0;
        -- 7. Extract the values from the row
        v_finaltxt := null;
        -- loop through each of the Projected columns
        for j in 1..col_cnt
        loop
          case rec_tab(j).col_type
            -- if it's a varchar2 column
            when 1 then
              -- read the value into our varchar2 variable
              dbms_sql.column_value(v_cursor,j,v_v_val);
              v_finaltxt := ltrim(v_finaltxt||','||rpad(v_v_val,20,' '),',');
            -- if it's a number column
            when 2 then
              -- read the value into our number variable
              dbms_sql.column_value(v_cursor,j,v_n_val);
              v_finaltxt := ltrim(v_finaltxt||','||to_char(v_n_val,'fm999999'),',');
            -- if it's a date column
            when 12 then
              -- read the value into our date variable
              dbms_sql.column_value(v_cursor,j,v_d_val);
              v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          else
            -- read the value into our varchar2 variable (assumes it can be implicitly converted)
            dbms_sql.column_value(v_cursor,j,v_v_val);
            v_finaltxt := ltrim(v_finaltxt||',"'||rpad(v_v_val,20,' ')||'"',',');
          end case;
        end loop;
        dbms_output.put_line(v_finaltxt);
        -- 8. Loop to fetch next row
      end loop;
      -- 9. Close the cursor
      dbms_output.put_line(chr(10)||'9 - Closing the cursor');
      dbms_sql.close_cursor(v_cursor);
    END;
    SQL> exec process_cursor('select * from proj_test');
    1 - Opening Cursor
    2 - Parsing the query
    3 - Describing the query
    3a - SQL Projection:-
    Column Name: ID                             Datatype: Number
    Column Name: RN                             Datatype: Number
    Column Name: NM                             Datatype: Varchar2
    4 - Binding in values
    5 - Executing the query
    6,7 and 8 Fetching Data:-
    1     ,1     ,Fred
    1     ,2     ,Bloggs
    2     ,1     ,Scott
    2     ,2     ,Smith
    3     ,1     ,Jim
    3     ,2     ,Jones
    1     ,3     ,Freddy
    1     ,4     ,Fud
    9 - Closing the cursor
    PL/SQL procedure successfully completed.
    So, what's really the point in knowing when SQL Projection occurs in a query?
    Well, we get many questions asking "How do I convert rows to columns?" (otherwise known as a pivot) or questions like "How can I get the data back from a dynamic query with different columns?"
    Let's look at a regular pivot. We would normally do something like...
    SQL> select id
      2        ,max(decode(rn,1,nm)) as nm_1
      3        ,max(decode(rn,2,nm)) as nm_2
      4  from proj_test
      5  group by id
      6  /
            ID NM_1   NM_2
             1 Fred   Bloggs
             2 Scott  Smith
             3 Jim    Jones
    (or, in 11g, use the new PIVOT statement)
    but many of these questioners don't understand it when they say their issue is that, they have an unknown number of rows and don't know how many columns it will have, and they are told that you can't do that in a single SQL statement. e.g.
    SQL> insert into proj_test (id, rn, nm) values (1,3,'Freddy');
    1 row created.
    SQL> select id
      2        ,max(decode(rn,1,nm)) as nm_1
      3        ,max(decode(rn,2,nm)) as nm_2
      4  from proj_test
      5  group by id
      6  /
            ID NM_1   NM_2
             1 Fred   Bloggs
             2 Scott  Smith
             3 Jim    Jones
    ... it's not giving us this 3rd entry as a new column and we can only get that by writing the expected columns into the query, but then what if more columns are added after that etc.
    If we look back at the steps of a cursor we see again that the description and projection of what columns are returned by a query happens before any data is fetched back.
    Because of this, it's not possible to have the query return back a number of columns that are based on the data itself, as no data has been fetched at the point the projection is required.
    So, what is the answer to getting an unknown number of columns in the output?
    1) The most obvious answer is, don't use SQL to try and pivot your data. Pivoting of data is more of a reporting requirement and most reporting tools include the ability to pivot data either as part of the initial report generation or on-the-fly at the users request. The main point about using the reporting tools is that they query the data first and then the pivoting is simply a case of manipulating the display of those results, which can be dynamically determined by the reporting tool based on what data there is.
    2) The other answer is to write dynamic SQL. Because you're not going to know the number of columns, this isn't just a simple case of building up a SQL query as a string and passing it to the EXECUTE IMMEDIATE command within PL/SQL, because you won't have a suitable structure to read the results back into as those structures must have a known number of variables for each of the columns at design time, before the data is know. As such, inside PL/SQL code, you would have to use the DBMS_SQL package, just like in the code above that showed the workings of a cursor, as the columns there are referenced by position rather than name, and you have to deal with each column seperately. What you do with each column is up to you... store them in an array/collection, process them as you get them, or whatever. They key thing though with doing this is that, just like the reporting tools, you would need to process the data first to determine what your SQL projection is, before you execute the query to fetch the data in the format you want e.g.
    create or replace procedure dyn_pivot is
      v_sql varchar2(32767);
      -- cursor to find out the maximum number of projected columns required
      -- by looking at the data
      cursor cur_proj_test is
        select distinct rn
        from   proj_test
        order by rn;
    begin
      v_sql := 'select id';
      for i in cur_proj_test
      loop
        -- dynamically add to the projection for the query
        v_sql := v_sql||',max(decode(rn,'||i.rn||',nm)) as nm_'||i.rn;
      end loop;
      v_sql := v_sql||' from proj_test group by id order by id';
      dbms_output.put_line('Dynamic SQL Statement:-'||chr(10)||v_sql||chr(10)||chr(10));
      -- call our DBMS_SQL procedure to process the query with it's dynamic projection
      process_cursor(v_sql);
    end;
    SQL> exec dyn_pivot;
    Dynamic SQL Statement:-
    select id,max(decode(rn,1,nm)) as nm_1,max(decode(rn,2,nm)) as nm_2,max(decode(rn,3,nm)) as nm_3 from proj_test group by id order by id
    1 - Opening Cursor
    2 - Parsing the query
    3 - Describing the query
    3a - SQL Projection:-
    Column Name: ID                             Datatype: Number
    Column Name: NM_1                           Datatype: Varchar2
    Column Name: NM_2                           Datatype: Varchar2
    Column Name: NM_3                           Datatype: Varchar2
    4 - Binding in values
    5 - Executing the query
    6,7 and 8 Fetching Data:-
    1     ,Fred                ,Bloggs              ,Freddy
    2     ,Scott               ,Smith               ,
    3     ,Jim                 ,Jones               ,
    9 - Closing the cursor
    PL/SQL procedure successfully completed.
    ... and if more data is added ...
    SQL> insert into proj_test (id, rn, nm) values (1,4,'Fud');
    1 row created.
    SQL> exec dyn_pivot;
    Dynamic SQL Statement:-
    select id,max(decode(rn,1,nm)) as nm_1,max(decode(rn,2,nm)) as nm_2,max(decode(rn,3,nm)) as nm_3,max(decode(rn,4,nm)) as nm_4 from proj_test group by id order by id
    1 - Opening Cursor
    2 - Parsing the query
    3 - Describing the query
    3a - SQL Projection:-
    Column Name: ID                             Datatype: Number
    Column Name: NM_1                           Datatype: Varchar2
    Column Name: NM_2                           Datatype: Varchar2
    Column Name: NM_3                           Datatype: Varchar2
    Column Name: NM_4                           Datatype: Varchar2
    4 - Binding in values
    5 - Executing the query
    6,7 and 8 Fetching Data:-
    1     ,Fred                ,Bloggs              ,Freddy              ,Fud
    2     ,Scott               ,Smith               ,                    ,
    3     ,Jim                 ,Jones               ,                    ,
    9 - Closing the cursor
    PL/SQL procedure successfully completed.
    Of course there are other methods, using dynamically generated scripts etc. (see Re: 4. How do I convert rows to columns?), but the above simply demonstrates that:-
    a) having a dynamic projection requires two passes of the data; one to dynamically generate the query and another to actually query the data,
    b) it is not a good idea in most cases as it requires code to handle the results dynamically rather than being able to simply query directly into a known structure or variables, and
    c) a simple SQL statement cannot have a dynamic projection.
    Most importantly, dynamic queries prevent validation of your queries at the time your code is compiled, so the compiler can't check that the column names are correct or the tables names, or that the actual syntax of the generated query is correct. This only happens at run-time, and depending upon the complexity of your dynamic query, some problems may only be experienced under certain conditions. In effect you are writing queries that are harder to validate and could potentially have bugs in them that would are not apparent until they get to a run time environment. Dynamic queries can also introduce the possibility of SQL injection (a potential security risk), especially if a user is supplying a string value into the query from an interface.
    To summarise:-
    The projection of an SQL statement must be known by the SQL engine before any data is fetched, so don't expect SQL to magically create columns on-the-fly based on the data it's retrieving back; and, if you find yourself thinking of using dynamic SQL to get around it, just take a step back and see if what you are trying to achieve may be better done elsewhere, such as in a reporting tool or the user interface.
    Other articles in the PL/SQL 101 series:-
    PL/SQL 101 : Understanding Ref Cursors
    PL/SQL 101 : Exception Handling

    excellent article. However there is one thing which is slightly erroneous. You don't need a type to be declared in the database to fetch the data, but you do need to declare a type;
    here is one of my unit test scripts that does just that.
    DECLARE
    PN_CARDAPPL_ID NUMBER;
    v_Return Cci_Standard.ref_cursor;
    type getcardapplattrval_recordtype
    Is record
    (cardappl_id ci_cardapplattrvalue.cardappl_ID%TYPE,
    tag ci_cardapplattrvalue.tag%TYPE,
    value ci_cardapplattrvalue.value%TYPE
    getcardapplattrvalue_record getcardapplattrval_recordtype;
    BEGIN
    PN_CARDAPPL_ID := 1; --value must be supplied
    v_Return := CCI_GETCUSTCARD.GETCARDAPPLATTRVALUE(
    PN_CARDAPPL_ID => PN_CARDAPPL_ID
    loop
    fetch v_return
    into getcardapplattrvalue_record;
    dbms_output.put_line('Cardappl_id=>'||getcardapplattrvalue_record.cardappl_id);
    dbms_output.put_line('Tag =>'||getcardapplattrvalue_record.tag);
    dbms_output.put_line('Value =>'||getcardapplattrvalue_record.value);
    exit when v_Return%NOTFOUND;
    end loop;
    END;

  • How can I allow users to access SQLPLUS?

    Hi everyone,
    I have been charged with the task of creating an Oracle server on a CentOS VM. Installation and configuration is complete and SQL is working fine for the database admin user "oracle." I copied the environment variables to the .bashrc file for "oracle" and SQLPLUS starts without a hitch.
    Here is where I need a little guidance...
    I need to create basic Linux user accounts that will have access to the database, so they can then in turn log into their SQLPLUS accounts. The problem is, all of the database files and software are in located in the user "oracle's" directory. This means that no one but "oracle" and root have access to these files because they are the only ones with proper permissions.
    Before I put a ton of time into this, I thought I would pose these questions to the Oracle Linux community:
    1) Could I enable a specific Linux group (ex. "Oracle Users") to have access to the main database folder or possibly all folders along the path? I am hoping this would allow any users I put in the group access to the folders, and essentially the SQLPLUS application. (here is ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
    2) If that is not an option, will I need to make a completely new database and locate it in a location that all users can access?
    I understand that my first idea may not be the SAFEST method, but this is only for a small class of students learning how to use SQL and writing queries. There will be no sensitive information at risk. This would be a quick fix until I learned more about Oracle and how to use it.
    Thank you everyone.

    It certainly is rather a question for the General Database forum, though I doubt you will get a lot of happy replies for such a basic question.
    You can use / as sysdba OS authentication through SSH or using the server console, provided the user's account belongs to the "dba" user group. For remote connection through sqlnet you need create a $ORACLE_HOME/dbs/orapw$SID password file.
    If you would like to know more about this:
    Connecting / as sysdba is used for OS authentication. It ignores password credentials stored in the database and allows any user belonging to the OSDBA system group to connect to the database. Connections as sysdba will always connect to the SYS schema of the database, regardless of any username or password specified. Using OS authentication relies on the BEQ protocol, which connects to the database directly, without using the Oracle Listener process.
    The "oinstall" group will give access to the database software repository. There could be different oracle home installations, each with a different oracle user/owner like "oracle_prod1" and "oracle_prod2", but both users must be able to read/write the shared oraInventory, in which case both users must have read and write access to the oraInventory directory, hence the oinstall group.

  • Add data item from a table to another table

    I have two tables,  "Model" and "Colour". Fields of Model are "Id", "ModelId" and "ModelName" and fields of Colour are "Id", "ColourId" and "ColourName". These two tables
    have one to many relationship. A model must have a colour. One Colour can have many Models.
    Say "A" is ColourId with a ColourName "black". An example of ModelId would be "101A", 101 is just model code and A refer to ColourId. ModelId cannot be computed property because that's the value user gonna enter.
    What I'm asking is how do I split the ColourId from ModelId and query the related colour item and add it to a record of Model.

    For advanced query issue, this will be good start.
    Advanced LightSwitch: Writing Queries in LightSwitch Code

  • Front end and Back end experience in SAP BW

    Hi Friends...
         Can ne1 plz explain wht things in SAP BW come under Front end and Back end experience......Thanks in advance

    Generally, back-end would consist of the taks associated with configuration of data targets (ODS, Cubes), working with extractors, mapping data to the data targets, writing transfer/start rtn/update rules, and creating Infopkgs/ Process Chains.
    Front-end deals with the use of the BW - writing queries, workbooks, web (although I think some of the infrastructure aspects of web reporting. e.g. javascript/templates might really could be considered backend).  Think of Front-end as all of the client/customer/user facing components.

  • Problem with populating a fact table from dimension tables

    my aim is there are 5 dimensional tables that are created
    Student->s_id primary key,upn(unique pupil no),name
    Grade->g_id primary key,grade,exam_level,values
    Subject->sb_id primary key,subjectid,subname
    School->sc_id primary key,schoolno,school_name
    year->y_id primary key,year(like 2008)
    s_id,g_id,sb_id,sc_id,y_id are sequences
    select * from student;
    S_ID UPN FNAME COMMONNAME GENDER DOB
    ==============================
    9062 1027 MELISSA ANNE       f  13-OCT-81
    9000 rows selected
    select * from grade;
          G_ID GRADE      E_LEVEL         VALUE
            73 A          a                 120
            74 B          a                 100
            75 C          a                  80
            76 D          a                  60
            77 E          a                  40
            78 F          a                  20
            79 U          a                   0
            80 X          a                   0
    18 rows selectedThese are basically the dimensional views
    Now according to the specification given, need to create a fact table as facts_table which contains all the dim tables primary keys as foreign keys in it.
    The problem is when i say,I am going to consider a smaller example than the actual no of dimension tables 5 lets say there are 2 dim tables student,grade with s_id,g_id as p key.
    create materialized view facts_table(s_id,g_id)
    as
    select  s.s_id,g.g_id
    from   (select distinct s_id from student)s
    ,         (select distinct g_id from grade)gThis results in massive duplication as there is no join between the two tables.But basically there are no common things between the two tables to join,how to solve it?
    Consider it when i do it for 5 tables the amount of duplication being involved, thats why there is not enough tablespace.
    I was hoping if there is no other way then create a fact table with just one column initially
    create materialized view facts_table(s_id)
    as
    select s_id
    from student;then
    alter materialized view facts_table add column g_id number;Then populate this g_id column by fetching all the g_id values from the grade table using some sort of loop even though we should not use pl/sql i dont know if this works?
    Any suggestions.

    Basically your quite right to say that without any logical common columns between the dimension tables it will produce results that every student studied every sibject and got every grade and its very rubbish,
    I am confused at to whether the dimension tables can contain duplicated columns i.e column like upn(unique pupil no) i will also copy in another table so that when writing queries a join can be placed. i dont know whether thats right
    These are the required queries from the star schema
    Design a conformed star schema which will support the following queries:
    a. For each year give the actual number of students entered for at A-level in the whole country / in each LEA / in each school.
    b. For each A-level subject, and for each year, give the percentage of students who gained each grade.
    c. For the most recent 3 years, show the 5 most popular A-level subjects in that year over the whole country (measure popularity as the number of entries for that subject as a percentage of the total number of exam entries).
    I written the queries earlier based on dimesnion tables which were highly duplicated they were like
    student
    =======
    upn
    school
    school
    ======
    school(this column substr gives lea,school and the whole is country)
    id(id of school)
    student_group
    =============
    upn(unique pupil no)
    gid(group id)
    grade
    year_col
    ========
    year
    sid(subject id)
    gid(group id)
    exam_level
    id(school id)
    grades_list
    ===========
    exam_level
    grade
    value
    subject
    ========
    sid
    subject
    compulsory
    These were the dimension table si created earlier and as you can see many columns are duplicated in other tables like upn and this structure effectively gets the data out of the schema as there are common column upon which we can link
    But a collegue suggested that these dimension tables are wrong and they should not be this way and should not contain dupliated columns.
    select      distinct count(s.upn) as st_count
    ,     y.year
    ,     c.sn
    from      student_info s
    ,     student_group sg
    ,     year_col y
    ,     subject sb
    ,     grades_list g
    ,     country c
    where      s.upn=sg.upn
    and     sb.sid=y.sid
    and     sg.gid=y.gid
    and     c.id=y.id
    and     c.id=s.school
    and      y.exam_lev=g.exam_level
    and      g.exam_level='a'
    group by y.year,c.sn
    order by y.year;This is the code for the 1st query
    I am confused now which structure is right.Are my earlier dimension tables which i am describing here or the new dimension tables which i explained above are right.
    If what i am describing now is right i mean the dimension tables and the columns are allright then i just need to create a fact table with foreign keys of all the dimension tables.

  • Someone please help me Design the database of bill of materials

    I want to design the database of bill of materials which contain item and amount.
    So the amount of child will depend on amount of parent in term of ratio. For example
    A(1)               A(2)
    |         ---->     |
    B(2)               B(4)
    My problem is when i try to add the parent and child . Let A is the parent of B , If i try to add A to be the child of C
    I want B to come along with A as well. For example
    A                       C
    |     C  --->        |           For this I have to store the relation of all item in  my list to check that this item have a child or not if yes
    B                             A              The child must come along with its parent , What the Er-diagram
    should be for all of my requirement?
                                    |
                                    B

    >I want B to come along with A as well. For example
    You can do that, but that is not automatic. You need to do some programming.
    It is better to use hierarchyid representation of the tree over traditional FK referencing.
    Tree using hierarchyid example:
    http://www.sqlusa.com/bestpractices2008/orgchart/
    BOL: "Model Your Data Hierarchies With SQL Server 2008
    .....The manufacturing system behind automobiles; the organization of a country into states, counties, cities, and postal codes; the description of a home entertainment system—what do these things have in common? The simple answer is that each
    describes a hierarchy.
    SQL Server 2008 supports a new data type, HierarchyID, that helps solve some of the problems in modeling and querying hier­archical information. I will introduce you to this data type by discussing a pattern commonly used in manufacturing
    known as bill of materials (BOM), or bills. Starting with a brief discussion of BOMs, I will illustrate how this kind of data can be modeled. I will also present an implementation of this model in SQL Server 2005. Then I will show you how the HierarchyID data
    type can be used to implement the model in SQL Server 2008.
    Hierarchical Data
    Automobiles are amalgamations of many components, such as engines, drivetrains, electronics, and steering. In the United States, our geographic territories are divided into states and are then sub-divided into jurisdictions called counties.
    Counties are then further subdivided in different ways by different agencies. The United States Census Bureau, for example, composes them from Census Tract Areas. The U.S. Postal Service routes mail delivery by Zone Improvement Plan (ZIP) codes. Geographic
    information systems (GIS) may aggregate census tracts and ZIP codes together to provide users with a familiar spatial reference for an area.
    A recent trip to a local electronics store to evaluate a replacement home entertainment system pointed to a similar sort of hierarchical system—all the combinations of possible components and options left my head spinning! I wondered
    how such systems could be modeled and implemented in a database system.
    The relationship between an automobile and its engine represents a hierarchy: the automobile contains the engine. The relationship is the same for the drivetrain, the electronics, and the steering. The relationship is containment. A
    similar hierarchy can be observed in the relationship between the different groupings of geographic or census data.
    Hierarchies exist everywhere, yet implementing them in the context of a relational database frequently proves to be a challenge. A typical approach is to represent the hierarchy using a parent/child relationship with one or more tables.
    While this approach certainly works in many cases, it has a few shortcomings. Such solutions must carefully consider how the referential integrity will be maintained. And while querying the depth and breadth of such tables was considerably simplified in SQL
    Server 2005 with the introduction of recursive common table expressions, writing queries against these types of tables can still be problematic when joins against many tables are required.
    A Bill of Materials Problem
    A few years ago I was working on a system being developed by a manufacturing company to help their dealers specify the components needed to build center-pivot irrigation systems. The software produced a list of components needed to custom-build
    the desired pivot (the totality of a center-pivot irrigation system is simply referred to as a pivot within the industry). The required components were determined based on geography, soil type, and the intended crops planted in the areas to be covered as well
    as the hydrologic and structural considerations of the device itself.
    Underpinning the solution would be a SQL Server database. The purpose of the database was to store information about the components available to build the pivot. However, when we generated the specification for manufacturing, we needed
    to identify those components as BOMs.
    Some bills represented a collection of physical parts that would be assembled into a system component. For example, every pivot needed a pump to draw water from a well into the system. That pump might be electrically powered, meaning
    it needed a transformer and fuse box, too. Or the pump might be fuel powered, meaning it needed a tank, a fuel pump, and hoses to connect the pump to the tank. In either case, the required parts for the pump would be listed in a pump bill.
    The bill for a complete pivot would include a collection of other bills. For example, a standardized pivot might consist of a tree of bills for the pump, another tree of bills for the spans of pipe used to deliver water, and bills for any other equipment
    needed to build that pivot system."
    LINK: http://msdn.microsoft.com/en-us/magazine/cc794278.aspx
    Kalman Toth Database & OLAP Architect
    SELECT Query Video Tutorial 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Need help further tuning view source for outer join

    I have been working on tuning views for use in Discoverer for some time, and I have greatly improved upon what was there, but it is still not where I need it to be. There are 2 views the users join together in Discoverer - one for contract lines, and one for contract flexfields. Run as a 1 to 1 join on contract number, performance is great. However, as soon as I have an outer join on flexfields, the performance is awful. We are talking a difference of under a minute to hours and hours. I have to be able to perform an outer join because there can be contracts without flexfields. Can anyone suggest an alternative method to get the data or further tuning? I will paste both the contract lines and contract flexfields source - I have tuned the flexfields but have done nothing to date with the lines.
    CREATE OR REPLACE VIEW XXDBD_CONTRACT_FLEXFIELDS AS
    SELECT core.contract_id, core.service_id, core.contract_number, core.service_line, core.service, core.product_line, core.equipment, core.UL_Certificate_And_End_Date, core.MAF, core.Termination_Penalty_Percentage, core.multi_year, core.multi_year_effective_dates, core.terms_multi_year, core.SerLineRenPricingMethod, core.ren_line_change, core.zone, core.add_invoice_display, core.add_subgrouping, re.diebold_price, attr.coverage_hours, attr.reaction_times, attr.resolution_times, attr.repair_times, tr.performance_requirement, attr.penalty, attr.penalty_amount, attr.penalty_bonus, attr.mon_break_start, attr.mon_break_end, attr.tues_break_start, attr.tues_break_end, attr.wed_break_start, attr.wed_break_end, attr.thu_break_start, attr.thu_break_end, attr.fri_break_start, attr.fri_break_end, attr.sat_break_start, attr.sat_break_end, attr.sun_break_start, attr.sun_break_end, attr.split_covering, attr.cash_handling
    FROM (SELECT aa.ID Contract_id,
    aa.contract_number,
    dd.id Service_ID ,
    dd.cle_id dd_cle_id,
    dd.line_number service_line,
    xxdbd_Disco_Service_Contract.GetServNameInv
    (dd.id) Service,
    dd.line_number ||'.'||ee.line_number Product_Line,
    xxdbd_Disco_Service_Contract.GetEqpNoInvoice(ee.id)
    Equipment,
    DECODE(dd.attribute_category,'Service Contracts',
    NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_50_CHARS', dd.attribute1),dd.attribute1),'') UL_Certificate_And_End_Date,
    dd.attribute2 MAF,
    DECODE(dd.attribute_category,'Service Contracts',NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute3),dd.attribute3),'') Termination_Penalty_Percentage,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_MULTIYEAR', dd.attribute5),dd.attribute5),
    'N','No Multi-Year',
    'Y','Multi-Year, Years not Known',
    'Y1','Multi-Year for 1 Year',
    'Y2','Multi-Year for 2 Year',
    'Y3','Multi-Year for 3 Year',
    'Y4','Multi-Year for 4 Year',
    'Y5','Multi-Year for 4 Year',dd.attribute5),'')Multi_Year,
    dd.attribute4 Multi_Year_Effective_Dates,
    DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_450_CHARS', dd.attribute9),dd.attribute9),'') Terms_Multi_Year,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_RENEWAL_PRICING', dd.attribute6),dd.attribute6),
    'MP', 'DBD Markup Percent',
    'CP', 'DBD Contract Price',
    'AI', 'DBD Amount Increase',
    'AD', 'DBD Amount Decrease',
    'TA', 'DBD Target Amount',
    'FR', 'DBD Flat Rate',dd.attribute6),'') SerLineRenPricingMethod,
    DECODE(dd.attribute_category,'Service Contracts', NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_NUMERIC', dd.attribute7),dd.attribute7),'') Ren_Line_Change,
    DECODE(dd.attribute_category,'Service Contracts', DECODE(NVL(xxdbd_Disco_Service_Contract.GetContractMasterProperty('DBD_OKS_ZONE', dd.attribute8),dd.attribute8),
    'DNA1','DNA Zone 1',
    'DNA2','DNA Zone 2',
    'DNA3','DNA Zone 3',
    'BRAZIL1','Brazil Zone 1 (50 KM)',
    'BRAZIL2','Brazil Zone 2 (80 KM)',
    'BRAZIL3','Brazil Zone 3 (200 KM)',dd.attribute8),'')Zone,
    DECODE(dd.attribute11, 'N','None','SC','Sub Component', 'SN', 'Serial Number', 'SNSC', 'Serial Number and Sub-Component') Add_Invoice_Display,
    DECODE(dd.attribute10, 'SI','Service Item', 'CP','Covered Product', 'PC','Product Category') Add_SubGrouping,
    dd.attribute12 Diebold_Price,
    ee.id ee_id,
    ee.cle_id ee_cle_id
    FROM okc_k_headers_b aa,
    okc_k_lines_b dd,
    okc_k_lines_b ee
    -- xxdbd_temp_flex_contract tfc
    WHERE aa.id = dd.DNZ_CHR_ID
    AND dd.CLE_ID IS NULL
    AND dd.id = ee.cle_id
    AND ee.DNZ_CHR_ID = aa.id
    AND ee.LSE_ID =9
    AND dd.LSE_ID =1
    -- and aa.contract_number = 'NL0000014'
    -- and aa.contract_number in (select contract_number from xxdbd_flex_contract)
    -- AND tfc.contract_number = aa.contract_number
    ) core,
    (SELECT h.contract_number,
    DECODE(l.attribute_category,
    'Coverage Break', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),
    'Business Process',xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,1)),
    'Coverage Template Header',xxdbd_get_sib_cont_id(l.cle_id),
    'Transaction Type', xxdbd_get_sib_cont_id(xxdbd_get_parent_cle_id(l.cle_id,2)),null) ee_id,
    DECODE(l.attribute_category, 'Business Process', l.attribute1) Coverage_Hours,
    DECODE(l.attribute_category, 'Business Process', l.attribute2) Reaction_Times,
    DECODE(l.attribute_category, 'Business Process', l.attribute3) Resolution_Times,
    DECODE(l.attribute_category, 'Business Process', l.attribute4) Repair_Times,
    DECODE(l.attribute_category, 'Business Process', DECODE(l.attribute5,
    'RA', 'REACTION'
    , 'RS', 'RESOLUTION'
    , 'RR', 'REACTION & RESOLUTION'
    , 'NR', 'NO REQUIREMENT',
    l.attribute5)) Performance_Requirement,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute1) Penalty,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute2) Penalty_Amount,
    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute2) Mon_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute3) Tues_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute4) Tues_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute5) Wed_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute6) Wed_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute7) Thu_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute8) Thu_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute9) Fri_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute10) Fri_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute11) Sat_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute12) Sat_Break_End,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute13) Sun_Break_Start,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute14) Sun_Break_End,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute2) Cash_Handling
    from okc_k_lines_b l , okc_k_headers_b h--, xxdbd_temp_flex_contract tfc
    where l.attribute_category in ('Coverage Break', 'Business Process', 'Coverage Template Header','Transaction Type')
    and h.id = l.dnz_chr_id
    -- and h.contract_number in (select contract_number from xxdbd_flex_contract)
    -- and tfc.contract_number = h.contract_number
    ) attr
    where core.ee_id = attr.ee_id (+)
    and core.contract_number = attr.contract_number (+);
    create or replace view xxdbd_contract_lines as
    select aa.id Contract_id,
    bb.id Service_id,
    aa.CONTRACT_NUMBER,
    F1.USER_NAME Created_By,
    F2.USER_NAME LastUpdated_By,
    bb.LINE_NUMBER Service_Line_No,
    bb.LINE_NUMBER ||'.'|| cc.LINE_NUMBER Product_Line_No,
    xxdbd_Disco_Service_Contract.GetServNameInv(bb.id) Service,
    xxdbd_Disco_Service_Contract.GetServDescInv(bb.id) Service_Desc,
    xxdbd_Disco_Service_Contract.GetServicePrice(bb.id) Service_Price,
    bb.PRICE_UNIT Service_List_Price,
    bb.CURRENCY_CODE,
    aa.SCS_CODE Contract_Type,
    bb.STS_CODE Service_Status,
    bb.TRN_CODE Term_Code,
    bb.START_DATE Service_start,
    bb.END_DATE Service_end,
    TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' )) SERVICE_BillToSite,
    xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(Null, bb.id, 'OKX_BILLTO' ))) Bill_Account,
    xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_BILLTO' ))) Service_BillTo,
    TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' )) SERVICE_ShipToSite ,
    xxdbd_Disco_Service_Contract.GetLocation(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Service_Ship_To,
    xxdbd_Disco_Service_Contract.GetLocAccount(TO_NUMBER(OKS_ENT_UTIL_PVT.get_billtoshipto(NULL, bb.id, 'OKX_SHIPTO' ))) Ship_Account,
    bb.DATE_RENEWED,
    bb.DATE_TERMINATED,
    cc.START_DATE Eqp_Start,
    cc.END_DATE Eqp_End,
    xxdbd_Disco_Service_Contract.GetEqpNoInvoice(cc.id) Eqp_No,
    xxdbd_Disco_Service_Contract.GetEqpDescInvoice(cc.ID) Eqp_Desc,
    xxdbd_Disco_Service_Contract.GetEqpQuantityInvoice(cc.id) Eqp_Quan,
    xxdbd_Disco_Service_Contract.GetEqpSerialNoInvoice(cc.id) Eqp_Serial,
    xxdbd_Disco_Service_Contract.GetCustomerCt(aa.id, bb.id) Cust_Contact,
    DD.ORGANIZATION_ID,
    dd.INSTALL_ADDRESS,
    dd.INSTALL_DATE,
    dd.INSTALL_SITE_ID INSTALL_SITE_USE_ID,
    dd.PARTY_SITE_NAME INSTALL_SITE_NAME,
    dd.PARTY_SITE_NUMBER INSTALL_SITE_NUMBER
    ,cii.inventory_item_id
    ,cii.inv_master_organization_id
    ,aa.authoring_org_id
    ,cc.id equipment_id
    ,TO_NUMBER(replace(bb.attribute12,',','')) annual_contract_amt
    ,ou.name operating_unit
    ,ou.organization_id operating_unit_id
    ,substr(xxdbd_ra_utility.Get_BusinessProcess(cc.cle_id),1,100) business_process
    ,cii.instance_id
    ,cii.instance_number
    from okc_k_headers_b aa
    ,okc_k_lines_b bb
    ,okc_k_lines_b cc
    ,fnd_user f1
    ,fnd_user f2
    ,csi_item_instances cii
    ,okc_k_items items
    ,hr_all_organization_units ou
    ,xxdbd_oks_install_info_v dd
    where aa.id = bb.dnz_chr_id
    and bb.cle_id is null
    and cc.cle_id = bb.id
    and cc.dnz_chr_id = aa.id
    and f1.user_id = bb.created_by
    and f2.user_id = bb.last_updated_by
    and cc.lse_id in (9,25,18,40)
    and dd.line_id (+) = cc.id
    and items.cle_id = cc.id
    and cii.instance_id = items.object1_id1
    and aa.authoring_org_id = ou.organization_id (+);
    Here are the explain plans from TOAD:
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 6 49124
    NESTED LOOPS OUTER 6 80 K 49124
    VIEW 6 80 K 49112
    HASH JOIN 6 1 K 49112
    HASH JOIN 17 K 2 M 20214
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
    INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
    VIEW PUSHED PREDICATE 1 107 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
    NESTED LOOPS 50 5 K 219
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 245 63309
    NESTED LOOPS 245 291 K 63309
    NESTED LOOPS OUTER 245 286 K 63064
    NESTED LOOPS 245 80 K 62574
    HASH JOIN 245 74 K 61839
    HASH JOIN 245 71 K 61756
    HASH JOIN OUTER 245 68 K 61673
    HASH JOIN 245 60 K 61664
    HASH JOIN 205 K 32 M 28046
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 244 K 37
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 205 K 23 M 27803
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 2 M 168 M 27803
    TABLE ACCESS FULL HR.HR_ALL_ORGANIZATION_UNITS 2 K 64 K 8
    TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
    TABLE ACCESS FULL APPLSYS.FND_USER 13 K 172 K 81
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
    UNION-ALL PARTITION
    NESTED LOOPS 1 167 9
    NESTED LOOPS 1 108 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
    INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 144 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 161 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
    INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    And here is the SQL to join:
    select * from xxdbd_contract_lines l, xxdbd_contract_flexfields f
    where f.service_id (+) = l.service_id
    and f.contract_number (+) = l.contract_number
    and l.contract_number = 'NL0000014'
    Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE 1 49221
    HASH JOIN OUTER 1 38 K 49221
    VIEW APPS.XXDBD_CONTRACT_LINES 1 19 K 96
    NESTED LOOPS OUTER 1 1 K 96
    NESTED LOOPS 1 358 94
    NESTED LOOPS 1 345 93
    NESTED LOOPS 1 332 92
    NESTED LOOPS 1 311 91
    NESTED LOOPS 1 285 88
    NESTED LOOPS 448 72 K 88
    NESTED LOOPS OUTER 1 78 4
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 46 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    TABLE ACCESS BY INDEX ROWID HR.HR_ALL_ORGANIZATION_UNITS 1 32 1
    INDEX UNIQUE SCAN HR.HR_ORGANIZATION_UNITS_PK 1
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 378 32 K 84
    INDEX RANGE SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 378 16
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 119
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 21 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
    INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_USER 1 13 1
    INDEX UNIQUE SCAN APPLSYS.FND_USER_U1 1
    VIEW APPS.XXDBD_OKS_INSTALL_INFO_V 1 861 2
    UNION-ALL PARTITION
    NESTED LOOPS 1 167 9
    NESTED LOOPS 1 108 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTY_SITES 1 23 1
    INDEX UNIQUE SCAN AR.HZ_PARTY_SITES_U1 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 144 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_LOCATIONS 1 59 1
    INDEX UNIQUE SCAN AR.HZ_LOCATIONS_U1 1
    NESTED LOOPS 1 161 8
    NESTED LOOPS 1 85 7
    NESTED LOOPS 1 51 6
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 1 25 3
    INDEX UNIQUE SCAN OKC.OKC_K_LINES_B_U1 1 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_ITEMS 1 26 3
    INDEX RANGE SCAN OKC.OKC_K_ITEMS_N1 1 2
    TABLE ACCESS BY INDEX ROWID CSI.CSI_ITEM_INSTANCES 1 34 1
    INDEX UNIQUE SCAN CSI.CSI_ITEM_INSTANCES_U01 1
    TABLE ACCESS BY INDEX ROWID AR.HZ_PARTIES 1 76 1
    INDEX UNIQUE SCAN AR.HZ_PARTIES_U1 1
    VIEW APPS.XXDBD_CONTRACT_FLEXFIELDS 6 112 K 49124
    NESTED LOOPS OUTER 6 80 K 49124
    VIEW 6 80 K 49112
    HASH JOIN 6 1 K 49112
    HASH JOIN 17 K 2 M 20214
    TABLE ACCESS FULL OKC.OKC_K_HEADERS_B 5 K 175 K 37
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 17 K 1 M 20162
    INDEX SKIP SCAN XXDBD.XXDBD_OKC_K_LINES_B_N10 39 17085
    TABLE ACCESS FULL OKC.OKC_K_LINES_B 502 K 34 M 27803
    VIEW PUSHED PREDICATE 1 107 2
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_LINES_B 42 3 K 216
    NESTED LOOPS 50 5 K 219
    TABLE ACCESS BY INDEX ROWID OKC.OKC_K_HEADERS_B 1 33 3
    INDEX RANGE SCAN OKC.OKC_K_HEADERS_B_U2 1 2
    INDEX RANGE SCAN OKC.OKC_K_LINES_B_N2 1 K 32

    DECODE(l.attribute_category, 'Coverage Template Header', l.attribute3) Penalty_Bonus,
    DECODE(l.attribute_category, 'Coverage Break', l.attribute1) Mon_Break_Start,
    DECODE(l.attribute_category, 'Transaction Type', l.attribute1) Split_Covering,Uh oh, the dreaded entity attibute value, or generic, data model.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:10678084117056
    I am afraid slow performance is a built in feature of this database design, not much you can do in queries.
    You could possibly create the views as materialized views and query those instead.
    Quote from the linked article
    But, how does it perform? Miserably, terribly, horribly. A simple "select
    first_name, last_name from person" query is transformed into a 3-table join with
    aggregates and all. Further, if the attributes are "NULLABLE" - that is, there
    might not be a row in OBJECT_ATTRIBUTES for some attributes, you may have to
    outer join instead of just joining which in some cases can remove more optimal
    query plans from consideration.
    Writing queries might look pretty straightforward, but it's impossible to do in
    a performant fashion.

  • Trouble with a SELECT stament?Is this is a bug or am i an idiot

    DB version:10g Enterprise Edition Release 10.2.0.3.0
    I have a simple SELECT statement like
    SELECT ship_dtl.track_id,{color:#ff0000}_{color}ship_dtl.cons_id from ship_dtl
    If there is a space between coma and ship_dtl.cons_id in the query(a red underscore is used above to show the space). This query will give the error
    {noformat}ERROR at line 1:
    ORA-00942: table or view does not exist
    {noformat}
    But i don't get this issue with other tables. Why is this happening?
    Edited by: canine_Joe on Sep 4, 2008 3:04 AM

    canine_Joe wrote:
    How many lines of output do i to post to convince you?Ok, well let me be blunt...
    It's not a bug. It can't possibly be.
    Thousands, if not millions, of Oracle developers have been writing queries with or without spaces between their columns in the select clause for a long time now without any issue.
    The fact that Oracle is reporting the table is not found indicates that there's some other issue at hand.
    What version of SQL*Plus are you using against your 10.2.0.3 database? Maybe that's out of date and has a bug or is incompatible with 10.2.0.3. for some reason.
    What user/schema owns the table and what user is running the SQL?
    What permissions are on the table?
    What synomyms exist?
    Is there a problem with keyboard mappings on your client or the language settings on client or Oracle server, so the space isn't really a space character?
    How about taking your query with the space and doing...
    select dump('SELECT ship_dtl.track_id, ship_dtl.cons_id from ship_dtl;') from dual;and seeing what each character is in the string, just to confirm it's a chr 32 (space).
    There may be other reasons too...

  • Query Based On Form

    Hi,
    I am writing queries which work very well and have managed to use a parameter to dynamically select the data I need (basically Purchase Orders raised from a Sales Order Number)
    SELECT T0.[DocNum], T0.[CardName], T0.[DocDate] FROM OPOR T0  INNER JOIN POR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T1.[BaseRef] = [%DocNum]
    THis is fine - as a box appears to ask me for a SO number.
    How do I get this to auto populate with the SO number of the currently open Sales Order when in Sales Order Form ?
    TIA for any help.

    Hi Thanks,
    Sadly this did not work , I was excited for a second .
    Here is the Error :
    <LogMessage Component="SystemMessage" Severity="Error" PID="13028" ProcessName="C:\Program Files\SAP\SAP Business One\SAP Business One.exe" TID="12608" TimeStamp="18/03/2008 15:43:45:664311">
      <MessageText>1). [Microsoft][SQL Native Client][SQL Server]Invalid pseudocolumn "$http". 2). [Microsoft][SQL Native Client][SQL Server]Statement(s) could not be prepared. STACK: Frame id=00: "SAP Business One.exe"; base=0x00400000, offset=0x01834E97 Frame id=01: "SAP Business One.exe"; base=0x00400000, offset=0x016BE088 Frame id=02: "SAP Business One.exe"; base=0x00400000, offset=0x00479C22 Frame id=03: "SAP Business One.exe"; base=0x00400000, offset=0x0047C27F Frame id=04: "SAP Business One.exe"; base=0x00400000, offset=0x004F465C Frame id=05: "SAP Business One.exe"; base=0x00400000, offset=0x01545978 Frame id=06: "SAP Business One.exe"; base=0x00400000, offset=0x00820CF2 Frame id=07: "SAP Business One.exe"; base=0x00400000, offset=0x01554460 Frame id=08: "SAP Business One.exe"; base=0x00400000, offset=0x015542DD Frame id=09: "SAP Business One.exe"; base=0x00400000, offset=0x0173CC84 Frame id=10: "SAP Business One.exe"; base=0x00400000, offset=0x01690F19 Frame id=11: "SAP Business One.exe"; base=0x00400000, offset=0x016FAB85 Frame id=12: "SAP Business One.exe"; base=0x00400000, offset=0x0165C2CF Frame id=13: "SAP Business One.exe"; base=0x00400000, offset=0x0165BE16 Frame id=14: "SAP Business One.exe"; base=0x00400000, offset=0x0164B59D Frame id=15: "SAP Business One.exe"; base=0x00400000, offset=0x0164B3CB Frame id=16: "SAP Business One.exe"; base=0x00400000, offset=0x0164B413 Frame id=17: "SAP Business One.exe"; base=0x00400000, offset=0x00402E18 Frame id=18: "SAP Business One.exe"; base=0x00400000, offset=0x00401010 Frame id=19: "SAP Business One.exe"; base=0x00400000, offset=0x018CF1D2 Frame id=20: "kernel32.dll"; base=0x7C800000, offset=0x7C816FD7</MessageText>
    Thanks

Maybe you are looking for