SQL query not calculating

SQL query not calculating
gross_amount is giving the value of extended_amount and the gross_price_rc is giving the value of unit_selling_price
select customer_trx_line_id,
( extended_amount / 1- (decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) GROSS_AMOUNT,
( unit_selling_price /1-(decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) gross_price_rc
from ra_customer_trx_lines_all
where attribute6 is not null or attribute7 is not null or attribute8 is not null or attribute9 is not null
whats the isuue here??
Thanks

decode(attribute7,null,0)Looking at it again, this always returns 0 or NULL, so it not really surprising
DECODE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions040.htm#i1017437
CASE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions004.htm#i1033392

Similar Messages

  • Inline transform for Sql Query not working in SAP MII 12.1 Version 12.1.8 B

    Hi All,
    I applied an xslt for an sql query which returns an xml file.
    I used inline transform icon in sql query to load an xsl file which has to return me a string
    Any idea why is not working for me..?
    My Sample XML file:
                                     <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="/XMII/CM/BatchDisposition/BatchQueueManagement/StyleSheets/ProductXsl.xsl"?>
    <Rowsets DateCreated="2011-05-05T07:27:45" EndDate="2011-05-05T07:27:45" StartDate="2011-05-05T06:27:45" Version="12.1.8 Build(20)">
         <Rowset>
              <Columns>
                   <Column Description="ProductName" MaxRange="1" MinRange="0" Name="ProductName" SQLDataType="12" SourceColumn="ProductName"/>
              </Columns>
              <Row>
                   <ProductName>Asprin 100mg Tablets 12 x10 strip</ProductName>
              </Row>
              <Row>
                   <ProductName>Asprin 300mg Tablets 12 x10 strip</ProductName>
              </Row>
              <Row><ProductName>Ibprooven 200mg Tablets 12 x 10 strip</ProductName></Row>
              <Row><ProductName>RipTide 50mg Tablets 40 x10 strip</ProductName></Row>
              <Row><ProductName>Seroquel 200mg Tablets 6 x10 strip</ProductName></Row>
              <Row><ProductName>Seroquel 400mg Tablets 12 x10 strip</ProductName></Row>
         </Rowset>
    </Rowsets>
    My Sample XSl File:
                                    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
         <xsl:text>["</xsl:text>
         <xsl:for-each select="Rowsets/Rowset/Row">
              <xsl:value-of select="ProductName"/>
              <xsl:if test="position() &lt; last()">
                   <xsl:text>","</xsl:text>
                    </xsl:if>
              <xsl:if test="position()=last()">
                           <xsl:text>"]</xsl:text>
                    </xsl:if>
         </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Any Suggestions  are Welcome:
    Thanks

    Something like this should work...
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
              <Rowsets DateCreated="{Rowsets/@DateCreated}" Version="{Rowsets/@Version}" StartDate="{Rowsets/@StartDate}" EndDate="{Rowsets/@EndDate}">
                   <xsl:copy-of select="/Rowsets/FatalError"/>
                   <xsl:copy-of select="/Rowsets/Messages"/>
                   <Rowset>
                   <Columns>
                        <Column Description="Mycol1" MaxRange="1" MinRange="0" Name="Mycol1" SQLDataType="12" SourceColumn="Mycol1" />
                   </Columns>
                   <Row>
                   <Mycol1>
                   <xsl:text>["</xsl:text>
                        <xsl:for-each select="/Rowsets/Rowset/Row">
                             <xsl:value-of select="." />
                             <xsl:choose>
                                  <xsl:when test="position() &lt; last()"><xsl:text>","</xsl:text></xsl:when>
                                  <xsl:otherwise><xsl:text>"]</xsl:text></xsl:otherwise>
                             </xsl:choose>
                        </xsl:for-each>
                   </Mycol1>
                   </Row>
                   </Rowset>
              </Rowsets>
         </xsl:template>
    </xsl:stylesheet>

  • Sql query not execute

    Hi Forum
    i made an application which run on JRun server.
    In many of my jsps i used sql query like this:
    " select id, name, rollno from student where add = 'jj';"
    and retrieve the record from resultset like this:
    rs.getString("id");
    rs.getString("name");
    rs.getString("rollno");
    I got no error.
    BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
    rs.getString("name");
    rs.getString("id");
    rs.getString("rollno");
    i got the error:
    java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
    I can not understand what is the problem ?
    all the datatypes are correct.
    all coding is correct.
    and everything is correct.
    pls help me & suggest a solution.
    is there any problem of jdbc API OR of JRUN SERVER SETTINGS?
    thanks
    mail me at [email protected]
    Arvind Goel

    I would advise against ever using SELECT * - the order of the columns is undetermined so you're bound to hit this problem sooner or later. Besides, it assumes the column names and you know what happens when you assume things...
    I would recommend retrieving only the columns you need, in the order you want them and to call ResultSet.getXXX for each of the columns, in order.

  • Using Parameters in SQL-Query not only in where clauses

    Hi,
    I try to use Publisher parameters in the SQL Query from a Data Set.
    All of them have default values.
    So far, this is no problem, unless I try to use such a parameter value as an ordinary attribute value:
    >
    select
         case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."BETR_TEIL"
                                            else :pv_some_Text end                                                                  as Betr_Teil,
         case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM"
                                            else :pv_some_Text end                                                        as Suva_Nr,
         case when (:pv_Group = 'no') then "DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH"
                                            else sum("DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") end      as Vollbesch
    from "GDWH05"
    where
         "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in (:pv_nim100)
         fetch first 65001 rows ONLY
    >
    The parameters 'pv_Group' and 'pv_nim100' are working fine. (when or where clauses)
    The parameter 'pv_some_Text' unfortunately not. (simple literals)
    When I try to validate the above SQL, I get the following Error:
    <font color="red">
    java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46033] Datatype: 25 is not supported.
    </font>
    After use a cast function:
    >
    else CAST(:pv_some_Text AS CHARACTER)
    >
    I get this ERROR:
    <font color="red">
    java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 19002] Incorrect use of parameters. The parameters used in CAST cannot be resolved without ambiguity.
    </font>
    We use OBIEE 11.1.1.6.4 on a Win64-System.
    Thank's for any help.

    Hi Alex,
    let's leave away any unnecessary details.
    This is the SQL, inserted in the window 'Edit Data Set' of BIP Data Model:
    >
    select
         '--1'     as Betr_Teil,
         '--2'      as Suva_Nr,
         sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
    from "GDWH05"
    where
         "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
         fetch first 65001 rows ONLY
    >
    Everything is fine when I click OK, the script goes back to the metadata.
    Let's try this script with bind values in ORACLE SQL Developer.
    This SQL is the physical part, found in the OBIEE-Log (Log level 5), except the bind values. Therefore we find, in the where clause, the join. In the logical sql, we don't have to join, because it's handled in the Common Enterprise Information Model (CEIM)
    >
    with
    sawith0 as
    select
    sum(t39617.ris_vollbesch) as c1
    from
    dm15d_betriebsteil t39455,
    dm15k_ris_fakten_pro_btt_jhr t39617
    where
    t39455.id_betriebsteil = t39617.id_betriebsteil
    and t39455.suva_nr_form = '122-4.4'
    select
    d1.c1 as c1,
    d1.c2 as c2,
    d1.c3 as c3
    from
    select
    :pv_some_text as c1,
    :pv_some_text as c2,
    sum(d1.c1) as c3
    from
    sawith0 d1
    d1
    where
    rownum <= 65001
    >
    This SQL works fine, even with bind values for 'pv_some_text'.
    But, when using the following SQL in the BIP Data Model:
    >
    select
         :pv_Text as Betr_Teil,
         :pv_Text as Suva_Nr,
         sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
    from "GDWH05"
    where
         "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
         fetch first 65001 rows ONLY
    >
    The following ERROR occurs:
    <font color="red">java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46008] Internal error: File server\Query\Optimizer\ServiceInterfaceMgr\Utility\Src\SQOIUTypeVisitor.cpp, line 643.</font>
    In my opinion, either I use a wrong syntax, or BIP has a problem with parsing the script.
    Thank you for your most welcome help.

  • SQL Query Not working

    Hi All,
    Please help with the error ORA-00923: FROM keyword not found where expected.
    I am trying to execute the following SQL query.
    SELECT
    CASE
    WHEN (Grouping("PRICECATEGORY"."PriceCategoryName")=1) THEN "PriceCatTotal"
    ELSE "PRICECATEGORY"."PriceCategoryName"
    END AS "PRICECATEGORY"."PriceCategoryName",
    CASE
    WHEN (Grouping("LINEITEM"."LineDescription")=1) THEN "LineTotal"
    ELSE "LINEITEM"."LineDescription"
    END AS "LINEITEM"."LineDescription" ,
    *"INVOICE"."InvoiceDate",*
    Sum("TRANSACTION"."TotalPrice") as "TotalPrice",
    Sum("INVOICE_CHILD"."QUANTITY") as "Quantity"
    FROM "LINEITEM","INVOICE","TRANSACTION","PRICECATEGORY", "INVOICE_CHILD"
    WHERE "TRANSACTION"."InvoiceID"="INVOICE"."InvoiceNumber"
    and      "TRANSACTION"."PriceCategoryID"="PRICECATEGORY"."PriceCategoryID"
    and      "INVOICE_CHILD"."INVOICEID"="INVOICE"."InvoiceID"
    and      "PRICECATEGORY"."PriceCategoryID"="TRANSACTION"."PriceCategoryID"
    and      "TRANSACTION"."PriceCategoryID"="PRICECATEGORY"."PriceCategoryID"
    and      "PRICECATEGORY"."PriceCategoryID"="TRANSACTION"."PriceCategoryID"
    and      "LINEITEM"."LINEITEMID"="TRANSACTION"."LineItemID"
    and      "LINEITEM"."PRICECATEGORYID"="PRICECATEGORY"."PriceCategoryID"
    and     "INVOICE"."InvoiceDate" >= :STARTDATE and "INVOICE"."InvoiceDate" <= to_date(:ENDDATE,'DD-MON-YY')+1
    GROUP BY "PRICECATEGORY"."PriceCategoryName", "LINEITEM"."LineDescription" WITH ROLLUP
    I am using a from keyword at the right place and all the aliases are properly used.
    Please advice.
    Regards,
    Sandeep Reddy

    Jaydip and Jeff are correct:
    <li>Jaydip points out that <tt>"PRICECATEGORY"."PriceCategoryName"</tt> and <tt>"LINEITEM"."LineDescription"</tt> are not valid column alias names. They must be unqualified, nonquoted/quoted identifiers.
    <li>Jeff indicates that <tt>WITH ROLLUP</tt> is not Oracle SQL syntax, and provides a sample of the required ROLLUP/CUBE clauseOracle SQL <tt>ROLLUP/CUBE clause</tt>.
    Additionally, <tt>TRANSACTION</tt> is an Oracle keyword and therefore a poor choice as a database identifier: change the name of this table as soon as possible.
    You're having this problem because not all "SQL" is created equal. Your OdeToCode source appears to be a site dealing with Microsoft technologies (SQL Server in this case). Unless you are very familiar with Oracle and SQL Server and the inherent differences between them you'd be advised to stick to purely Oracle resources (I know I do). There are plenty of good Oracle resources out there.
    You'll also find it a lot easier to write, read and spot problems in SQL and PL/SQL code if you avoid using quoted identifiers (please tell us the database objects don't have case-sensitive names?) and use short table aliases rather than full table names. And we'll find it easier to help you on this forum if you post code samples wrapped in \...\wrapped in <tt>\...\</tt> tags.

  • Sql query not executed using recordset

    Hi All,
    I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
      Dim AltProc  as string
      AltProc = " USE [DB_name]" & Environment.NewLine
      AltProc = AltProc & " GO " &  Environment.NewLine
      AltProc = AltProc & " ALTER proc [proc_name] " &  Environment.NewLine
    '---------------------and so on
    Orec.DoQuery(AltProc)
    this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error.  strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
    any one has any idea?
    thanks in advance,
    Binita

    HI Binita
    The reason:
    GO is the "command" delimiter of MS Query Editor.
    It is not working with RecordSet Object.
    In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
    IN SQL 2008 use the Fully Qualified name instead of GO:
    Dim AltProc  as string
      AltProc = " ALTER proc [DB_name].[dbo].[proc_name] "  + vbcrlf
    '---------------------and so on
    Orec.DoQuery(AltProc)
    it is not working on MS SQL 2008 i have tried.
    'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
    Regards,
    J.
    Edited by: Janos  Nagy on Jun 22, 2009 2:55 PM

  • ORA-00904 ON A PLSQL QUERY RETURNING SQL QUERY ( NOT ALWAYS )

    Running a classic report , we sometimes face the error :
    <pre>failed to parse SQL query:
    ORA-00904: : invalid identifier
    Even when using the same parameters, sometimes the report runs and some others we get the error.
    The report is called by a url from a different page
    f?p=&APP_ID.:500:&APP_SESSION.:FLOW_EXCEL_OUTPUT_R&P503_RUN_REGION_ID._el:NO::P500_RUN_RG,P500_RG11_FILTER1:1,&P503_FILTER1.
    THE EVNVIRONMENT IS THE FOLLOWING
    ORACLE DATABASE 11g      Enterprise Edition Release 11.2.0.2.0 -64bit
    Apex                     Application Express 4.1.0.00.32
    In the apex on the same workspace we have 2 copies of the same application having different schema.
    We did not face this problem in Oracle 10g

    hello,
    I send you the function. rs_check_limit .
    In one case when i tried to debug in order to understand the error, the function was not fired.
    FUNCTION rs_check_limit ( p_trade_date_from date
    , p_trade_date_to date, p_session_id number , p_user_id varchar2
    , p_pct_sum_prcp_cd number
    ,p_rs_list_exclude varchar2 default ' '
    return rs_check_limit_tb PIPELINED
    is
    v_data rs_check_limit_tp :=rs_check_limit_tp ( null, null,null, null,null, null,null, null,null, null );
    CURSOR exec_trades_prcp_cur (vc_risk_date_from date
    , vc_risk_date_to date
    , vc_rs_list_exclude varchar2
    is
    select PRCP_CD
    , clr_sys_cd
    , clr_acc_cd
    ,avg( exec_trades_value_mkt ) avg_exec_trades_prcp
    ,SUM( exec_trades_value_mkt ) sum_exec_trades_prcp
    from
    select trd_dt, PRCP_CD , clr_sys_cd
    , clr_acc_cd , sum ( exec_trades_value_mkt ) exec_trades_value_mkt
    from
    select lst_cmpt_dt trd_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd
    ,SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where 1=1
    and lst_cmpt_dt > vc_risk_date_from -1
    and lst_cmpt_dt <= vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by lst_cmpt_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd
    UNION ALL
    select trunc ( apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt,- 1) ) trd_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd, SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where trd_dt = apx_rs_risk_info.get_d_n_cur ( lst_cmpt_dt , 2 )
    and lst_cmpt_dt > apx_rs_risk_info.get_d_n_cur (vc_risk_date_from ,1 )-1
    and lst_cmpt_dt < vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt , -1 ) ,PRCP_CD , clr_sys_cd
    , clr_acc_cd
    group by trd_dt, PRCP_CD , clr_sys_cd
    , clr_acc_cd
    group by PRCP_CD , clr_sys_cd
    , clr_acc_cd
    CURSOR exec_trades_all_cur (vc_risk_date_from date
    , vc_risk_date_to date
    , vc_rs_list_exclude varchar2)
    is
    select SUM( exec_trades_value_mkt ) sum_exec_trades_all -- óõíïëéêÞ çìåñÞóéá áîßá óõíáëëáãùí áãïñÜò
    , avg( exec_trades_value_mkt ) avg_exec_trades_all
    from
    select trd_dt, sum( exec_trades_value_mkt ) exec_trades_value_mkt
    from
    --gia  T : T, T-1 ,  T-2
    select lst_cmpt_dt trd_dt , SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where 1=1
    and lst_cmpt_dt > vc_risk_date_from -1
    and lst_cmpt_dt <= vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by lst_cmpt_dt
    union all
    --gia  T EPIPLEON: T-3
    select apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt,-1) trd_dt , SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where trd_dt = apx_rs_risk_info.get_d_n_cur ( trunc ( lst_cmpt_dt ) , +2 )
    and lst_cmpt_dt > apx_rs_risk_info.get_d_n_cur (vc_risk_date_from ,1 )-1
    and lst_cmpt_dt < vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt , -1 )
    group by trd_dt
    exec_trades_prcp_row exec_trades_prcp_cur%rowtype;
    exec_trades_all_row exec_trades_all_cur%rowtype;
    i number := 0;
    tmp varchar2(4) := null;
    procedure feed_table is
    BEGIN
    v_data.prcp_cd := exec_trades_prcp_row.prcp_cd;
    v_data.clr_sys_cd := exec_trades_prcp_row.clr_sys_cd;
    v_data.clr_acc_cd := trim(exec_trades_prcp_row.clr_acc_cd);
    v_data.member_id := RS_GET_PRCP_MEMBER_ID(exec_trades_prcp_row.prcp_cd);
    v_data.member_dsc := RS_GET_PRCP_DSC(exec_trades_prcp_row.prcp_cd);
    v_data.sumTRADES_VALUE_PRCP_CD_T := round( exec_trades_prcp_row.sum_exec_trades_prcp,2);
    v_data.mkt_sumTRADES_VALUE_PRCP_CD_T := round( exec_trades_all_row.sum_exec_trades_all,2) ;
    v_data.avgTRADES_VALUE_PRCP_CD_T := round( exec_trades_prcp_row.avg_exec_trades_prcp,2);
    v_data.mkt_avgTRADES_VALUE_PRCP_CD_T := round( exec_trades_all_row.avg_exec_trades_all,2) ;
    v_data.pct_sum_prcp_cd := round( 100* exec_trades_prcp_row.sum_exec_trades_prcp
    / exec_trades_all_row.sum_exec_trades_all , 2);
    end ;
    begin
    exec_trades_all_row := null;
    open exec_trades_all_cur (vc_risk_date_from => p_trade_date_from
    , vc_risk_date_to => p_trade_date_to
    ,vc_rs_list_exclude => NVL(p_rs_list_exclude ,'.' )
    fetch exec_trades_all_cur INTO exec_trades_all_row;
    close exec_trades_all_cur;
    for exec_trades_prcp_rec in exec_trades_prcp_cur (vc_risk_date_from => p_trade_date_from
    , vc_risk_date_to => p_trade_date_to
    ,vc_rs_list_exclude => NVL(p_rs_list_exclude ,'.' )
    loop
    exec_trades_prcp_row := exec_trades_prcp_rec;
    if exec_trades_all_row.sum_exec_trades_all <> 0 then
    if 100* exec_trades_prcp_row.sum_exec_trades_prcp
    / exec_trades_all_row.sum_exec_trades_all >= p_pct_sum_prcp_cd then
    i := i+1;
    v_data :=rs_check_limit_tp ( null, null,null, null,null, null,null, null,null, null );
    feed_table;
    pipe row ( v_data );
    end if;
    end if;
    end loop;
    end;
    I send you the dll for the type
    CREATE OR REPLACE
    TYPE rs_check_limit_tp as object
    prcp_cd varchar2(10)
    , member_id varchar2(4)
    , member_dsc varchar2(120)
    , clr_sys_cd varchar2(4)
    , clr_acc_cd varchar2(6)
    , avgTRADES_VALUE_PRCP_CD_T number
    , mkt_avgTRADES_VALUE_PRCP_CD_T number
    , sumTRADES_VALUE_PRCP_CD_T number
    , mkt_sumTRADES_VALUE_PRCP_CD_T number
    , pct_sum_prcp_cd number
    and the table dll
    CREATE TABLE rs_mm_rsk_lmts_dtls
    (trd_dt DATE NOT NULL,
    prcp_cd VARCHAR2(10 BYTE) NOT NULL,
    clr_sys_cd CHAR(4 BYTE),
    clr_acc_cd CHAR(10 BYTE),
    sec_isin_cd VARCHAR2(12 BYTE) NOT NULL,
    buys NUMBER(19,0),
    sells NUMBER(19,0),
    buys_value NUMBER(19,6),
    sells_value NUMBER(19,6),
    abs_b_minus_s NUMBER(19,2),
    rsk_prc NUMBER(13,6),
    net_value NUMBER(19,2) NOT NULL,
    sr NUMBER(19,2) NOT NULL,
    mm NUMBER(19,2) NOT NULL,
    lst_cmpt_dt DATE,
    usr_id VARCHAR2(8 BYTE) NOT NULL,
    cmt VARCHAR2(64 BYTE),
    chg_dt DATE,
    gr_b NUMBER(19,2) NOT NULL,
    gr_s NUMBER(19,2) NOT NULL)
    Thank you
    Tonia

  • URGENT (sql query not execute)

    Hi Forum
    i made an application which run on JRun server.
    In many of my jsps i used sql query like this:
    " select id, name, rollno from student where add = 'jj';"
    and retrieve the record from resultset like this:
    rs.getString("id");
    rs.getString("name");
    rs.getString("rollno");
    I got no error.
    BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
    rs.getString("name");
    rs.getString("id");
    rs.getString("rollno");
    i got the error:
    java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
    I can not understand what is the problem ?
    all the datatypes are correct.
    all coding is correct.
    and everything is correct.
    pls help me & suggest a solution.
    is there any problem of jdbc API OR of JRUN SERVER SETTINGS?
    thanks
    mail me at [email protected]
    Arvind Goel

    " select id, name, rollno from student where add =
    'jj';"
    BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
    rs.getString("name");
    rs.getString("id");
    rs.getString("rollno");
    You are retrieving the fields in a different order than what is specified in the select statement.
    Some drivers don't allow that (I don't believe it matters what version of the driver you have.)

  • SQL Query (not OMBPlus) to get Join- and Filter-Conditions

    Hallo,
    I allready used the Views ALL_IV_XFORM_... to get serveral informations on my mappings using SQL-Queries,
    but how can I retrieve the Conditions of an Join- or Filter-Transformation using SQL and not OMBPLUS?
    Thanks in advance
    Frank

    but how can I retrieve the Conditions of an Join- or Filter-Transformation using SQL and not OMBPLUS?if i understood the question correctlly then
    join will be written as
    select * from table_1 , table_2  where table_1.col1=table_2.col2;filter will be written as
    select * from table_1  where table_1.col1='A';

  • Executing sql query(not through sqlfile) from batchfile

    Hi,
    I have written a batchfile below which should execute the sql query. Can someone please help me in modifying the below code. I know we can make use of sql file ,but wanted it to be more robust and hence everything in a single batch file instead of having combination of sqlfile and batchfile.
    @echo off
    set ORACLE_HOME=%RAMBOH%
    set ORACLE_SID=%RAMBSID%
    set path=%RAMBOH%\bin;%RAMBOH%\admin\Ramb_Scripts;%path%
    sqlplus sys/XXX as sysdba
    @echo SET SERVEROUTPUT ON;
    @echo DECLARE
    @echo     v1   DATE;
    @echo BEGIN
    @echo     SELECT SYSDATE INTO V1 FROM DUAL;
    @echo     DBMS_OUTPUT.PUT_LINE(v1);
    @echo END;
    @echo /

    I used the below syntax to execute a procedure
    set ORACLE_SID=orcl
    echo exec MyProcedure;
    echo exit
    )|sqlplus system/manager >MyProcedure.log
    Try making modifications to this and see if this helps you in executing the SQL from the batch file

  • Function used in SQL query not showing the desired results

    I have created a function that gives me the client id but when i am using the function in the query its not giving me any result i.e. 0 rows but if I execute the function sepreatly and put the result of that function in the qurey it is giving me the desired result please have a look on the following and please reply with you expert opinion:
    FUNCTION CODE:
    create or replace function j2
    (usid in varchar2)
    return varchar2
    is
    cidn_in varchar2(4000) := '';
    ls_sep varchar2(1) := ',';
    cursor predicate_cidn
    is
    select
    logical_schema_id
    from
    CLIENT_REGISTRY cr,
    MEMBER_ROLE_CLIENT_ASSIGNMENT mrca,
    MEMBER m
    where
    mrca.base_client_id = cr.base_client_id and
    mrca.member_id = m.member_id and
    cr.schema_in_use_in = '1' and
    m.active_status_id = 'A' and
    upper(mrca.member_id) = upper(usid);
    BEGIN
    for GET_CIDN in predicate_cidn
    loop
    cidn_in := cidn_in || ls_sep || '''' || GET_CIDN.logical_schema_id || '''';
    end loop;
    cidn_in := substr(cidn_in, 2);
    cidn_in := '('||cidn_in||')';
    --dbms_output.put_line(cidn_in);
    return cidn_in;
    END ;
    SQL> select j2('qaa@adp') from dual;
    J2('QAA@ADP')
    ('BASE18','SDK1TEST','SEETHA1CONFIG','BASE09','KAREN2','SIVACONFIG','BASE19','SD
    K1CTEST','VASU1','KAREN5','EVENTS1CTEST','SDK1','ADA1CONFIG','BASE10','VRB1CONFI
    G','CRU2CONFIG','BASE20','SIVATEST','PCOMCONFIG','KP1CONFIG','KAREN4CONFIG','EVE
    NTS1TEST','SUZ3CONFIG','DONG2CONFIG','ED2CONFIG','SIVACTEST','APDCONFIG','EVENTS
    1CONFIG','ESSCONFIG','SIVA','SDK2CONFIG','ED3CONFIG','RAJ4CONFIG','CBRCONFIG','N
    AMRATA2CONFIG','EMIL1','NAMRATA1CONFIG','SDK2CTEST','BVT2CONFIG','MURUGAN1CONFIG
    ','COB1CONFIG','GABY1TEST','CHR1CONFIG','ED4CONFIG','USE1CONFIG','SDK2TEST','DEM
    O1CONFIG','BERNIE1CONFIG','XA1','CAR2TEST','SDK2','ED5CONFIG','PAY1TEST','PAYXCO
    NFIG','KP1TEST','SEAN1CONFIG','CAR2CTEST','VASU1CONFIG','SEAN2CONFIG','KP1CTEST'
    ,'MAU1CONFIG','CONWCONFIG','PAN1CONFIG','MERAJ2','PRA3CONFIG','SEAN5CONFIG','KP1
    ','PRA4CONFIG','CAR2CONFIG','PRA2CONFIG','SEAN6CONFIG','PRA3TEST','RPT','GABY1CT
    EST','SDK3CONFIG','PRA2TEST','SEAN9CONFIG','CAR2','LV1CONFIG','PRA3CTEST','DONG1
    CONFIG','TE1CONFIG','MERAJ2CONFIG','VIV1CONFIG','GABY1','SEAN2','PRA2CTEST','PRA
    3','RPTCONFIG','PRA4CTEST','SEAN3','MITA1CONFIG','PRA2','RPTCTEST','PCOM1CONFIG'
    ,'SS2CONFIG','PAY1CONFIG','SEAN7','ANNCONFIG','BASE11','BASE02','LV2CONFIG','RPT
    TEST','IMPECONFIG','SUR1CONFIG','SREEK2CONFIG','BASE03','SRINU3CONFIG','BDCONFIG
    ','JAY1CONFIG','AMMAN1','PRA1TEST','WPGCONFIG','BASE12','MP5CONFIG','MERAJ1','SR
    INU2CONFIG','XA1CONFIG','RAJ1CONFIG','WPGCTEST','BASE04','CHRIS','RAJSCONFIG','P
    ANKAJ','BASE13','WPGTEST','RAJ3CONFIG','WPG','BASE14','VASU2CONFIG','SRINU1CONFI
    G','BASE05','PRA4TEST','VASU1TEST','PRA5CONFIG','NISH1CONFIG','CHRISCONFIG','SDK
    3TEST','RAJ3TEST','KP2CONFIG','BASE06','DEFPCONFIG','NISH2CONFIG','CHRISCTEST','
    WPSCONFIG','VASU2TEST','BASE15','GABY1CONFIG','PRA5TEST','MITA2CONFIG','BASE07',
    'VASU1CTEST','KP2TEST','VASU2CTEST','LAURA3CONFIG','BASE16','CHRISTEST','WPSTEST
    ','VASU2','KP2CTEST','EVENTS1','BASE17','RAJ2CONFIG','WPSCTEST','BASE08','SREEK1
    CONFIG','ADVE','PRA4','SDK1CONFIG','KP2','KAREN1','CRU1CONFIG','WPS')
    Now if i put the results (cut and paste )in the query it gives me the results
    SQL> select count(*) from baseclient.address_detail where cidn in ('BASE18','SDK1TEST','SEETHA1CONFIG','BASE09','KAREN2','SIVACONFIG','BASE19','SD
    2 K1CTEST','VASU1','KAREN5','EVENTS1CTEST','SDK1','ADA1CONFIG','BASE10','VRB1CONFI
    3 G','CRU2CONFIG','BASE20','SIVATEST','PCOMCONFIG','KP1CONFIG','KAREN4CONFIG','EVE
    4 NTS1TEST','SUZ3CONFIG','DONG2CONFIG','ED2CONFIG','SIVACTEST','APDCONFIG','EVENTS
    5 1CONFIG','ESSCONFIG','SIVA','SDK2CONFIG','ED3CONFIG','RAJ4CONFIG','CBRCONFIG','N
    6 AMRATA2CONFIG','EMIL1','NAMRATA1CONFIG','SDK2CTEST','BVT2CONFIG','MURUGAN1CONFIG
    7 ','COB1CONFIG','GABY1TEST','CHR1CONFIG','ED4CONFIG','USE1CONFIG','SDK2TEST','DEM
    O1CONFIG','BERNIE1CONFIG','XA1','CAR2TEST','SDK2','ED5CONFIG','PAY1TEST','PAYXCO
    8 9 NFIG','KP1TEST','SEAN1CONFIG','CAR2CTEST','VASU1CONFIG','SEAN2CONFIG','KP1CTEST'
    10 ,'MAU1CONFIG','CONWCONFIG','PAN1CONFIG','MERAJ2','PRA3CONFIG','SEAN5CONFIG','KP1
    11 ','PRA4CONFIG','CAR2CONFIG','PRA2CONFIG','SEAN6CONFIG','PRA3TEST','RPT','GABY1CT
    12 EST','SDK3CONFIG','PRA2TEST','SEAN9CONFIG','CAR2','LV1CONFIG','PRA3CTEST','DONG1
    13 CONFIG','TE1CONFIG','MERAJ2CONFIG','VIV1CONFIG','GABY1','SEAN2','PRA2CTEST','PRA
    14 3','RPTCONFIG','PRA4CTEST','SEAN3','MITA1CONFIG','PRA2','RPTCTEST','PCOM1CONFIG'
    15 ,'SS2CONFIG','PAY1CONFIG','SEAN7','ANNCONFIG','BASE11','BASE02','LV2CONFIG','RPT
    16 TEST','IMPECONFIG','SUR1CONFIG','SREEK2CONFIG','BASE03','SRINU3CONFIG','BDCONFIG
    17 ','JAY1CONFIG','AMMAN1','PRA1TEST','WPGCONFIG','BASE12','MP5CONFIG','MERAJ1','SR
    18 INU2CONFIG','XA1CONFIG','RAJ1CONFIG','WPGCTEST','BASE04','CHRIS','RAJSCONFIG','P
    19 ANKAJ','BASE13','WPGTEST','RAJ3CONFIG','WPG','BASE14','VASU2CONFIG','SRINU1CONFI
    20 G','BASE05','PRA4TEST','VASU1TEST','PRA5CONFIG','NISH1CONFIG','CHRISCONFIG','SDK
    21 3TEST','RAJ3TEST','KP2CONFIG','BASE06','DEFPCONFIG','NISH2CONFIG','CHRISCTEST','
    22 WPSCONFIG','VASU2TEST','BASE15','GABY1CONFIG','PRA5TEST','MITA2CONFIG','BASE07',
    23 'VASU1CTEST','KP2TEST','VASU2CTEST','LAURA3CONFIG','BASE16','CHRISTEST','WPSTEST
    24 ','VASU2','KP2CTEST','EVENTS1','BASE17','RAJ2CONFIG','WPSCTEST','BASE08','SREEK1
    25 CONFIG','ADVE','PRA4','SDK1CONFIG','KP2','KAREN1','CRU1CONFIG','WPS');
    COUNT(*)
    228
    BUT if I user the function it gives me no results
    0 rows selected and its taking a loon time to reurn

    This appears to be a duplicate of the question in this thread
    Re: VPD issue Need Assistance ASAP
    where I wrote
    "Your function returns a single string that happens to have a bunch of commas and quotes in it. An IN list generally requires a list of strings, which your function doesn't return.
    You could rewrite the function to be a pipelined table function and then do
    select count(*)
    from baseclient.address_detail
    where cidn in (SELECT cidn
    FROM TABLE(<<your pipelined table function>>))
    However, I would expect it to be easier not to wrap all this into a function and just have your IN clause be the logic in your predicate_cidn cursor.
    Justin
    "

  • SQL query not retrieving special characters in like O', M÷ and û

    Hi,
    I have a sql script to query database. The output is a string. When I execute this script through a Korn shell script to send the query result to a .csv file, it is showing some characters of the output as below.
    The characters O’ is displayed as ?
    The characters M÷ is displayed as ?
    The characters û is displayed as u
    I am able to retrieve the data as it is while running the script through SQL * Plus and spooling the output to a .csv file.
    If anybody is having solutions for this please reply.
    Thanks in advance for your kind help
    Regards,
    Sreesha
    Edited by: user530278 on Oct 18, 2008 2:56 PM

    user530278 wrote:
    Hi,
    I have a sql script to query database. The output is a string. When I execute this script through a Korn shell script to send the query result to a .csv file, it is showing some charcters of the output as below.
    The characters O’ is displayed as ?
    The characters M÷ is displayed as ?
    The characters û is displayed as uThis sounds like an NLS client setting issue.
    Note that there are scenarios where the data is "incorrectly" stored in the database but can be retrieved "successfully" from some clients. This is the case if you specify the same character set at your client as you have as database character set and this client character set setting is wrong, which means you ought to have specified a different client character set than you have in the database.
    Specifying the same character set on client and server prevents any conversion from taking place, so as long as the database can store the data (e.g. multi-byte characters won't be stored correctly in single-byte character set database no matter what you do) it will be stored "as is". If you now retrieve the data using the same setting, it looks correct, but if you use a client with a different character set setting that requires conversion the data will be mangled.
    The database character set can be identified using the dictionary view NLS_DATABASE_PARAMETERS, parameter "NLS_CHARACTERSET".
    The client character set can be identified by issuing the following at the SQL*Plus prompt:
    SQL> @[%NLS_LANG%]You'll get a message similar to:
    "Unable to open file [AMERICAN_AMERICA.WE8MSWIN1252]"
    The string after the dot represents the client character set.
    If you get this:
    Unable to open file "[%NLS_LANG%]"
    then the NLS_LANG client setting is undefined.
    Please follow this very useful link regarding client NLS issues and how to resolve them, in particular to determine what is your correct client NLS_LANG setting:
    http://www.oracle.com/technology/tech/globalization/htdocs/nls_lang%20faq.htm
    I am able to retreive the data as it is while running the script through SQL * Plus and spooling the output to a .csv file.You mean that when using SQL*Plus interactively the data is shown/spooled correctly, whereas if you run a script non-interactively then the data is mangled?
    Note that if you e.g. use "cron" to schedule/execute your script that you need to take care of the Oracle specific environment variables yourself because no logon scripts are executed when cron forks the process to run. May be you need to define the NLS_LANG variable explicitly or call/source the corresponding script to define your default Oracle environment that includes the NLS_LANG setting.
    It probably depends on your environment, operating system, etc. and how you set the Oracle specific settings, e.g. environment variables under Unix, registry settings under Windows etc.
    Use the above mentioned check regarding NLS_LANG setting in the different cases that you encounter to get started.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • SQL Query not working in action performed event of combobox in swing

    hi all..
    i have to retreive from the database based on the item selected in the comboBox.......
    when the program runs for the first time the data of defaultselected item is being displayed...
    but when another item is selected the data is not retrieved from the database....
    i am able to print the selected item but unable to query the database for the selected item
       private void resultsItemStateChanged(java.awt.event.ItemEvent evt) {                                        
    // TODO add your handling code here:
            try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:aa");
                System.out.println("you have selected me : --- >" + results.getSelectedItem().toString());
                sql="SELECT * FROM " + name + " WHERE term = ? ";
                srch2 = conn.prepareStatement(sql);
                srch2.setString(1,results.getSelectedItem().toString());
                rs2 = srch2.executeQuery();
                rs2.next();
                tarea2.setText("\n Definition:"+rs1.getString(3));
                tarea3.setText("\n Description:"+rs1.getString(4));
                tarea4.setText("\n Related Terms:"+rs1.getString(5));
                tarea5.setText("\n Hyperlinks : "+rs1.getString(6));
                tarea6.setText("\n References:"+rs1.getString(7));
                conn.close();
                rs2.close();
            } catch(Exception e){}
    }    please help me to query the database for the selected item
    Thanks in advance...

    hi all..
    i have to retreive from the database based on the item selected in the comboBox.......
    when the program runs for the first time the data of defaultselected item is being displayed...
    but when another item is selected the data is not retrieved from the database....
    i am able to print the selected item but unable to query the database for the selected item
    private void resultsItemStateChanged(java.awt.event.ItemEvent evt) {                                        
    // TODO add your handling code here:
          ResultSet rs2=null;
           PreparedStatement srch2 = null;
            Connection conn1= null;
            Statement us = null;
            try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn1 = DriverManager.getConnection("jdbc:odbc:aa");
               System.out.println("you have selected me : --- >" + results.getSelectedItem().toString());
                 sql="SELECT * FROM " + name + " WHERE term = ?";
                srch2 = conn.prepareStatement(sql);
                srch2.setString(1,results.getSelectedItem().toString());
                rs2 = srch2.executeQuery();
               rs2.next();
                tarea2.setText("\n"+rs1.getString(3));
                tarea3.setText("\n "+rs1.getString(4));
                tarea4.setText("\n"+rs1.getString(5));
                tarea6.setText("\n"+rs1.getString(6));
                tarea5.setText("\n"+rs1.getString(7));
              rs2.close();
              conn1.close();
            } catch(Exception e){
                System.out.println(e);
        After printing for the first time it is showing like this ...
    java.sql.SQLException: ResultSet is closed
    at sun.jdbc.odbc.JdbcOdbcResultSet.checkOpen(JdbcOdbcResultSet.java:6646)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:257)
    at more_info.resultsActionPerformed(more_info.java:301)
    at more_info.access$100(more_info.java:25)
    at more_info$2.actionPerformed(more_info.java:121)
    at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1242)
    at javax.swing.JComboBox.setSelectedItem(JComboBox.java:569)
    at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:605)
    at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:814)
    at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:273)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
    at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:480)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

  • Debugging mode - sql query not showing up in console

    Hi,
    I have turned on the debugging mode via Admin->Server Configuration->Debug Level. Set it to debug mode.
    I restarted the server. I wanted to test if the query will show up if there was an error in the query.
    However I am not seeing any query. It complains that there is some error, but doesn't show what query string it is using.
    Anyone got any idea how I can get query to show up on console (BI Publisher web interface) as opposed to
    going and seeing the log files on the server.
    Please let me know.
    Thanks
    Girija

    Thankyou Vetsrini.
    I will try out custom log table approach.
    I see that there is a way to test pl/sql scripts via the DBMS output
    and for that we need some invoking program like SQL PLUS to get the
    log out into a file.
    However, we wanted to see if there is a way to set Pl/SQL log files
    and get PL/SQL logs when the calling program is BI Publisher.
    regards
    Girija

  • SQL query not working well

    Hi,
    I made a small table with 5 rows and want to make them an sql consult using rownum
    so I'm running
    select * from mytable where rownum = 1;and it gives me the first row but if I change the 1 for a 2 or 3 or 4 or 5 it's says that theres nothing :S
    why?????????????????????
    but if i change for between 1 and 5 it gave me the 4 rows :S :S
    why???????????????????

    AlanWms wrote:
    try this:
    SELECT *
    FROM (
    SELECT bne.*, rownum myrow
    FROM BAN_EVENTOS_CONFIRMACION bne WHERE ROWNUM <=5)
    WHERE myrow = 2;
    Wrong!!! Rows in table are not stored in any specific order. Rows are fetched based on execution plan. So if execution plan changed query will retrieve same rows but they can be fetched in a different order. Bottom line only ORDER BY guarantees order. Without ORDER BY there is no sense to talk about first row, second row, last row or any row position.
    SY.

Maybe you are looking for

  • Could I have some help identifying and fixing dead/stuck/hot pixel?

    Hello, yesterday whilst watching a movie on my Macbook Pro I noticed something on my screen, at first I thought it was just something stuck on the screen but it seems to be an issue with a pixel. I would appreciate help regarding identifying if it's

  • My 4GB Ipod Mini Doesn't Work

    My Ipod Mini stopped working and anytime I try to charge it, the screen displays the Apple logo and then a low battery logo. I tried charging it for more than 12 hours, but the two pictures remain the same. Compaq   Windows XP  

  • Bridge CS5 downloading images

    I'm trying to download my pics from a card reader on a Mac via Bridge rather than Lightroom. It can see my images but when I try to select a destination folder it freezes leaving the only option to force quit. Any suggestions please.

  • Problems with subreports from VB6, helpppppppppp!!!

    Post Author: Alejandro CA Forum: General Hi, everybody, I have problems to see the information from subreports, I dont know what to do. I have reports with 2 or more subreports inside it, I link the subreports with report, but when I try to see it fr

  • Download version will not install on MacBook

    I purchased Version 2.0 as an upgrade download, but it will not install on a MacBook. Is there some trick. I have the multimedia version or so I thought. Thank you, Mike