Limitation of SQL-Query data source !?

Hello,
I faced a situation that required the use of "case ... when ... then ...end" in my select-statement defining the data source. But I doesn't seem to work! I checked the statement in sql developer and it worked fine!
Is there any idea about that?
Thanks in advance.
Dirk

Hi Tim,
thank you for your response - I created a sample query of what I used and it looks like this one:
select col1
,col2
, case col2 when '12' then (select a2.col2 from a2 where a2.col1 = a1.col1 )
when '13' then (select a3.col2 from a3 where a3.col1 = a1.col1 )
     end
from a1
Dirk

Similar Messages

  • Question on Dynamic Query Data Source and Form Folders in Oracle Forms 6i

    Hi there -
    I have one interesting requirement in Oracle Forms.
    This is what I wanted to do.
    1. Have a LOV and Go button on Form.
    2. From LOV, I will select a pre-defined custom table and click Go.
    3. Based on the selected custom table, I have to populate the Block (Tabular Format).
    4. User should be able to do update, delete, insert on this block.
    5. User should be able to use the Oracle Form folders functionality (select only necessary column and save views etc. Std folder functionality).
    6. If user selects a different custom table name in the LOV on top, I need to refresh the data from the block based on this new table. Remaining functionality should be as it is (steps 3 to 5).
    You can see here, I am going to have dynamic query data source (Table Name as well as column mapping) on the block. I do not know before hand how many columns the user selected table has!
    This is what I have planned for this so far but I have some major questions before I can move on with this design:
    1. I am going to create a table structure with fixed number of column in form (40 cols assuming that the custom table will not have more that 40 cols). (Kind of limitation but it's okay as of now).
    2. Dynamically populate the block based on the table name selected by the user from LOV. Dynamically change the table column names based on the table selected etc.
    3. Perform insert, update, delete using PL/SQL package.
    So far it looks okay.
    Now my real question is,
    Can user still be able to user "Folders" functionality here? I have never done this kind of development before and I doubt the dynamic column naming, dynamic column data source will really work for "folders"!
    Also, I am not really sure whether user will be able to save these "folder" queries?
    Okay so form experts, can you ppl suggest me if this is really going to work? Are there any better ways to do this?
    Initially I tried to do this in OA Framework but I got stuck at because as per OAF developer guide "I cannot user OAF personalization for dynamic items, regions etc".
    For more info on that thread see this link...
    Re: setUserCustomizable issue!
    Thanks in advance for the help.

    Any suggestion anyone?

  • Multiple PS Query Data Sources in RTF Template

    Is it possible to use two PS Queries as Data Sources on an RTF template in XML Publisher?
    There is a field in the main Data Source (PS Query) that needs to join to some other tables. This slows down the query considerably even after tweaking the join and tuning, etc. Instead of doing the join in the main PS Query Data Source, can we do any of these?
    1. Do a select statement inside an RTF template Form Field?
    2. Use two PS Queries on the same RTF template?
    3. Import a sub template that uses its own PS Query Data Source for the field?
    Hope this makes sense. Thank you.

    You can have multiple data models and then use the 'concatenated SQL data source' to generate a single xml file that includes data based on both queries. You can not do a select statement inside a RTF template.
    Within the RTF template you can write logic to join the two data sets... see this blog post:http://blogs.oracle.com/xmlpublisher/entry/formatting_concatenated_dataso
    Thanks,
    Bipuser

  • Frm-41380 error - cannot set the blocks query data source

    Fairly new forms so bare with me. I am creating a form based on one table. This table has one column that is a nested table.
    table name: szrtime
    table columns: szrtime_code, szrtime_styp_list
    szrtime_styp_list is a table of varchar2(1).
    main block is szvtime_block
    the block that contains the nested table is szvtime_styp_block
    I read that I could use a WHEN_NEW_RECORD_INSTANCE trigger on the main block to display the related nested table. I have tried the folllowing:
    Declare
    select_stmt Varchar2(512) ;
    Begin
    If :szvtime_block.szvtime_code Is not null Then
         select_stmt := '(SELECT column_value FROM TABLE ( SELECT szrtime_styp_list FROM szrtime WHERE szrtime_code = ''' || :SZVTIME_BLOCK.SZVTIME_CODE || '''))';
         Go_Block('SZVTIME_STYP_BLOCK' );
         Clear_Block ;
         message('select_stmt = '||select_stmt);
    Set_Block_Property( 'SZVTIME_STYP_BLOCK', QUERY_DATA_SOURCE_NAME, select_stmt ) ;
    Execute_Query ;
    Go_Block('SZVTIME_BLOCK') ;
    Else
    Go_Block('SZVTIME_STYP_BLOCK' );
    Clear_Block ;
    Go_Block('SZVTIME_BLOCK') ;
    End if ;
    End ;
    The result is the frm-41380 error.
    I have tried change the query data source type on the nested table block to Table or From-clause but did not help. The select statement that is valid and returns the correct result in Toad.
    Any suggestions on what to look for? Thank you.
    Todd

    > But what is giving me pause is that the user will be updating, deleting, and inserting
    into this table and, of course, the nested table column.
    It would give me pause, too. I've never used nested tables, so I poked around in Forms on-line help. In Forms 6i, it specifically states that Forms does not support the Nested Table structure.
    In Forms 10g help, it describes Nested Table structures, but says NOTHING about how a form would handle it. And that implies to me that it is still not supported. So good luck.
    In addition to creating the view, you may need to provide your own nested table updating procedures via a package on the server which your form can call. I know Forms supports passing pl/sql tables ("indexed by binary_integer"), so you could pass your nested table back and forth between the package and the form in that format.

  • Block Property (Query Data Source Type)

    Hello Friends
    I am using Forms 6i.oracle 9i.
    in the Block Property Pallete under Query Data Source Type there
    are 4 Type is mentioned.i have used Table,From Clause Query but yet to use Transactional Trigger and Procedure.How to use this two and it will be very kind enough if u give any example about these twos.
    Regards

    There's a whole bunch of explanation about this subject in the online help of Forms. Just select the Query Data Source Type property and press F1. The initial explanation is very limited but there are a number of useful links under "Related topics"

  • Query data source type = procedure or from clause

    1)I have a form where a block is based on a from clause. In the source name I entered a simple sql statement.
    Isn't the items suppose to show without any other action or
    WHAT ELSE DO I NEED TO DO IN ORDER TO SEE THE BLOCK ITEMS EQUIVALENT TO THE COLUMNS IN THE QUERY?
    2) I have a form where a block is based on a procedure.
    First I created a package in a program unit with the procedures query_procedure, insert_procedure, update_procedure, delete_procedure and lock_procedure.
    Then I set the query data source name to the package query_procedure. The columns and arguments were automatically filled by Forms - they are fine as well.
    Forms automatically created the block triggers insert-procedure,delete-procedure, update-procedure and lock-procedure.
    Everything seems to be fine but when I run the form and execute the query I get frm 40505 - unable to perform query.
    What am i doing wrong?
    This is the package:
    PACKAGE pkgdeptemp IS
    type dept_emp is record (
    empno number(4),
    ename varchar2(10),
    job varchar2(9),
    hiredate date,
    sal number(7,2),
    deptno number(2),
    dname varchar2(14));
    success constant number :=0;
    type dept_emp_ref is ref cursor return dept_emp;
    type dept_emp_tab is table of dept_emp index by binary_integer;
    procedure query_procedure (resultset in out dept_emp_ref, p_empno in number);
    procedure lock_procedure (dmlset in out dept_emp_tab);
    procedure insert_procedure (dmlset in out dept_emp_tab);
    procedure update_procedure (dmlset in out dept_emp_tab);
    procedure delete_procedure (dmlset in out dept_emp_tab);
    END;
    PACKAGE BODY pkgdeptemp IS
    function get_success return number is
         begin
              return(success);
         end;
    procedure query_procedure (resultset in out dept_emp_ref, p_empno in number) is
    begin
         open resultset for
              select e.empno, e.ename, e.job, e.hiredate, e.sal, e.deptno, d.dname
              from emp e, dept d
              where e.deptno = d.deptno
              and e.empno = nvl(p_empno, e.empno);
    end query_procedure;
    procedure lock_procedure(dmlset in out dept_emp_tab) is
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              select empno
              into tempout
              from emp
              where empno = dmlset(i).empno
              for update;
         end loop;
    end lock_procedure;
    procedure insert_procedure (dmlset in out dept_emp_tab) is
         cursor c_dept (i binary_integer) is
         select deptno
         from dept
         where deptno = dmlset(i).deptno;
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              open c_dept(i);
              fetch c_dept into tempout;
              if c_dept%notfound then
                   insert into dept(deptno,dname)
                   values(dmlset(i).deptno, dmlset(i).dname);
              end if;
              close c_dept;
              insert into emp (empno,ename,job,hiredate,sal,deptno)
              values (dmlset(i).empno, dmlset(i).ename, dmlset(i).job, dmlset(i).hiredate, dmlset(i).sal, dmlset(i).deptno);
         end loop;
    end insert_procedure;
    procedure update_procedure (dmlset in out dept_emp_tab) is
         cursor c_dept (i binary_integer) is
         select deptno
         from dept
         where deptno = dmlset(i).deptno;
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              open c_dept(i);
              fetch c_dept into tempout;
              if c_dept%notfound then
                   insert into dept(deptno,dname)
                   values(dmlset(i).deptno, dmlset(i).dname);
              else
              update dept
              set deptno=dmlset(i).deptno,
              dname=dmlset(i).dname;
              end if;
              close c_dept;
         update emp
              set empno=dmlset(i).empno,
              ename=dmlset(i).ename,
              job=dmlset(i).job,
              hiredate=dmlset(i).hiredate,
              sal=dmlset(i).sal,
              deptno=dmlset(i).deptno;
         end loop;
    end update_procedure;
    procedure delete_procedure (dmlset in out dept_emp_tab) is
    begin
         for i in 1..dmlset.count loop
              delete from emp where empno = dmlset(i).empno;
         end loop;
    end delete_procedure;
    END;

    for ur q1:
    create the text items manually in the layout editor or in the obj navigator then specify there properties manually in the the pallette.
    database item = yes
    column name = field name in ur select statement
    for q2:
    try running the form again and press F8 then if an error occur press F1 or shift F1 to show the error in ur code.
    i suspect u forgot to specify a value for the in parameter the reason why u get an error that is specify the actual parameter for ur in argument then press F8.
    enjoy!

  • Setting Query Data Source Arguments Property for Block with TYPE Procedure

    Hi,
    I have a block whose type is 'Procedure', this returns a PL/SQL table.
    I pass an IN OUT variable declared in the Package header and all works well.
    What I need to know is how, if I have ANOTHER argument, how do I set it programatically prior to EXECUTE_QUERY.
    I can see how to set the Name and Value manually at the "Query Data Source Arguments" property but if I need to set it dynamically in the code how would I do it.

    Thanks,
    Worked it out.
    Set the VALUE to the name of a Global variable and populated the variable before executing the procedure.
    Thanks

  • How to use 'query data source Name '  property in a block

    I want to create a block using query and want to show the columns on a form.
    Could you please tell me how can I do this?
    Regards

    Hi!
    Create a new block manually.
    Set the Query Data Source Type Property to FROM clause query.
    In the Query Data Source Name Property write your query like you would
    write it in sql*plus or toad but without a order by clause.
    Set the DML Data Target Type Property to None.
    Create items for the columns in your query.
    May set the where clause and order by property of the block.
    Build the form and execute a query in your new block.
    Regards

  • Create SQL server data source programmatially

    Hi,
    I'd like to create a SQL server data source programmatically in LabVIEW. The SQL server version I used is 2005. Can anyone give some ideas? A code example will be most favorable.
    Thanks,
    Jane
    Solved!
    Go to Solution.

    Dan put it well. All you need is a connection string and those are easy to build. There are even a couple website that do nothing but publish template connection strings for every DBMS on the planet.
    The only point I would quibble over is about using the database connectivity toolkit. The DCT is an unnecessary complication that is ultimately counter productive because it limits your support options. When I get into the office in a few hours I will post a link to an alternative that actually simplifies the process and is free.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Is there a way to consolidate calculations used in SQL Query Data Sets?

    I am building SQL Query Data Sets against multiple DB Views which all have different date formats. I have the date parameter working well, but want to consolidate the changes that I have to do to it especially for the quarter. For example the SQL against a monthly view would use "where year_month > to_char(:ST_DATE, 'YYYY-MM')" which is not too hard, but to make that work for the quarterly view I need several concats and a decode to get a "> '2012-Q2'". I would like not to have to do this within every where clause. I had put this into a global element hoping to use that in a filter for the data set, but the filter does not have access to global elements only parameters.
    Is there any way to refer to a calculated global element from the data set to do this? I am using Layout Templates, so even if I wanted to I could not do the condition within the template.
         Thanks,
         Rick

    Change the following line to include the red coloured parts
    <div class="MasterColumn" spry:repeat="ds4" spry:setrow="ds4" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected">
      <span>{Dsp_#}</span><span>{Dsp_WkDay}</span><span>{Dsp_Event}</span>
    </div>
    The add the following style rule to your document:
    .MasterColumn span {
        display: inline-block;
    I hope this helps.
    Ben

  • With clause in SQL query data model

    Hello!
    isn't it possible to use the with clause in sql query data models?
    for example following query:
    WITH
    a_test as (
    select dummy from dual
    select *
    from a_test
    brings up a "XML Parsing Error: no element found"-error...
    BR Paul

    I tried a slightly different query (see below) and the query worked fine and retrieved data.. I did not get any errors.
    WITH
    a_test as (
    select 'dummy' from dual
    select *
    from a_test
    This works as well.. retrieving the value of the parameter
    WITH
    a_test as (
    select :Test_ID from dual
    select *
    from a_test
    thanks,
    BIPuser

  • SQL Concat function seem not to work properly in SQL query data model. BIP 11g

    I try to use this function to show entire name CONCAT(name, ' ', surname) and it doesnt show the surname. it looks like it only tooks 2 arguments. I use it with the option "Add element by expression" within a SQL Query - Data set.
    Lucia

    i don't believe you
    please post more info, may be screen or sql or some more useful statement
    CONCAT(name, ' ', surname) and it doesnt show the surname
    may be because for some case "surname" is empty  or may be you incorrect use concat function
    one way mentioned by BluShadow is " || " operator  - http://docs.oracle.com/cd/B28359_01/server.111/b28286/operators003.htm#SQLRF51156
    and another is concat function http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions026.htm#SQLRF00619
    so for your case it can be like
    CONCAT(CONCAT(name, ' '), surname)

  • Forms clause query data source data block in oracle forms

    Hello experts,
                  I am new in oracle forms.I am using oracle forms 11g with weblogic 10.3.5 at windows 7.Through googaling I know how to create a database block,forms clause data block and stored procedure based datablock in oracle forms.I want to know that as in case of  Database based datablock, could we commit form either on editing records or on insertion or deletion in data block.
    I tried this but got error frm 40501.If we can perform editing and creation in such type of datablock then please tell me how.
    Thank You,
    regards
    aaditya

    When I base my datablock on a query using the "From Clause" property of the block query data source in the oracle Forms 6i,
    I get the strange error
    "ORA-00928: missing SELECT keyword"
    The query I see in the Display Error in Help Menu is
    SELECT DAY_NUMBER,CONSULTANT_ID,EVENT_ID,EVENT_NUMBER,SESSION_NUMBER,HOURS_UNPAID,HOURS_PAID,PAPERWORK FROM (EVENT_ASSIGNED_CONSULTANT) WHERE (CONSULTANT_ID=:1)
    What should I do now?????? Please remove the brackets () from the table name.
    Instead of (EVENT_ASSIGNED_CONSULTANT) use
    EVENT_ASSIGNED_CONSULTANT

  • Abnormal termination of runform when PROCEDURE is used as Query Data Source Type

    I created a package with a procedure that returns a table of records. This
    procedure tested OK in SQLPLUS. I then created a form and in this form a block
    that used this procedure as the Query Data Source Name, and of course the Query
    Data Source Type has been set to PROCEDURE. This form runs beautifully when the
    number of records returned is small (a few hundreds). But when the number of
    records is large (I have one case where the total number of records returned
    was 11099) then it will crash. I also found that whenever this happens, there
    will be a file in my C:\TEMP with funny namessuch as s90, s81, etc. They are
    always the same size (5008 kBytes).
    Anyone any ideas?
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Chandra movva([email protected]):
    Create a view and base your block on view.That could solve the problem unless you have other requirements specifically.<HR></BLOCKQUOTE>
    Chandra,
    Thank you for your suggestion. Unfortunatel, we have requirements that translate to logics too complicated to be handled by views, and that is why we use PROCEDURES. This actually works very well and very fast, except when we have lots of records returned, then it fails. I am just wondering whether this is a configuration problem ???
    Regards,
    A. Leung
    null

  • Different LOV behavior between SQL query data model and data template

    I have noticed different behavior when using parameters linked to list of values (LOV) of type menu with the multiple selection option enabled and a SQL query data model vs a data template. Here's the example because that first sentence was probably really confusing.
    SQL Query:
    select
    plmc.MonthCode, plmc.ModalityDim, plmc.ModalityName,plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(:modalityDim,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (:modalityDim)
    then 1
    else 0
    end
    end
    Putting BI Publisher into debug mode, defining a data model of type SQL Query, defining a parameter called :modalityDim linked to a LOV that allows multiple selections, and selecting a couple of values from the LOV the output of the prepared statement is:
    [081607_122647956][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?,?)
    then 1
    else 0
    end
    end
    [081607_122647956][][STATEMENT] 1:6
    [081607_122647956][][STATEMENT] 2:7
    [081607_122647956][][STATEMENT] 3:6
    [081607_122647956][][STATEMENT] 4:7
    [081607_122654713][][EVENT] Data Generation Completed...
    [081607_122654713][][EVENT] Total Data Generation Time 7.0 seconds
    Note how the bind variable :modalityDim was changed into two parameters in the prepared statement.
    When I use this same SQL Query in a data template the output is:
    [081607_012113018][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?)
    then 1
    else 0
    end
    end
    [081607_012113018][][STATEMENT] 1:'6','7'
    [081607_012113018][][STATEMENT] 2:'6','7'
    [081607_012113574][][EXCEPTION] java.sql.SQLException: Syntax error converting the nvarchar value ''6','7'' to a column of data type int.
    Note the exception because it is trying to convert the multiple parameter values.
    Am I doing something completely wrong here? I really need to use a data template because I will need to link a couple of queries together from different database vendors.
    -mark

    This is for 10.1.3.4 - because in 11g every SQL query is automatially part of a data model.
    In 10g SQL query is for simple unrelated SQL queries.
    If you need to use advance features such as:
    a) multiple SQL queries that are joined in master-detail relation ships
    b) before/after report triggers
    Then you will need to use the data template, which is an XML description
    of the queries, links, and PL/SQL calls.
    hope that helps,
    Klaus

Maybe you are looking for