Converting A Query To A Struct

Been working on this for a while now with no breakthrough.  The query returns all the colors; the cfset structColors (commented out) held the colors previously.  I still want to use structColors but how would I use it with the query.   Please see image below.
Any help would be greatly appreciated.                                                                                                                                                                                                                                       

OK, a couple things related to that code block:
1) I still see a number of colors still referenced by structColors.COLORNAME e.g. structColors.orange or .white
Although this won't give you an error because there is no space in the name, it will make your life a LOT easier down the road if you consistently refer to your variables in a standardized format.  6 months from now, you are not going to remember that you need to refer to your you names with spaces with the braket syntax and the ones with spaces without.  I recommend that you switch all your references to use the bracket syntax.
2) It looks like you are comparing a value in your arguments scope to a specific value (e.g. 1) that I'm assuming you want to replace with the data stored in your new structure. 
Use a Switch/case statement to set the different cases for dealing with the value of your arguments.type variable and reference you job details using:
<cfset jobName = structJobStatus["#arguments.type#"]> (note the use of quotation marks and pound signs)
In the future, it would be helpful to copy/past the data from the pastebin into the comments in the forum so we can view your code without having to follow and external link.

Similar Messages

  • Converting MDX query into SQL Server 2008

    We have MDX query based OLAP CUbes.
    To reduce MDX based dependenies, we have to convert MDX based cube to sql server 2008 based queries.
    For this I need expert advise to convert below query to sql server 2008 based query :
    CREATE MEMBER CURRENTCUBE.Measures.[Ack Lost]
                        AS 'Sum(PeriodsToDate([Time].[Year], [Time].CurrentMember ), [Measures].[Lost])',
                        FORMAT_STRING = "#,#",
                        VISIBLE = 1;

    Hi Sachin,
    According to your description, you need to convert the MDX query to T-SQL query, right?
    Your MDX query is calculated measure that return the total value from the first sibling and ending with the given member. In T-SQL query we can use the query as Yogisha provided to achieve the same requirement. Now you need to a tool to convert all the MDX
    related SSAS cube queries to MS SQL Server 2008 based queries.
    Although MDX has some similarities with T-SQL these languages are in many ways different. Beginning to learn and comprehend SQL Server Analysis Services (SSAS) MDX queries can be difficult after one has spent years writing queries in T-SQL. Currently, there
    is no such a tool to convert a MDX query to T-SQL query since the structure difference between MDX and T-SQL. So you need to convert them manually, please refer to the links below to see the details.
    http://www.mssqltips.com/sqlservertip/2916/comparison-of-queries-written-in-tsql-and-sql-server-mdx/
    https://sqlmate.wordpress.com/2013/11/12/t-sql-vs-mdx-2/
    http://technet.microsoft.com/en-us/library/aa216779(v=sql.80).aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Convert a query form to Creation form.

    We create a normal jspx form and drag and drop a view object normal mode.
    When we open the form first record come
    Then We need to change this form to a creation form with new empty record.
    Form include many custom code.We can't recreate form.
    How can we do it?
    it means how Convert a query form to Creation form?
    we are using jdev 10.1.3.2
    Thanks

    You have to add Create method in PageDef.xml and then add expression in RefreshCondition to invoke it (in executables). For more information see:
    http://download-uk.oracle.com/docs/html/B25947_01/web_form006.htm#CACECCJA
    Kuba

  • How to convert my query to SQL Procedure

    Hi all,
    I am running an SQL Query in my page process to set few items on my page.
    begin
    declare
    l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
    begin
    IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
    END IF;
    IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
    END IF;
    FOR i in 1..APEX_APPLICATION.G_F01.count
    LOOP
    l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
    :P32_SUBJECT := l_vc_arr2(1);
    :P32_TYPE := l_vc_arr2(2);
    :P32_BODY := l_vc_arr2(3);
    END LOOP;
    end;
    end;
    It is running perfectly fine. Now i want to convert this query into custom procedure. I am writing follwing code to create SQL Procedure,
    create or replace
    procedure Edit_EmailTemplate as
    begin
    declare
    l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
    begin
    IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
    END IF;
    IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
    END IF;
    FOR i in 1..APEX_APPLICATION.G_F01.count
    LOOP
    l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
    v(P32_SUBJECT) := l_vc_arr2(1);
    v(P32_TYPE) := l_vc_arr2(2);
    v(P32_BODY) := l_vc_arr2(3);
    END LOOP;
    end;
    end;
    but it is not getting compiled. Do anyone know what the problem is???
    With Regards,
    Sunil Bhatia

    hey thanks,
    but my problem is not of creating,
    it has been created and i can see it in sql browser. but it is not getting compiled
    it is returning with the following error
    Compilation failed,line 18 (13:22:08)
    PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 18 (13:22:08)
    PL/SQL: Statement ignoredCompilation failed,line 19 (13:22:08)
    PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 19 (13:22:08)
    PL/SQL: Statement ignoredCompilation failed,line 20 (13:22:08)
    PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 20 (13:22:08)
    PL/SQL: Statement ignored
    my statement is
    create or replace
    procedure Edit_EmailTemplate as
    begin
    declare
    l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
    begin
    IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
    END IF;
    IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
    RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
    END IF;
    FOR i in 1..APEX_APPLICATION.G_F01.count
    LOOP
    l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
    v('P32_SUBJECT') := l_vc_arr2(1);
    v('P32_TYPE') := l_vc_arr2(2);
    v('P32_BODY') := l_vc_arr2(3);
    END LOOP;
    end;
    end;

  • Trying to convert SELECT query to Update query with INNER JOINS

    Assalam O Alaikum!
    I've tried to convert this query of mine but failed.
    I wish to use it for update datasource in data GridView. I'm fetching data with it but converting it to update is not helping giving multiple errors.
    I tried to share the pic but they don't let me do so. Its actually a gridView with check boxes. check the item and update it..
    Here is the query. Please help me with that.
    <pre>
    SELECT [rightsId], [saveRights], [updateRights],
    [viewRights], [deleteRights], [printRights],
    [processRights], [verifyRights], [unProcessRights],
    [unVerifyRights], CONVERT(VARCHAR(100),tblGroup.groupId)as groupId, convert(varchar(100),tblmenu.[menuId])as menuid
    FROM [tblRights] inner join tblMenu ON
    tblMenu.menuId=tblRights.menuId INNER JOIN
    tblGroup ON tblGroup.groupId=tblRights.rightsId
    </pre>

    code is fine the above query works fine with the fetching(select) but when I try to write it with update it doesn't. Here is the asp code. I'm doing nothing with c# or vb.
      <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                DataSourceID="ratGrid" AutoGenerateColumns="False"
                CssClass="GridViewStyle" Width="100%" AllowSorting="True" AutoGenerateEditButton="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2">
                <Columns>
                    <asp:BoundField DataField="rightsId" HeaderText="rightsId" ItemStyle-Width="75px" SortExpression="rightsId" Visible="False">
                    <ItemStyle Width="75px" />
                    </asp:BoundField>
                    <asp:CheckBoxField DataField="saveRights" HeaderText="Save" SortExpression="saveRights" />
                    <asp:CheckBoxField DataField="updateRights" HeaderText="Update" SortExpression="updateRights" />
                    <asp:CheckBoxField DataField="viewRights" HeaderText="View" SortExpression="viewRights" />
                    <asp:CheckBoxField DataField="deleteRights" HeaderText="Delete" SortExpression="deleteRights" />
                    <asp:CheckBoxField DataField="printRights" HeaderText="Print" SortExpression="printRights" />
                    <asp:CheckBoxField DataField="processRights" HeaderText="Process" SortExpression="processRights" />
                    <asp:CheckBoxField DataField="verifyRights" HeaderText="Verify" SortExpression="verifyRights" />
                    <asp:CheckBoxField DataField="unProcessRights" HeaderText="UnProcess" SortExpression="unProcessRights" />
                    <asp:CheckBoxField DataField="unVerifyRights" HeaderText="UnVerify" SortExpression="unVerifyRights" />
                    <asp:BoundField DataField="groupId" HeaderText="groupId" ReadOnly="True" SortExpression="groupId" Visible="False" />
                    <asp:BoundField DataField="menuid" HeaderText="menuid" SortExpression="menuid" ReadOnly="True" Visible="False" />
                </Columns>
                <RowStyle CssClass="RowStyle" BackColor="#FFF7E7" ForeColor="#8C4510" />
                <PagerStyle CssClass="PagerStyle" ForeColor="#8C4510" HorizontalAlign="Center" />
                <SelectedRowStyle CssClass="SelectedRowStyle" BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle CssClass="HeaderStyle" BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle CssClass="AltRowStyle" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>
            <asp:SqlDataSource ID="ratGrid"
                 runat="server"
                ConnectionString="<%$ ConnectionStrings:Conn_Str %>"
                SelectCommand="SELECT [rightsId], [saveRights], [updateRights],
    [viewRights], [deleteRights], [printRights],
    [processRights], [verifyRights], [unProcessRights],
    [unVerifyRights], CONVERT(VARCHAR(100),tblGroup.groupId)as groupId, convert(varchar(100),tblmenu.[menuId])as menuid
    FROM [tblRights] inner join tblMenu ON
    tblMenu.menuId=tblRights.menuId INNER JOIN
    tblGroup ON tblGroup.groupId=tblRights.rightsId"
               FilterExpression="menuId like '{0}%' and [groupId] like '{1}%'" >
                            <FilterParameters>
                <asp:ControlParameter ControlID="ddlmenu" Name="menu"
                        PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ddlgroup" Name="Country"
                        PropertyName="SelectedValue" Type="String" />
                </FilterParameters>
            </asp:SqlDataSource>
    Your table needs key(s) and you need to assign the key as DataKeys property for the GridView to make your UpDate and Delete work without coding.

  • How to convert Access query to Oracle?

    I am trying to convert this query into an Oracle 8i query: -
    SELECT *
    FROM EMPLOYEE
    LEFT JOIN ATTENDANCE ON EMPLOYEE.EMPID = ATTENDANCE.EMPID
    WHERE ATTENDANCE.COL1="#"
    AND ATTENDANCE.COL2>=#1/1/2007#
    AND ATTENDANCE.COL2<Now()
    GROUP BY EMPLOYEE.EMPID, EMPLOYEE.EMPNO;
    How do I put the above query in plain Oracle join operator (+) notation? Thanks for the help.

    Hi,
    Let us take a look at the solution you had suggested -
    EMPLOYEE.EMPID = ATTENDANCE.EMPID (+)
    AND ATTENDANCE.COL1="#"
    AND ATTENDANCE.COL2 >= TO_DATE ('1/1/2007','dd/mm/yyyy')
    AND ATTENDANCE.COL2< SYSDATE;
    Since we are outer joining ATTENDANCE but not using the (+) operator in the later filter conditions; it will still be a normal join i.e. it will not outer join on ATTENDANCE. That is my question.

  • Please convert decode query to case expression

    Please convert decode query to case expression
    Decode(Sign(id), 1, id, null) positive, Decode(Sign(id), -1, id, null) negative from dual;

    this is a serious forums that help people, if you want that we do your "homeworks" i must told you that you should pay us for that.
    Edited by: Fran on 05-jun-2013 23:41
    1002966     
    Handle:      1002966 
    Status Level:      Newbie
    Registered:      Apr 28, 2013
    Total Posts:      20
    Total Questions:      12 (12 unresolved)

  • Converting this query to Oracle-Help

    New account as my old email address has changed so I had to create a new one. Sucks!
    Either way can I please get some help with converting the query below to oracle syntax not microsoft sql. Cheers
    select  eventtypeid as Payment_Type,
         sum(commission_amount) as commission_amount,
         startdate as commission_date
    from
    SELECT distinct
              PERIOD.STARTDATE,
              Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE,
    case when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('2573','185')
         then 'D'
         when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('1126','1055')
         then 'O'
         when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('789','4000','785','871','1028','743')
         then 'R'
    else Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE
    end as SDC,
              Master_Usage.GENERICATTRIBUTE2 AS Service_Id,
              Master_Usage.EVENTTYPEID,
              sum(Master_Usage.CONTRIBUTIONVALUE) AS Commission_Amount
    FROM              Master_Usage INNER JOIN PERIOD
                   ON Master_Usage.PERIODSEQ = PERIOD.PERIODSEQ
              INNER JOIN (select distinct
                        lastname,
                        super_distributor_code,
                        distributor_code,
                        participantid,
                        startperiod
                   from Dealer_Hierarchy_107_114
                   where startperiod in ('107','108','110','111','112','114')
                   AND NOT POSITIONTYPEID LIKE 'MI %'
                   and not super_distributor_code = 'null' or distributor_code = 'null') as dealer_hierarchy
                   ON Master_Usage.GENERICATTRIBUTE1 = dealer_hierarchy.PARTICIPANTID and dealer_hierarchy.startperiod in ('107','108','110','111','112','114')
    WHERE          
              (NOT Master_Usage.PRODUCTID = 'IDDV' OR Master_Usage.PRODUCTID IS NULL)
              AND Master_Usage.PERIODSEQ in ('107','108','110','111','112','114')
              and Dealer_Hierarchy.startperiod in ('107','108','110','111','112','114')
              and Master_Usage.NAME not like '%revenue%'
              and Master_Usage.name not like '%GST%'
    group by      PERIOD.STARTDATE,
              Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE,
              Master_Usage.GENERICATTRIBUTE2,
              Master_Usage.EVENTTYPEID
    ) as asf
    group by asf.EVENTTYPEID,
          startdate
    order by commission_amount desc

    please see the bold section,
    could that be the reason ??
    select eventtypeid as Payment_Type,
         sum(commission_amount) as commission_amount,
         startdate as commission_date
    from
    SELECT distinct
              PERIOD.STARTDATE,
              Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE,
    case when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('2573','185')
         then 'D'
    when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('1126','1055')
         then 'O'
    when Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE in ('789','4000','785','871','1028','743')
         then 'R'
    else Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE
    end as SDC,
              Master_Usage.GENERICATTRIBUTE2 AS Service_Id,
              Master_Usage.EVENTTYPEID,
              sum(Master_Usage.CONTRIBUTIONVALUE) AS Commission_Amount
    FROM      Master_Usage INNER JOIN PERIOD
                   ON Master_Usage.PERIODSEQ = PERIOD.PERIODSEQ
              INNER JOIN (select distinct
                        lastname,
                        super_distributor_code,
                        distributor_code,
                        participantid,
                        startperiod
                   from Dealer_Hierarchy_107_114
                   where startperiod in ('107','108','110','111','112','114')
                   AND NOT POSITIONTYPEID LIKE 'MI %'
                   and not (super_distributor_code = 'null' or distributor_code = 'null') as dealer_hierarchy
                   ON Master_Usage.GENERICATTRIBUTE1 = dealer_hierarchy.PARTICIPANTID and dealer_hierarchy.startperiod in ('107','108','110','111','112','114')
    WHERE      
              (NOT Master_Usage.PRODUCTID = 'IDDV' OR Master_Usage.PRODUCTID IS NULL)
              AND Master_Usage.PERIODSEQ in ('107','108','110','111','112','114')
              and Dealer_Hierarchy.startperiod in ('107','108','110','111','112','114')
              and Master_Usage.NAME not like '%revenue%'
              and Master_Usage.name not like '%GST%'
    group by      PERIOD.STARTDATE,
              Dealer_Hierarchy.SUPER_DISTRIBUTOR_CODE,
              Master_Usage.GENERICATTRIBUTE2,
              Master_Usage.EVENTTYPEID
    ) as asf
    group by asf.EVENTTYPEID,
         startdate
    order by commission_amount desc

  • Converting SAP Query to Report Program

    Hello Experts,
    I'm stuck up with an issue.
    I want to convert SAP query into a report program as the things which I need to implement is not possible with SAP Query anymore.
    So I need to convert SAP query to Report program.
    I'm very much aware about the SQ01--> Query --> More functions --> Display Report Program
    But this Report Program generates is AQ..................... but if you see the code there will be buch of dynamic calls not as clear as ABAP code and not much flexibility to modify...
    Please Provide a solution to this.
    Regards,
    Titiksha

    Hi Bhange,
    Glen Anthony has said very well and I support him. Even I suggest you to ignor the report generated with Query and develop a new report with the required business logic.
    Regards,
    Vijay

  • How to convert sql query to oracle query?

    Hi all,
    Hope doing well,
    sir i am using oracle database where i am running my sql query in oracle. but this query is not working properly. i used sql developer translation scratch editor to convert that.
    it's converted but i am not getting the exact value.
    which i was getting in sql server.
    here is my query below:
    SELECT C.*,ISNULL(P.Comp_Name,'') + ' (' + ISNULL(P.Comp_ID,'') + ')' Parent FROM Comp_Master C LEFT JOIN Comp_Master P ON C.Parent_ID = P.Comp_ID Where C.Comp_ID='C02'
    please convert it into oracle so that i can use this query
    thanks in advance.

    Try --
    1. Use NVL instead of isNull
    2. Use *||* instead of +*
    /* Formatted on 9-13-2012 4:39:09 PM (QP5 v5.163.1008.3004) */
    SELECT c.*, NVL (p.comp_name, '') || ' (' || NVL (p.comp_id, '') || ')' parent
        FROM comp_master c LEFT JOIN comp_master p ON c.parent_id = p.comp_id
    WHERE c.comp_id = 'C02'
    PS - Do remember to mark the solutions as Helpful or Correct. Thanks for understanding.

  • Issue in converting sql query to oracle

    Hi Friends,
    I have a sql query as follows,
    Select Name From SysObjects Where XType = 'U' And Name = @NameI want to convert this to oracle. I have tried to convert this in someways. But I'm getting errors only. Please anyone help me to fix this issue.
    Thanks,
    Ram

    Most Oracle dictionary views come in DBA_, ALL_ and USER_ flavours. Probably you don't have privileges to view DBA_OBJECTS, in which case try ALL_OBJECTS or <a gref="http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2005.htm">USER_OBJECTS</a>.
    Based on what I read, you might need something like
    SELECT * FROM all_objects WHERE owner &lt;> 'SYS' AND object_type = 'TABLE'btw a sure way to wind up Oracle professionals is to use "SQL" to mean another DBMS product and not Structured Query Language. As you may have noticed, we have SQL over here as well.

  • SAP Quickview: converting to Query

    Hi,
    I've created a quickview, and this quickview can be used for other users, and I want to convert this quickview to a quey.
    If I go to the query screen (SQ01), there's the 'convert quickview' functionality (Menu: Query --> convert quickview). But this function is grayed out in my system, as well as the IDES sytem. I think I'm missing a step which hinders me in creating the query.
    Can anyone help, will award points!
    Kind regards,
    Mark

    Mark,
    It is simple you need to change the "Query area" to "Standard area - Client Specific". Currently you are checking in "Global area - Cross Client".
    In SQ01 transaction, you need to use menu path Environment--->Query Areas. Select "Standard Area - Client Specific". Now try the menu: Menu: Query --> convert quickview.
    Hope this resolves your problem...Reward your points,
    Regards,
    Prasobh

  • How to convert the query to function

    Please help to convert the below given query to a function :
    SELECT
      ITEM_CODE, ITEM_NAME,
      ROUND(OPSTK/CNV/ML,2) OPSTK, ROUND(OPVAL,3)OPVAL,
      ROUND(INQTY/CNV/ML,2) INQTY, ROUND(INVAL,3) INVAL,
      ROUND(OUTQTY/CNV/ML,2) OUTQTY,ROUND(OUTVAL,3)OUTVAL,
      ROUND((NVL(OPSTK,0)+NVL(INQTY,0)-NVL(OUTQTY,0))/CNV/ML,2) CLSTK,
      ROUND((NVL(OPVAL,0)+NVL(INVAL,0)-NVL(OUTVAL,0)),3) CL_VAL
    FROM
      SELECT ITEM_CODE, ITEM_NAME, IU_CONV_FACTOR CNV, IU_MAX_LOOSE_1 ML
      FROM   ITEM,ITEM_UOM
      WHERE  ITEM_CODE = IU_ITEM_CODE AND IU_UOM_CODE = ITEM_UOM_CODE
      SELECT SL_ITEM_CODE OP_ICODE,
             SUM(DECODE(RCVD_ISSD,'R',1,'I',-1)*QTY_BU) OPSTK,
             ROUND(SUM(DECODE(RCVD_ISSD,'R',1,'I',-1)*VAL_1),2) OPVAL
      FROM   STK
      WHERE  DT <  TO_DATE(:P249_DATE1,'DD-MM-YYYY')
      GROUP BY SL_ITEM_CODE 
      SELECT SL_ITEM_CODE TX_ICODE,
             SUM(DECODE(RCVD_ISSD,'R',1)*QTY_BU)INQTY,
             SUM(DECODE(RCVD_ISSD,'R',1)*VAL_1) INVAL,
             SUM(DECODE(RCVD_ISSD,'I',1)*QTY_BU)OUTQTY,
             SUM(DECODE(RCVD_ISSD,'I',1)*VAL_1) OUTVAL
      FROM   STK
      WHERE  DT BETWEEN TO_DATE(:P_DATE1,'DD-MM-YYYY')
      AND    TO_DATE(:P249_DATE2,'DD-MM-YYYY')
      GROUP BY SL_ITEM_CODE
    WHERE ITEM_CODE = OP_ICODE(+)
    AND   ITEM_CODE = TX_ICODE(+)
    --AND   ITEM_CODE LIKE :P_ITEMCODE
    ORDER BY ITEM_CODEYogesh

    create or replace type typ_stk is object(
      ITEM_CODE number, ITEM_NAME varchar2(100) ,
      OPSTK number, OPVAL number,
      INQTY number ,  INVAL number,
       OUTQTY number ,OUTVAL number,
       CLSTK number,
       CL_VAL number
    create or replace function fn_stk return typ_stk is
    v_ITEM_CODE number;
    v_ITEM_NAME varchar2(100) ;
    v_OPSTK number;
    v_OPVAL number;
    v_INQTY number ; 
    v_INVAL number;
    v_OUTQTY number ;
    v_OUTVAL number;
    v_CLSTK number;
    v_CL_VAL number;
    begin
      select 1,'item',2,3,4,5,6,7,8,9 into
      v_ITEM_CODE ,
    v_ITEM_NAME ,
    v_OPSTK ,
    v_OPVAL ,
    v_INQTY , 
    v_INVAL ,
    v_OUTQTY ,
    v_OUTVAL ,
    v_CLSTK ,
    v_CL_VAL
      from dual;
      return typ_stk(v_ITEM_CODE ,
                        v_ITEM_NAME ,
                        v_OPSTK ,
                        v_OPVAL ,
                        v_INQTY , 
                        v_INVAL ,
                        v_OUTQTY ,
                        v_OUTVAL ,
                        v_CLSTK ,
                        v_CL_VAL);
    end fn_stk; 
    select treat(fn_stk as typ_stk).item_code item_code,
           treat(fn_stk as typ_stk).ITEM_NAME ITEM_NAME,
           treat(fn_stk as typ_stk).OPSTK OPSTK,
           treat(fn_stk as typ_stk).OPVAL OPVAL,
           treat(fn_stk as typ_stk).INQTY  INQTY,
           treat(fn_stk as typ_stk).INVAL  INVAL ,
           treat(fn_stk as typ_stk).OUTQTY OUTQTY,
           treat(fn_stk as typ_stk).OUTVAL OUTVAL,
           treat(fn_stk as typ_stk).CLSTK CLSTK,
           treat(fn_stk as typ_stk).CL_VAL CL_VAL
      from dualare you expecting something like this ?

  • Converting Oracle query to Sql Server with date manipulation

    The following SSIS statement works great in Oracle, and it parses successfully in the "Sql Task" window. In Oracle it returns
    this result:
    FROM_DT              THRU_DT
    16-Jan-2014      23-Jan-2014
    select
    case
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=7 then to_date('24'||to_char(add_months(sysdate,-1),'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=15 then to_date('01'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=23 then to_date('08'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    else to_date('16'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    end as from_dt,
    case
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=7 then trunc(last_day(add_months(sysdate,-1)))
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=15 then to_date('07'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    when to_char(to_date(sysdate,'dd-mon-yyyy'),'dd') <=23 then to_date('15'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    else to_date('23'||to_char(sysdate,'mmyyyy'),'ddmmyyyy')
    end as thru_dt
    from sys.dual
    How can I convert this to Sql Server ?

    >>You mean you get the data from Oracle and tries to insert it into SQL Server?
    - no, sorry, I want to convert the syntax to Sql Server
    >>Are
    you running the query in OLEDB provider connected to the Oracle's database?
    - yes, this works fine now (after fixing this redundancy:
    to_char(to_date(sysdate,'dd-mon-yyyy'),'dd')change toto_char(sysdate,'dd')

  • Converting Oracle query to Hibernate

    0 down vote favorite
    share [fb] share [tw]
    considering I have Txn_Summ_Dec as a domain object (Entity) with all the fields used in the query how would I convert the SQL query below to Hibernate Query (ether HQL or Criteria api)..
    What the query does: Given a date range as input the query counts distinct users grouped by date, eventdesc and left joins with all the dates in the date range so resultset contains user counts for all dates in the range for all events.
    select
        d.dateInRange as dateval,
        eventdesc,
        nvl(td.dist_ucnt, 0) as dist_ucnt
    from (
        select
            to_date('03-NOV-2011','dd-mon-yyyy') + rownum - 1 as dateInRange
        from all_objects
        where rownum <= to_date('31-DEC-2011','dd-mon-yyyy') - to_date('03-NOV-2011','dd-mon-yyyy') + 1
    ) d
    left join (
        select
            currentdate,
            count(distinct(grauser_id)) as dist_ucnt,
            eventdesc
        from
            txn_summ_dec
        group by currentdate, eventdesc
    ) td on td.currentdate = d.dateInRange order by d.dateInRange ascThe query runs successfully on oracle returning the required result
    Edited by: EJP on 30/01/2012 20:12: added {noformat}{noformat} tags on your behalf, to make your code legible.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    ow006921 wrote:
    I think the question is, why would you want to convert a complex query like that to Hibernate syntax? Hibernate is an application layer superimposed over SQL and JDBC, intended to simplify your coding and provide a more object-oriented interface, best suited to simple cases of table i/o. It does not improve upon or substitute for the power of SQL.
    For something this complex, I would capture the SQL in a view or stored procedure on the database and call that from the client, either with Hibernate or straight JDBC.
    Just my opinion.
    Howard HydeYour opinion is very valid, but moot in this case. Upon my reply I expected one of two things:
    - silence (what I got; the OP looks for an easier way to make someone else solve his problems)
    - a second attempt at outsourcing work by posting something along the lines of "Please. I read the linked article but I couldn't figure it out. Can you please post some sample code?"
    When you've been around this forum for a while, you learn to identify the people who don't have a real problem other than being lazy.

Maybe you are looking for

  • Can I create a photo album to embed in my website?

    I would like to create a photo album to embed in my website so visitors to the site could view it online. Can anyone tell me how, please? I am new to the photo publishing world...!) Thank you. Marion

  • Inbound Delivery via Idoc with more than 1 line fails

    Hi @ all, i try to replicate inbound deliveries from an external system to SAP EWM using Idocs (SHP_IBDLV_SAVE_REPLICA02 with MessageType SHP_IBDLV_SAVE_REPLICA). If there's only one position in inbound delivery it works, but if i try with two or mor

  • Page Navigation not working

    I have moved my project from Early release to creator2 I have followed all the steps suggested changing the com.sun.web.ui to com.sun.rave.web.ui etc, etc. Now I have a few pages that don't do anything when a button or action is pressed. I end up get

  • Custome field addition in production order

    Hello All, I want to add one custom field in production order. My abaper tried "PPCO0012 enhancement for displaying/changing order header data" enhancement and SAP version is 4.7. But it is inconsistent. Can anyone suggest me other way to add one fie

  • When typing an e-mail it sometimes disappears (moves to the right) off the screen

    When typing an e-mail message it sometimes disappears (moves of the screen) to the right for no apparent reason. What's happening?  Robin