Query-plsql

=======================================================
SELECT mc.segment1 sbu, mc.segment3 ssbu,
mc.segment2 bu_code, msi.inventory_item_id,
msi.segment1, group_code, package_name_code, 0 onhand,
0 VALUE
FROM mtl_system_items_b msi,
sga_inv_item_extension_data siied,
mtl_item_categories mic,
mtl_categories mc,
mtl_category_sets mcs
WHERE msi.inventory_item_id = siied.inventory_item_id
AND siied.organization_id = in_num_organization_id
AND msi.organization_id = in_num_organization_id
AND mic.inventory_item_id = msi.inventory_item_id
AND mic.organization_id = msi.organization_id
AND mc.category_id = mic.category_id
AND mcs.category_set_id = mic.category_set_id
AND mcs.category_set_name = 'SGA Item Classification'
AND EXISTS (
SELECT 1
FROM ra_customer_trx a,
ra_customer_trx_lines b,
ra_cust_trx_line_gl_dist c
WHERE a.customer_trx_id = b.customer_trx_id
AND c.gl_date BETWEEN in_dte_from AND in_dte_to
AND b.inventory_item_id = msi.inventory_item_id
AND c.customer_trx_line_id =
b.customer_trx_line_id)
AND NOT EXISTS (
SELECT 1
FROM sga_inv_stock_status
WHERE inventory_item_id = msi.inventory_item_id
AND month_end_date = in_dte_to
AND subinventory_code NOT IN (
SELECT secondary_inventory_name
FROM mtl_secondary_inventories
WHERE asset_inventory = 2
AND organization_id = organization_id)))
==========================================================
In the above qquery how to modify to double not exists (exists and not exists in one not exists)
Any body please guide me.
Edited by: Shivaji M on Jul 15, 2009 1:12 AM

SELECT mc.segment1 sbu, mc.segment3 ssbu,
mc.segment2 bu_code, msi.inventory_item_id,
msi.segment1, group_code, package_name_code, 0 onhand,
0 VALUE
FROM mtl_system_items_b msi,
sga_inv_item_extension_data siied,
mtl_item_categories mic,
mtl_categories mc,
mtl_category_sets mcs
WHERE msi.inventory_item_id = siied.inventory_item_id
AND siied.organization_id = in_num_organization_id
AND msi.organization_id = in_num_organization_id
AND mic.inventory_item_id = msi.inventory_item_id
AND mic.organization_id = msi.organization_id
AND mc.category_id = mic.category_id
AND mcs.category_set_id = mic.category_set_id
AND mcs.category_set_name = 'SGA Item Classification'
AND EXISTS (
SELECT 1
FROM ra_customer_trx a,
ra_customer_trx_lines b,
ra_cust_trx_line_gl_dist c
WHERE a.customer_trx_id = b.customer_trx_id
AND c.gl_date BETWEEN in_dte_from AND in_dte_to
AND b.inventory_item_id = msi.inventory_item_id
AND c.customer_trx_line_id =
b.customer_trx_line_id)
AND NOT EXISTS (
SELECT 1
FROM sga_inv_stock_status
WHERE inventory_item_id = msi.inventory_item_id
AND month_end_date = in_dte_to
AND subinventory_code NOT IN (
SELECT secondary_inventory_name
FROM mtl_secondary_inventories
WHERE asset_inventory = 2
AND organization_id = organization_id)))
==============
Is this what You want
==============
SELECT mc.segment1 sbu, mc.segment3 ssbu,
mc.segment2 bu_code, msi.inventory_item_id,
msi.segment1, group_code, package_name_code, 0 onhand,
0 VALUE
FROM mtl_system_items_b msi,
sga_inv_item_extension_data siied,
mtl_item_categories mic,
mtl_categories mc,
mtl_category_sets mcs
WHERE msi.inventory_item_id = siied.inventory_item_id
AND siied.organization_id = in_num_organization_id
AND msi.organization_id = in_num_organization_id
AND mic.inventory_item_id = msi.inventory_item_id
AND mic.organization_id = msi.organization_id
AND mc.category_id = mic.category_id
AND mcs.category_set_id = mic.category_set_id
AND mcs.category_set_name = 'SGA Item Classification'
AND EXISTS (
SELECT 1
FROM ra_customer_trx a,
ra_customer_trx_lines b,
ra_cust_trx_line_gl_dist c
WHERE a.customer_trx_id = b.customer_trx_id
AND c.gl_date BETWEEN in_dte_from AND in_dte_to
AND b.inventory_item_id = msi.inventory_item_id
AND c.customer_trx_line_id =
b.customer_trx_line_id)
AND NOT EXISTS
SELECT 1
FROM sga_inv_stock_status sga1
WHERE sga1.inventory_item_id = msi.inventory_item_id
AND sga1.month_end_date = sga1.in_dte_to
AND NOT exists
SELECT 1
FROM mtl_secondary_inventories sec2
WHERE sec2.asset_inventory = 2
and sga1.subinventory_code = sec2.secondary_inventory_name
AND sec2.organization_id = sec2.organization_id)))
==================
You make sure the parenthesis are correctly paired....

Similar Messages

  • Error while querying plsql table.

    create table emp(eno number, ename varchar2(20), sal number(10,2), dno number);
    create table dept(dno number, dname varchar2(10));
    DECLARE
    TYPE EmpTabTyp1 IS TABLE OF emp%ROWTYPE INDEX BY BINARY_INTEGER;
    emp_tab1 EmpTabTyp1;
    l_str_name varchar2(20);
    begin
    select eno, ename, sal bulk collect into emp_tab1 from emp;
    select et1.ename into l_str_name from dept dp , TABLE(CAST(emp_tab1 EmpTabTyp1)) et1 WHERE dp.dno = et1.dno
    end;
    Getting below error:
    ERROR at line 8:
    ORA-06550: line 7, column 131:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 7, column 3:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 8, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
    following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted de
    Thanks,
    Vinodh

    ora_1978 wrote:
    create table emp(eno number, ename varchar2(20), sal number(10,2), dno number);
    create table dept(dno number, dname varchar2(10));
    DECLARE
    TYPE EmpTabTyp1 IS TABLE OF emp%ROWTYPE INDEX BY BINARY_INTEGER;
    emp_tab1 EmpTabTyp1;
    l_str_name varchar2(20);
    begin
    select eno, ename, sal bulk collect into emp_tab1 from emp;
    select et1.ename into l_str_name from dept dp , TABLE(CAST(emp_tab1 EmpTabTyp1)) et1 WHERE dp.dno = et1.dno
    end;
    Getting below error:
    ERROR at line 8:
    ORA-06550: line 7, column 131:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 7, column 3:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 8, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the
    following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted deThanks,
    VinodhYou cant query a PL/SQL table. You can query only a collection database object that is created and stored in the database.
    A simple reason is that PL/SQL code is processed by different engine and SQL code is processed by different engine. And your PL/SQL table is local to the PL/SQL code and is not available for the SQL engine.
    Edited by: Karthick_Arp on Apr 19, 2012 6:14 AM

  • PL/SQL: ORA-22806: not an object or REF  when Using Record in Package

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    I have declared a record type in my package
    create or replace
    PACKAGE MYPKG AS
      TYPE MYREC IS RECORD (VAL1 varchar2(20), val2 date);
      PROCEDURE display_error (pSQLERRM number);
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date);
      FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC;
    END MYPKG;
    --In My Package Body
    FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC is
            F_param MYREC;
            BEGIN
            select myvarchar2, mydate into MYREC from MYTable
              where myrefno1 = refno1
              and myrefno2 = refno2
            Exception
              when others then
              display_error(SQLERRM);
              RETURN F_param;
            END F_EPI ;
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date) IS
    insert into atable(myvarchar, mydate)
    select F_EPI(refno1,refno2).val1,F_EPI(refno1,refno2).val2 from tab2;
    END P_LOAD_DATA;
    I get errors
    Error(187,7): PL/SQL: SQL Statement ignored
    Error(225,7): PLS-00382: expression is of wrong type
    Error(225,7): PL/SQL: ORA-22806: not an object or REF
    When I compile the package.
    When I try to call the function from SQL I get an Invalid datatype error.

    Hi,
    Before posting any query/plsql blocks, please ensure that you have written it clean and complete with less syntax errors. ( at least general syntax errors, you can avoid). Then somebody can have an interest to check your logical error.
    About your posting, refer below solution step-by-step. It may help you, about what you are looking for? By the way, you must be knowing, what you are going to to do with. I haven't concentrated about your requirement; as it was not missing in your posting.
    drop table test;
    create table test(myvarchar varchar2(20), mydate date);
    create or replace
        package mypkg as
          type myrec is record (val1 varchar2(20), val2 date);
          --procedure display_error (psqlerrm in number); -- if you are passing sqlerrm, then parameter needs to be string type
       procedure display_error (psqlerrm in varchar2);
          procedure p_load_data (pstartdate in date, penddate in date);
          function  f_epi(refno1 in number,  refno2 in number) return myrec;
       end mypkg;
    Package created.
    --in my package body
    create or replace 
    package body mypkg as -- added
    procedure display_error (psqlerrm in varchar2) -- if you are declared a proc/func in spec, it needs to define in pkg body
    is
    begin
         null; -- you should know, what to do here
      dbms_output.put_line('Err -'||sqlerrm);
    end display_error;
    function  f_epi(refno1 in number,refno2 in number)
    return myrec
    is
    f_param myrec;
    begin
       -- select myvarchar2, mydate into MYREC from mytable
      --  where myrefno1 = refno1
      --  and myrefno2 = refno2;
        select ename, hiredate into f_param from emp -- added demo logic by using emp
        where empno = refno1
         and  mgr  = refno2;
        return f_param;  -- added
    exception
       when others then
         raise; -- if you are using OTHERS then, just raise it
       display_error(sqlerrm);  
       --return f_param; -- what is this?
    end f_epi;
    procedure p_load_data (pstartdate in date, penddate in date) -- you must be knowing the use of 2 params ???
    is
        v_rec myrec; -- added
    begin -- Added
       --insert into atable(myvarchar, mydate)
      -- select f_epi(refno1,refno2).val1,f_epi(refno1,refno2).val1 from tab2;
       -- demo logic added with static params to call f_epi
       v_rec:= f_epi(7499,7698);
       insert into test values v_rec;
        --null; 
    end p_load_data;
    end mypkg;
    Package body created.
    SQL> exec mypkg.p_load_data(null,null);
    PL/SQL procedure successfully completed.
    SQL> select * from test;
    MYVARCHAR            MYDATE
    ALLEN                20-FEB-81
    Thanks!

  • Possibility to register Pre-/Post-Procedures for an SQL Template Handler

    I would appreciate to see the possibility to register pre-/post-procedures for an SQL template handler in ORDS 3.0.
    Why:
    We use Oracle VPD/Row-Level-Security to secure data access. Hence a trigger sets a couple of attributes in the database session context at login time which are then used in static RLS predicates to limit which records the user can see/modify.
    With ORDS 3.0 all sessions are opened under the same technical user (e.g. APEX_REST_PUBLIC_USER), hence all users have the same/no attributes in the session context and could see/modify all data.
    To avoid this situation, I need to set the attributes (e.g. the authenticated user) in the database session context before the actual query/plsql handler is executed.
    Also, resetting the session context after the handler is executed would be good.
    This scenario is in line with scenarios 'One Big Application User' and 'Web-based applications' in http://docs.oracle.com/cd/B28359_01/network.111/b28531/vpd.htm#DBSEG98291.
    Different solution approach:
    Kris suggested to write a PL/SQL handler where the pre-procedure is called before the business logic procedure/query. This is ok for me as long as I modify data and only need to return no or little data.
    As soon as I need to return a lot of data (e.g. select c1, c19, c30 from t1), this approach will force me to write a lot of code in the PL/SQL handler in order to marshal the c1, c19 and c30 to JSON and put it in the HTTP response.
    But this is the beauty of ORDS - I can simply define a template, write a GET SQL Handler 'select c1, c19, c30 from t1'  and have the data available as REST service, without writing any code to write JSON marshaled data in the HTTP response.

    I tried to log the request at Oracle REST Data Services (ORDS) but I could only start a new discussion: Possibility to register Pre-/Post-Procedures for an SQL Template Handler
    As I mentioned there, the PL/SQL handler approach works for me as long as I have no or only little data to send back to the client (e.g. put/post/delete succeeded or an error message why the call failed).
    If I need to return a lot of data from the PL/SQL handler I would need to, as far as I understand, to marshal the data to JSON and write it to the response body in the PL/SQL handler.
    I don't want to do the marshaling, because ORDS does it better.
    However, this works for me:
    I write a pipelined stored procedure that takes as input the attributes I need to set in the session context. I then can reference it in the SQL handler:
    select * from table(my_pipelined_function(:USER, ....)
    Now the JSON/HTTP response is created by ORDS again.
    I still needed to code a couple of lines, but it is way better than duplicating the functionality already existing in ORDS.
    With the hooks it would be perfect because I would not have to write any code (apart from the procedure to set the session context attributes), just configure the REST services in ORDS.

  • Web Services Test ORA-28150: proxy not authorized to connect as client

    Oracle 11g R2 APEX 4.2 with the latest listener.
    Trying to click on the test button on the Oracle.example.hr sample under the SQL WORKSHOP Restful Services and receive the following error:
    Internal Service Error 500
    Error during evaluation of resource template: GET hr/employees/, SQL Error Code: 28,150, SQL Error Message: ORA-28150: proxy not authorized to connect as client
    I have the APEX_REST_PUBLIC_USER and APEX_LISTENER created from the supplied scripts and have executed the DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE.
    We can't get the web services to work.
    2 days wasted on this issue; Any help would be greatly appreciated!
    Edited by: 970698 on Nov 13, 2012 6:39 AM
    Edited by: 970698 on Nov 13, 2012 6:40 AM

    The error is saying that for whatever reason APEX_REST_PUBLIC_USER cannot proxy to the SCHEMA (APEX WORKSPACE) where the RESTful Service is defined.
    Allow me explain how RESTful Services are invoked in Listener 2.0
    - It is important that the RESTful Service is invoked as the SCHEMA user that the RESTful Service is defined in, to make sure the correct database security rules/constraints are applied when executing the query/pl sql block associated with the service.
    - The mechanism Listener uses to do this is called connection proxying, which is a facility provided by the Oracle database to switch a connection from one user to another.
    - Of course if you could switch from user A to user B without restriction that would not be good. Instead user B must grant user A the privilege to proxy to user B's identity.
    - Thus when an APEX workspace first has a RESTful Service created in it, it performs this grant, giving APEX_REST_PUBLIC_USER the privielge to proxy to the workspace/schema where the RESTful Service is defined.
    - Then when the RESTful Service definition is being evaluated for execution by the listener it proxies from APEX_REST_PUBLIC_USER to the workspace schema user immediately before executing the query/plsql of the service.
    - It looks like the granting of the proxy privilege has not happened/failed for some reason.
    Can you tell me:
    - If the workspace where the service was defined is a newly created workspace, i.e it was created after installing APEX 4.2?
    - If the workspace was created before or after running apex_rest_config.sql?
    A manual workaround for your problem would as the SYS user, do:
    ALTER USER <apex_workspace_name> GRANT CONNECT THROUGH apex_rest_public_user;
    Regards,
    Colm

  • Highlight rows depending on values

    I have a report (SQL Query PLSQL function body returning SQL query).
    In the report depending on the value of a column(delete_flag= 'Y' ) I want to set the
    color of the row to say red.
    Is is possible?.
    Dhiren

    Thanks a lot, i tried it out but i am making a mistake somewhere.
    I have given
    Column Template 1 condition (Use Based PLSQL Expression).
    Column Template 1 Expression (#DELETE_FLAG#=Y.
    Column Template 2 Condition -Select Condition-
    Attached this template to the report, added the CSS lines
    <style> </style> as per your link to the header.
    When i execute the report i still get an error
    ORA-01403: no data found
    Error ERR-1025 Error processing PLSQL expression. Y=Y.
    OK
    Am i missing out anything? Do I need to give "Y" , have tried various combinations.
    Dhiren

  • How is the design for this complex requirement ? pls help..

    Hi All,
    We have a Discount scheme that can be given for all possible
    combination of all customer, area and product hierarchy (attached below).
    for example :
    Promotion No.001 =>for sales on : CustomerGroup 'A', Area 'B', and
    ProductBrand 'C' will get discount 2 %
    Promotion No.002 =>for sales on : AllCustomer, District 'D', and
    Product 'E' will get discount 2.5 %
    Promotion No.003 =>for sales on : CustomerType 'F', AllArea, and
    ProductGroup 'G' will get discount 3 %
    ... and any possible combination.
    And it is possible for an Order / Invoice to get discount from two or
    more different promotion.
    e.g: Order 001, get 2 % from Promotion No.001 and 3 % from Promotion
    No.003, so totally it gets 5% discount.
    (1) Customer Hierarchy
    AllCustomer
    CustomerGroup
    CustomerType
    Customer
    (2) Area Hierarchy
    AllArea
    Region
    District
    Area
    (3) Product Hierarchy
    AllProduct
    ProductGroup
    ProductBrand
    Product
    Our Orders Data has following attributes :
    OrderNo.
    Customer
    Area
    Product
    Gross
    Discount
    Additional info :
    - Oracle version : 10g
    - If multiple discounts are applied, e.g: two discount, 10% each, then
    the total discount is 20%, if gross = 100, then netto is 100 * 80% =
    80.
    The design that comes to my mind is like below, please give me
    correcttion and recommendation :
    The Promotions is defined in master-detail :
    - one master table
    - three detail tables (one for each possible hierarchy)
    - one additional Tabel to store detail of discount an Order get,
    because it can get 2 or more discount.
    PromoHeader :
    - PromoNumber
    - Description
    - StartDate
    PromoDetail1 :
    - PromoNumber
    - PType (ALL / CustomerGroup / CustomerType / Customer)
    - PCode (ALL / 'xxxx' )
    ( note : 'xxxx' can be Customer Group Code, Customer Type Code or
    Customer Code )
    PromoDetail2 :
    - PromoNumber
    - PType (ALL / Region / District / Area)
    - PCode (ALL / 'xxxx' )
    ( note : 'xxxx' can be Region Code, District Code or Area Code )
    PromoDetail3 :
    - PromoNumber
    - PType (ALL / ProductGroup / ProductBrand / Product)
    - PCode (ALL / 'xxxx' )
    ( note : 'xxxx' can be ProductGroup Code, ProductBrand Code, Product
    Code )
    PromoByOrder
    - OrderNumber
    - PromoNumber
    - PType
    - PCode
    - Discount (%)
    (if an Order get two discount, there will be two records on this table
    for thet order)
    The question is :
    1) is this a 'good enough' design ?
    2) if I do go with this design, how is the efficient query / plsql to
    calculate the discounts for an Order.
    Pls help..
    Thank you very much,
    xtanto

    How was your wife using the Find My iPhone app from a Samsung phone? But, that question aside, your wife should educate herself on how GPS works, especially on a cell phone. GPS signals can be interfered with by trees, buildings, clouds. Off by several miles would be unusual, though.
    If your wife is tracking your cell phone and not believing what you tell her, you may want to consider counseling as there are some very serious issues that go way beyond the technology.
    Best of luck.

  • Set default value in master block of MD form

    I am finding it impossible to put a default value in a field in
    the master block of an MD form. It is essential to limit my
    users' queries to their own account. I get an error when I try
    to put a default value in, and I can't get it to respond to
    p_session.set_value in the query PLSQL section. The form appears
    on a subpage, so I can't call it with parameters. Anyone have
    any ideas? Has anyone else experienced this limitation with
    MDforms?
    Karli

    Mike,
    Thanks for your reply.
    First I just tried setting the default value for the field
    client_id (as a function returning a number) in the options box
    of the form builder. This works for my other forms, but here it
    gives me the following messages:
    Exception from wwv_generate_component.build_procedure (WWV-01821)
    Error creating module: ORA-06502: PL/SQL: numeric or value
    error: character string buffer too small (WWV-16042)
    Error creating module: ORA-06502: PL/SQL: numeric or value
    error: character string buffer too small (WWV-16042)
    Error adding module attributes: ORA-06502: PL/SQL: numeric or
    value error: character string buffer too small (WWV-16043)
    I tried setting the default as a number, 2, and got the same
    message. Therefore I decided to work around it, and just set the
    value before Querying, as follows:
    declare v_survey number;
    begin
    v_client := 2;
    p_session.set_value(
    p_block_name => 'MASTER_BLOCK',
    p_attribute_name => 'A_CLIENT_ID',
    p_value => v_client
    end;
    doQuery;--- This is the default handler
    (NOTE: I actually have a function that I want to call to set the
    default. I just used the number 2 to eliminate any unnecessary
    complexity while troubleshooting.)
    This code had no effect. I get no errors, but when the query is
    run, it ignores my attempt to set the value of the attribute. I
    suspected that perhaps this was because the doQuery procedure
    resets or ignores the master value appearing in an MDform, so I
    tried commenting out 'doQuery;' - It did not even put the value
    into the form. What am I missing?
    Karli

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

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

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

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Simple - plsql query

    I am new to plsql and want to do following in plsql code:
    code start select max(col1) from table1;
    -- and save the max value in variable VAR1
    select COL1, case COL2 when VAR1 THEN 'VALUE ONE'
    ELSE 'VALUE ELSE'
    END
    from table1
    -- I want to see the o/p of second select on the screen
    code ends how can i write the above plsql code.

    No, its not working... see the below..
    create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
    create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
    select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
    INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
    but when i use
    select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
    TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
    i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
    the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
    .. any help...
    not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
    requirements is
    mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx

  • PLSQL Funciton in SELECT query for a region in APEX

    Hello, I am developing a SQL report based on SELECT query that uses a plsql function.
    However the PLSQL Function returns a numeric value and , in addition to that, it also has one out parameter.
    How do I display this out paramete's value on APEX report?
    Thanks,
    R

    From a performance perspective, calling PL/SQL functions from SQL queries is expensive because you context switch between SQL and PL/SQL. That's ok for say 20-30 rows, but as you return more rows it gets more and more expensive. If possible write it all in SQL.
    Tyler Muth
    http://tylermuth.wordpress.com
    "Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book

  • Count number of columns in query passed as PLSQL parameter

    Hi All,
    I am using a PLSQL package to generate excel file in a Database directory, to generate file i am passing sql query and number of columns manually in a parameter.
    Now i want to automate it and do not want to pass "Number of Columns" as parameter.
    HOW CAN I CALCULATE NUMBER OF COLUMNS IN PASSED QUERY.
    Note: query can contain functions ( to get description or any other data)
    Many Thanks in advance

    http://saubbane.blogspot.com/2011/01/how-to-find-column-count-of-query.html
    Along with Re: Dynamic Fetch on dynamic Sql and just below this post, Blushadow's original run_query (from which I nicked!).

  • Query spatial data out of PLSQL Developer

    I tried to select all columns (on of them SdoGeom type) of a
    table using PLSQL Developer and got the message "unconsistent
    datatypes".
    When I use a the same select statement in SQL*Plus anything works
    right. What is there to do to use Developer?

    Here is extra information:
    We have persistent entity, it is TradeJDO, It has attributes (just sample):
    id="000004SJ"
    majorRevision=0
    minorRevision=1
    Within the managed transaction we locate this entity and change properties
    to majorRevision=1, minorRevision=0;
    Then this transaction is commited by container and here the weird stuff
    comes:
    In another transaction we retrieve PM (via jndi) and execute query for
    trade where id="000004SJ" majorRevision=1 and minorRevision=0;
    As a result we receive TradeJDO that actually has majorRevision=0 and
    minorRevision=1, i.e. the result is not consistent with the query.
    Any suggestions, what steps shall be taken to get more information on this
    problem?
    Egidijus
    We always get PM from the factory that is bound to jndi name and do not
    store it in stateful objects; Therefore I assume that adapter will take
    care that correct PM is returned.
    I haven't tried to query PM jdbc connection though, i've been checking
    data on another connection and possibly few ms later than query did.
    BEA has indicated that there might be a chance that called process and the
    transaction associated with it starts before the calling process commits.
    This would explain the "overlap". I will get back when I have more details
    Do you ever reuse persistence managers? Is it possible that PM A performs
    transaction 1, then PM B performs transaction 2, then PM A is used again?
    Also, if you get the JDBC Connection from the PM and query the data viaJDBC, do
    you see the changed data?

Maybe you are looking for