Insert into table a (select * from table b) - need pk?

Hi there.
I'm going to insert into table FINAL (select * from table STAGING) - same structure but in STAGING the ID column has nulls.
Do I need to provide the ID (primary key) for table FINAL or will it get created based on sequence/trigger?
If I were doing this in a loop I'd get the next val from the sequence but on a simple insert, I'm curious.
thanks!

hmm.. what is ?
it didn't like it.
Error(11,4): PLS-00103: Encountered the symbol "[" when expecting one of the following:     begin case declare exit for goto if loop mod null pragma    raise return select update while with <an identifier>    <a double-quoted delimited-identifier> <a bind variable> <<    close current delete fetch lock insert open rollback    savepoint set sql execute commit forall merge    <a single-quoted SQL string> pipe
9i, sqldeveloper                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How to use insert into...select * from...if source table is huge in size

    The source tables are having crores of data (growing tables). Tables with 4crores, 17cr. We want these tables to be copied frequently to our local database. Previously it was done by export-import through windows scheduled task. but now we are planning to do it as database jobs. We are fetching the datas with query
    insert into dest_tablee( select * from source_table@dblink) when we tried with this it was throwing exception like enough table space is not there. And also it was found that frequent commits has to be used while populating datas from big tables. So tried with cursor But it was very slow and again we got the exception like 'the table space unable to extend segment by 16 in undo tablespace 'UNDOTBS1'.
    After that we tried with the group by. In this case we got the exception like unable to extend table and also index in the table space. For this the solution is to add datafile. Again we have increase the table space. Now the procedure is running very slow(taking much time. It might be because of the conditions used in the query).
    Is there any other option to copy the datas from such a big tables? can we use the same sort of query?
    Friends please help me to sort it out.
    Thanks in Advance

    Hi,
    you have lot of data DONT use cursor, did you try using the COPY command.
    How frequently you will be doing the COPYING of the data ?
    If you have any constraints you can disable and enable after all the records have been copied.
    Please look at this link this should help.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5280714813869
    Thanks
    Message was edited by:
    hkandpal
    Link added

  • Insert problem using a SELECT from table with a index by function TRUNC

    I came across this problem when trying to insert from a select statement, the select returns the correct results however when trying to insert the results into a table, the results differ. I have found a work around by forcing an order by on the select, but surely this is an Oracle bug as how can the select statements value differ from the insert?
    Platform: Windows Server 2008 R2
    Oracle 11.2.3 Enterprise edition
    (I have not tried to replicate this on other versions)
    Here are the scripts to create the two tables and source data:
    CREATE TABLE source_data
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    CREATE INDEX IN_SOURCE_DATA ON SOURCE_DATA (TRUNC(count_date, 'MM'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120101', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120102', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120103', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120201', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120202', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120203', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120301', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120302', 'YYYYMMDD'));
    INSERT INTO source_data VALUES (1, TO_DATE('20120303', 'YYYYMMDD'));
    CREATE TABLE result_data
      ID                 NUMBER(2),
      COUNT_DATE       DATE
    );Now run the select statement:
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')You should get the following:
    1     2012/02/01
    1     2012/03/01
    1     2012/01/01Now insert into the results table:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM');Select from that table and you get:
    1     2012/03/01
    1     2012/03/01
    1     2012/03/01The most recent month is repeated for each row.
    Truncate your table and insert with the following statement and the results should now be correct:
    INSERT INTO result_data
    SELECT id, TRUNC(count_date, 'MM')
    FROM source_data
    GROUP BY id, TRUNC(count_date, 'MM')
    ORDER BY 1, 2;If anyone has encountered this behavior before could you please let me know, I can't see that I am making a mistake as the selects results are correct they should not differ from what is being inserted.
    Edited by: user11285442 on May 13, 2013 5:16 AM
    Edited by: user11285442 on May 13, 2013 6:15 AM

    Hi,
    welcome to the forum. I cannot reproduce the same behavior.
    Could you please post the SQLPlus output while executing all commands, like it has been done by S10390?
    Also post the output of the following command:
    SELECT * FROM v$version;When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Formatted code is easier to read.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • May returning Clause be used w/ INSERT INTO...SELECT FROM

    Hi,
    I use Oracle 8i: 8.1.7.2.0.
    I'd like to insert multiple rows into a table, and get back certain inserted columns into a collection variable. Is this possible?
    Eg:
    INSERT INTO foo
    f1
    , f2
    SELECT b1, b2...
    FROM bar
    RETURNING f1 bulk collect into collection
    This compiles, but yields a "command not properly ended" error at runtime--I assume because the "returning" binds to the SELECT subquery, and not to the main INSERT query.
    Is there a way to do this?
    By the way, I already know this works when INSERTing just 1 row via the "values" clause.
    Regards,
    --IG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    Try this way:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2     TYPE emp_t IS TABLE OF VARCHAR2(30);
      3     emp_list emp_t;
      4 
      5     TYPE emp_t2 IS TABLE OF NUMBER;
      6     emp_code emp_t2;
      7  BEGIN
      8 
      9     emp_list := emp_t('John',
    10                       'Doe',
    11                       'Max');
    12 
    13     FORALL i IN emp_list.FIRST .. emp_list.LAST
    14        INSERT INTO emp
    15           (id,
    16            NAME)
    17        VALUES
    18           (employees_seq.NEXTVAL,
    19            emp_list(i))
    20        RETURNING id BULK COLLECT INTO emp_code;
    21 
    22     FOR i IN emp_code.FIRST .. emp_code.LAST LOOP
    23        dbms_output.put_line(emp_code(i));
    24     END LOOP;
    25  END;
    26  /
    213
    214
    215
    PL/SQL procedure successfully completed
    SQL> commit;
    Commit complete
    SQL> select * from emp;
            ID NAME
           213 John
           214 Doe
           215 Max
    SQL>Regards,
    Edited by: Walter Fernández on May 8, 2009 12:59 PM -- Adding query on emp table...

  • Reason behind this query ,SELECT * FROM table WHERE 1 0

    HEllo,
    I would like to know the reason behind using this query ,
    SELECT * FROM <table> WHERE 1 < 0
    before executing the actual SQL query.
    Is there any special reason or the JDBC receiver side is configured like that.
    Is there any option to overcome this process like, can we remove this option or stop using this.
    Why the JDBC adapter basically sending this query on the DB?
    Thanks,
    Soorya,

    Hi,
    if you run this query, you wont be able to see any records of the table.
    SELECT * FROM <table> WHERE 1 < 0
    if you run this query you will see all records
    SELECT * FROM <table> WHERE 0 < 1
    same with SELECT * FROM <table> WHERE 1=1
    So you can check this out that whats happening in your code before executing actual query. just try to co-relate.
    regards
    Aashish Sinha
    PS : reward points if helpful

  • Insert into remote Oracle DB from Excel spreadsheet

    We currently have a Full Oracle database ( PROD ) which I can remotely link to with a version of Oracle Express on my desktop. Also, I can successfully link to an Excel spreadsheet. I am able to insert into a table on the Oracle Express database from the Excel link, and I can also insert to the PROD database from the Oracle Express database.
    However, when I try to insert rows into the remote PROD database from Excel, I get the following error.
    "Problem ORA-02019 connection discription for remote database not found ORA-02063; preceding line from XE ORA-02063 preceding 2 lines from PROD"
    The syntax that I am trying to use is:
    "Insert into temp@prod
    select * from Sheet1$@excel"
    The above syntax works very well to insert rows on the Oracle Express database from Excel, but is creating the error when trying to insert to a remote Oracle database.
    Is this solvable? Any advice is appreciated.
    Thanks.

    Hey
    Check this link:
    http://www.dba-oracle.com/t_ora_02019_connection_description_remote_database.htm
    Regards

  • Error while inserting into MS-SQL Server from Oracle using HS

    Hi,
    I am using hetrogeneous connection.
    I want to insert into MS-SQL Server Table by selecting from Oracle Tables.
    insert into tableone@mssql select * from table2;
    Table2 is in oracle database.
    while executing i'm getting
    ORA-02025: all tables in the SQL statement must be at the remote database
    Please guide me.
    Regards
    Salih KM

    some guy come up a solution by himself before. go ahead and try it
    ORA-02025 error while insert into emp@custard select ....

  • Strange result from insert into...select query

    Hello guys,
    I need your preciuos help for a question maybe simple, but that I can't explain by myself!
    I have a query of "insert into...select" that, as I have explained in the title, returns a strange result. In facts, If I execute ONLY the SELECT statement the query returns the expected result (so 2 rows); instead If I execute the entire statement, that is the "insert into...select", the query returns 0 rows inserted!!
    Following an example of the query:
    INSERT
    INTO TITOLI_ORI
    COD_TITOLO_RICCONS ,
    D_ESTRAZIONE ,
    COD_SOCIETA ,
    COD_PIANO_CONTABILE ,
    COD_CONTO_CONTABILE ,
    COD_RUBRICATO_STATISTICO_1 ,
    COD_NDG ,
    NUM_ESEGUITO ,
    CUR_IMPORTO_RICCONS ,
    CUR_IMPORTO_BICO ,
    FLG_MODIFICATO ,
    CUR_NON_ASSEGNATO ,
    FLG_QUOTATO ,
    COD_CATEG ,
    TIP_COPERTURA ,
    TIPTAS_TITOLO
    SELECT NEWID,
    '28-feb-2111',
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' as CUR_IMPORTO_BICO,
    0 as FLG_MODIFICATO,
    NULL as CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('VALUE1 ')
    AND TRC.COD_RAGGR_IAS NOT IN ('VALUE2')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('VALUE3')
    AND TRC.DES_MOV_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_CAT_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_INTER_TIT = RTRIM('VALUE5')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'V6'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'V7'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('VALUE8 '))
    Thanks a lot

    Right, I have executed this steps:
    - I have changed the query with the select count(*)
    - Changed the insert into with the select count(*)
    - Executed the insert into
    These are the result:
    SQL> select count(*) from TITOLI_ORI2;
    COUNT(*)
    1
    BUT:
    SQL> select * from TITOLI_ORI2;
    A
    0
    The insert into that I've modified is this:
    INSERT INTO bsc.TITOLI_ORI2
    select count(*)
    FROM
    (SELECT bsc.NEWID,
    TO_DATE('28-feb-2111','DD-MON-YYYY') as data,
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' AS CUR_IMPORTO_BICO,
    0 AS FLG_MODIFICATO,
    NULL CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM bsc.S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM bsc.S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN bsc.S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('HFT ')
    AND TRC.COD_RAGGR_IAS NOT IN ('GPO')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('DISPONIBILI')
    AND TRC.DES_MOV_TIT = RTRIM('CONSEGNARE ')
    AND TRC.COD_CAT_TIT = RTRIM('OBBLIGAZIONE ')
    AND TRC.COD_INTER_TIT = RTRIM('334058')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN bsc.S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN bsc.S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'ME'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'IS'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('P044C11 '))
    Another time the strange result returns!!
    And I've created the table TITOLI_ORI2 as create table TITOLI_ORI2 (a number); to contain the number result of the query.

  • Html form for select * from table a

    Hi all,
    I m looking for report on header/footer part from one apex pages
    which will display context from table a, like sql statement
    select * from table a, written in html.
    Is any examples in java script/html select from tables
    (and same insert into table A (...) select * from table b)
    thanks,
    Gordan

    Hello Gordan,
    Do you want to show the whole report or just some data of it?
    If it's for ex just the name and address you could create two items and have a process or computation to fill it with your select statement.
    If it's the whole report, just create the report and put it in for ex. Region 1. In your page template you can specify that Region 1 needs to come into the footer.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://apex-evangelists.com/
    -- http://apexblogs.info/

  • Select from table containing clob

    If i try to select from table containing clob column in SQL PLus it gives error.
    Tab1 contains 3 clob columns and 1 blob column
    select * from tab 1;
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    The same statement works in SQL Developer and I am able to see the result.
    Actually i am writing the queries and they will be used by Java developers in their JSP page.
    So what happens here? Can Java use these select statements or will it throw error like SQL Plus?

    BLOB column content can't be displayed in SQL*Plus:
    SQL> create table t_blob (b blob);
    Table created.
    SQL> edit
    Wrote file afiedt.buf
      1* insert into t_blob values('01')
    SQL> /
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t_blob;
    SP2-0678: Column or attribute type can not be displayed by SQL*PlusBlob and clob columns content can be processed using DBMS_LOB
    package procedures and functions or using client's language (like Java)
    methods. See JDBC specification.
    Rgds.

  • Insert into oracle_table (column1) select column1 from ms_sql_table

    Hi all,
    how do I export data from ms sql table into oracle table ?
    begin
    insert into oracle_table (column1)
    select column1 from ms_sql_table;
    commit;
    end;

    Hi ymarkiv,
    In addition to Prashanth’s suggestion, you can also use Import and Export Data Wizard to export SQL Server data to Oracle. When using the Wizard, you can edit transformation parameters using the Column
    Mapping dialog box, or write your own query to specify the data to transfer.
    For more details about export data from SQL Server to Oracle , please review this similar blog:
    Export SQL Server Data to Oracle using SSIS.
    Thanks,
    Lydia Zhang

  • Must specify table to select from

    hi everybody
    i think  sometime we received this error message:
    1).[Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to selet from. 2).[Microsoft][SQL Server Native Client 10.0][SQL Server]Statment 'Contrato de Servicio' (OCTR)(s) could not be prepared.
    when i'm working in SQL Server the qry run fine, but when i run in SAP, i receive the error before mentioned.
    the Qry is this:
    DECLARE @FechaIni datetime,     
            @FechaFin datetime,
            @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni = [%0]
    SET @FechaFin = [%1]
    CREATE TABLE #Libo_Mayor_CS (
                                    CodCta nvarchar(max),
                                    CtasPadre nvarchar(max),
                                    NbreCta nvarchar(max),
                                    Nivel numeric(1),
                                    Rubro numeric(1),
                                    SldoInicial numeric(19,6),
                                    Debe numeric(19,6),
                                    Haber numeric(19,6),
                                    SldoFinal numeric(19,6)
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] <=3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           0.00,
           0.00,
           0.00,
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode] = T1.[Account]
    WHERE T0.[Levels] BETWEEN 1 AND 3 AND
          T0.[GroupMask]   BETWEEN 1 AND 5
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] >3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           CASE
               WHEN T0.GroupMask  = 1 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 2 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 4 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 5 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
           END,
           SUM(T1.[Credit]),
           SUM(T1.[Debit]),
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode]  = T1.[Account]
    WHERE T0.[Levels] > 3 AND
          T0.[GroupMask]  BETWEEN 1 AND 5 AND
         (T1.[RefDate] between @FechaIni AND @FechaFin)
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    SELECT A.[CodCta] 'Codigo de Cuenta',
           A.[CtasPadre] 'Cuentas Padre',
           A.[NbreCta] 'Nombre de Cuenta',
           A.[Nivel] 'Nivel',
           A.[Rubro] 'Rubro',
           A.[SldoInicial] 'Saldo Inicial',
           A.[Debe] 'Debito',
           A.[Haber] 'Credito',
           CASE
               WHEN A.[Rubro] = 1 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 2 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               WHEN A.[Rubro] = 4 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 5 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               ELSE 0
           END 'Saldo'
    FROM #Libo_Mayor_CS A
    ORDER BY A.[CodCta]
    DROP TABLE #Libo_Mayor_CS
    if  assign the value to variables directly the Qry run in SAP but when i change the comodin to capture the variables value of SAP , there is when the problem ocurre
    DECLARE @FechaIni datetime,     
                    @FechaFin datetime,
                    @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni =  '20110601'
    SET @FechaFin = '20110630'
    i wait for your recomendations
    Edited by: AlexMeza on Jun 15, 2011 1:29 AM

    Hi all !
    Sorry because i dont know where post new.
    My issue, when i using querry manager to call store in Database like this
    Declare @Fromdate Datetime
    Declare @Todate Datetime
    Declare @AcctCode nvarchar (20)
    set @Fromdate = (select distinct (T1.RefDate) from OJDT T1 where T1.RefDate = '[%0]')
    set @Todate = (select distinct (T2.RefDate) from OJDT T2 where T2.RefDate = '[%1]')
    set @AcctCode = (select distinct(T3.AcctCode) from OACT as T3 where T3.AcctCode ='[%2]' )
    exec [USP_RPT_FI_GENERALLEDGER] @Fromdate, @Todate, @AcctCode
    and i run this querry
    this error:
    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'Service Contracts' (OCTR) (s) could not be prepared.
    Please help me fix this issue
    Regards!
    John Le.

  • Dynamic data select from table is giving dump

    Hello Experts,
       Below statement is giving Dump after it move all the data in my dynamic table.
    When i see in debug. All my recored are avilable in <T_TAB> Table.
    SELECT * FROM (pa_tab) INTO CORRESPONDING FIELDS OF TABLE <T_TAB>.
    > IF SY-SUBRC = 0.
    Information on where terminated
    The termination occurred in the ABAP program "ZFIR_ZTABLE_UPLOAD" in
    "F_DOWNLOAD".
    The main program was "ZFIR_ZTABLE_UPLOAD ".
    The termination occurred in line 403 of the source code of the (Include)
    program "ZFIR_ZTABLE_UPLOAD"
    of the source code of program "ZFIR_ZTABLE_UPLOAD" (when calling the editor
    4030).
    Processing was terminated because the exception "CX_SY_OPEN_SQL_DB" occurred in
    the
    procedure "F_DOWNLOAD" "(FORM)" but was not handled locally, not declared in
    the
    RAISING clause of the procedure.
    The procedure is in the program "ZFIR_ZTABLE_UPLOAD ". Its source code starts
    in line 399
    of the (Include) program "ZFIR_ZTABLE_UPLOAD ".
    please help me.
    Regards,
    Amit
    Message was edited by:
            Amit Gupta

    Hi Amit,
    Check if you are doing the following in your program
    FIELD-SYMBOLS <T_TAB> TYPE STANDARD TABLE.
    DATA: g_tabref type ref to data.   "Reference to your table structure
    CREATE DATA g_tabref type standard table of (pa_tab).
    ASSIGN g_tabref->* to <T_TAB>.
    SELECT * FROM (PA_TAB) INTO TABLE <T_TAB>.
    Hope this solves your problem.
    Let me know if you require any further info.
    Enjoy SAP. Reward points of useful
    Rajasekhar

  • Select * from table not working with Oracle OBDC driver

    Hello,
    In our web development we have been using the MS ODBC for Oracle
    driver to connect to our Oracle db. We decided to try the
    Oracle ODBC driver because it supports the commandTimeout
    property in ASP which the MS driver does not. The problem I'm
    running into now is that all of our select * from table
    statements appear not to be working. The Oracle ODBC driver
    version we are using is ver 8.00.05.00. Is there something that
    I'm not doing properly? If I take the same select * from table
    statement and name the columns, I dont get any error. Otherwise
    I'm getting a Subscript out of range error. It seems strange to
    me that this driver would not support a select * from table
    statement (which I''m told is the case by another developer
    here).
    Is there something I'm missing?
    Thanks,
    Pete

    I'm positive I have a connection. Otherwise I wouldn't get a
    response when I name the columns instead of using *.
    There must be something else that I'm missing or doing wrong.
    I've actually been looking into alternative ODBC drivers to see
    if I have the same problems but none that I have found support
    commandTimeout.
    Any other ideas?

  • Error in query: [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. '' (SWEI)

    Hi All
    below query giving me error in query generator but working well in Sql server.
    error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. '' (SWEI)
    Select
    T1.U_grp01 As 'BA',T3.DocDate As 'Posting Date',Month(T3.DocDate) As 'PostMonth',Year(T3.DocDate) As 'PostYear',
    'AR Invoice' As 'Type',T3.DocNum As 'Doc No',T3.CardCode As 'Cust. Code',T3.CardName As 'Cust. Name',T5.SlpName As 'Sale Emp. Name',
    T4.IndustryC As 'Channel Type',T6.CityB As 'BillToCity',T7.Name As 'BillToState',T6.CityS As 'ShipToCity',T8.Name As 'ShipToState',
    T4.U_Une_Zone As 'Zone',
    T2.ItmsGrpNam As 'L1',T0.LineNum As 'Row No',T0.ItemCode As 'ItemCode',T0.Dscription As 'Item Name',t0.whscode,
    T0.Quantity As 'Quantity',T0.StockPrice As 'COGS Price',IsNull(Sum(T0.Quantity * T0.StockPrice),0) As 'COGS Value',T0.VatSum As 'Tax Amount',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.PriceBefDi Else (T0.PriceBefDi * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.INMPrice Else (T0.INMPrice * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then Sum(T0.Quantity * T0.INMPrice) Else Sum(T0.Quantity * T0.INMPrice * T0.Rate) End) Else T0.LineTotal End) ,0) As 'Sales Value',t9.linetotal as 'Freight',
    T3.DocType As 'DocType',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = -90
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'BED',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = -60
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'Cess',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = 9
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'HeCess',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE (INV4.StaType = 1 or inv4.staType = 8)
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'VAT',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = 8
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'CST'
    From INV1 T0
    Left Join OITM T1 On T1.ItemCode=T0.ItemCode
    Left Join OITB T2 On T2.ItmsGrpCod=T1.ItmsGrpCod
    Left Join OINV T3 On T3.DocEntry=T0.DocEntry
    Left Join OCRD T4 On T4.CardCode=T3.CardCode
    Left Join OSLP T5 On T5.SlpCode=T4.SlpCode
    Left Join INV12 T6 On T6.DocEntry=T0.DocEntry
    Left Join OCST T7 On T7.Code=T6.StateB and T7.Country='IN'
    Left Join OCST T8 On T8.Code=T6.StateS and T8.Country='IN'
    left join inv3 t9 on t9.docentry = t3.docentry
    WHERE T3.[DocDate] >= [%0] and T3.[DocDate] <= [%1] and t3.U_UNE_GCAT = '2'
    Group By T1.U_grp01,T3.DocEntry,T3.DocNum,T3.DocDate,T0.LineNum,T3.CardCode,T3.CardName,T5.SlpName,T4.IndustryC,T4.U_Une_Zone,
    T6.CityB,T7.Name,T6.CityS,T8.Name,T0.VatSum,T0.Currency,T0.Rate,T3.DocType,T0.Price,T0.LineTotal,
    T2.ItmsGrpNam,T0.ItemCode,T0.Dscription,T0.StockPrice,T0.INMPrice,T0.PriceBefDi,T0.Quantity,t9.linetotal,t0.WhsCode
    Union All
    Select
    T1.U_grp01 As 'BA',T3.DocDate As 'Posting Date',Month(T3.DocDate) As 'PostMonth',Year(T3.DocDate) As 'PostYear',
    'AR Invoice' As 'Type',T3.DocNum As 'Doc No',T3.CardCode As 'Cust. Code',T3.CardName As 'Cust. Name',T5.SlpName As 'Sale Emp. Name',
    T4.IndustryC As 'Channel Type',T6.CityB As 'BillToCity',T7.Name As 'BillToState',T6.CityS As 'ShipToCity',T8.Name As 'ShipToState',
    T4.U_Une_Zone As 'Zone',
    T2.ItmsGrpNam As 'L1',T0.LineNum As 'Row No',T0.ItemCode As 'ItemCode',T0.Dscription As 'Item Name',t0.whscode,
    T0.Quantity As 'Quantity',T0.StockPrice As 'COGS Price',IsNull(Sum(T0.Quantity * T0.StockPrice),0) As 'COGS Value',T0.VatSum As 'Tax Amount',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.PriceBefDi Else (T0.PriceBefDi * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.INMPrice Else (T0.INMPrice * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then Sum(T0.Quantity * T0.INMPrice) Else Sum(T0.Quantity * T0.INMPrice * T0.Rate) End) Else T0.LineTotal End) ,0) As 'Sales Value',t9.linetotal as 'Freight',
    T3.DocType As 'DocType',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = -90
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'BED',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = -60
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'Cess',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = 9
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'HeCess',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE (rin4.StaType = 1 or rin4.staType = 8)
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'VAT',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = 8
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'CST'
    From rin1 T0
    Left Join OITM T1 On T1.ItemCode=T0.ItemCode
    Left Join OITB T2 On T2.ItmsGrpCod=T1.ItmsGrpCod
    Left Join Orin T3 On T3.DocEntry=T0.DocEntry
    Left Join OCRD T4 On T4.CardCode=T3.CardCode
    Left Join OSLP T5 On T5.SlpCode=T4.SlpCode
    Left Join rin12 T6 On T6.DocEntry=T0.DocEntry
    Left Join OCST T7 On T7.Code=T6.StateB and T7.Country='IN'
    Left Join OCST T8 On T8.Code=T6.StateS and T8.Country='IN'
    left join rin3 t9 on t9.docentry = t3.docentry
    WHERE T3.[DocDate] >= [%0] and T3.[DocDate] <= [%1] and t3.U_UNE_GCAT = '2'
    Group By T1.U_grp01,T3.DocEntry,T3.DocNum,T3.DocDate,T0.LineNum,T3.CardCode,T3.CardName,T5.SlpName,T4.IndustryC,T4.U_Une_Zone,
    T6.CityB,T7.Name,T6.CityS,T8.Name,T0.VatSum,T0.Currency,T0.Rate,T3.DocType,T0.Price,T0.LineTotal,
    T2.ItmsGrpNam,T0.ItemCode,T0.Dscription,T0.StockPrice,T0.INMPrice,T0.PriceBefDi,T0.Quantity,t9.linetotal,t0.WhsCode
    Thanks in Advance

    Hi deepak..
    try this
    /* SELECT FROM OSRT P1 */
    DECLARE @FROM AS DATE
    /* WHERE */
    SET @FROM = /* P1.FromDate */ '[%1]'
    /* SELECT FROM OSRT P2 */
    DECLARE @TO AS DATE
    /* WHERE */
    SET @TO = /* P2.ToDate */ '[%2]';
    SELECT T1.U_grp01 AS 'BA',
           T3.DocDate AS 'Posting Date',
           MONTH(T3.DocDate) AS 'PostMonth',
           YEAR(T3.DocDate) AS 'PostYear',
           'AR Invoice' AS 'Type',
           T3.DocNum AS 'Doc No',
           T3.CardCode AS 'Cust. Code',
           T3.CardName AS 'Cust. Name',
           T5.SlpName AS 'Sale Emp. Name',
           T4.IndustryC AS 'Channel Type',
           T6.CityB AS 'BillToCity',
           T7.Name AS 'BillToState',
           T6.CityS AS 'ShipToCity',
           T8.Name AS 'ShipToState',
           T4.U_Une_Zone AS 'Zone',
           T2.ItmsGrpNam AS 'L1',
           T0.LineNum AS 'Row No',
           T0.ItemCode AS 'ItemCode',
           T0.Dscription AS 'Item Name',
           t0.whscode,
           T0.Quantity AS 'Quantity',
           T0.StockPrice AS 'COGS Price',
           ISNULL(SUM(T0.Quantity * T0.StockPrice), 0) AS 'COGS Value',
           T0.VatSum AS 'Tax Amount',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.PriceBefDi
                                      ELSE (T0.PriceBefDi * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.INMPrice
                                      ELSE (T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN SUM(T0.Quantity * T0.INMPrice)
                                      ELSE SUM(T0.Quantity * T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.LineTotal
                   END
               0
           ) AS 'Sales Value',
           t9.linetotal AS 'Freight',
           T3.DocType AS 'DocType',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = -90
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'BED',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = -60
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'Cess',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = 9
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'HeCess',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  (INV4.StaType = 1 OR inv4.staType = 8)
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'VAT',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = 8
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'CST'
    FROM   INV1 T0
           LEFT JOIN OITM T1
                ON  T1.ItemCode = T0.ItemCode
           LEFT JOIN OITB T2
                ON  T2.ItmsGrpCod = T1.ItmsGrpCod
           LEFT JOIN OINV T3
                ON  T3.DocEntry = T0.DocEntry
           LEFT JOIN OCRD T4
                ON  T4.CardCode = T3.CardCode
           LEFT JOIN OSLP T5
                ON  T5.SlpCode = T4.SlpCode
           LEFT JOIN INV12 T6
                ON  T6.DocEntry = T0.DocEntry
           LEFT JOIN OCST T7
                ON  T7.Code = T6.StateB
                AND T7.Country = 'IN'
           LEFT JOIN OCST T8
                ON  T8.Code = T6.StateS
                AND T8.Country = 'IN'
           LEFT JOIN inv3 t9
                ON  t9.docentry = t3.docentry
    WHERE  T3.[DocDate] >= @FROM
           AND T3.[DocDate] <= @TO
           AND t3.U_UNE_GCAT = '2'
    GROUP BY
           T1.U_grp01,
           T3.DocEntry,
           T3.DocNum,
           T3.DocDate,
           T0.LineNum,
           T3.CardCode,
           T3.CardName,
           T5.SlpName,
           T4.IndustryC,
           T4.U_Une_Zone,
           T6.CityB,
           T7.Name,
           T6.CityS,
           T8.Name,
           T0.VatSum,
           T0.Currency,
           T0.Rate,
           T3.DocType,
           T0.Price,
           T0.LineTotal,
           T2.ItmsGrpNam,
           T0.ItemCode,
           T0.Dscription,
           T0.StockPrice,
           T0.INMPrice,
           T0.PriceBefDi,
           T0.Quantity,
           t9.linetotal,
           t0.WhsCode
    UNION ALL
    SELECT T1.U_grp01 AS 'BA',
           T3.DocDate AS 'Posting Date',
           MONTH(T3.DocDate) AS 'PostMonth',
           YEAR(T3.DocDate) AS 'PostYear',
           'AR Invoice' AS 'Type',
           T3.DocNum AS 'Doc No',
           T3.CardCode AS 'Cust. Code',
           T3.CardName AS 'Cust. Name',
           T5.SlpName AS 'Sale Emp. Name',
           T4.IndustryC AS 'Channel Type',
           T6.CityB AS 'BillToCity',
           T7.Name AS 'BillToState',
           T6.CityS AS 'ShipToCity',
           T8.Name AS 'ShipToState',
           T4.U_Une_Zone AS 'Zone',
           T2.ItmsGrpNam AS 'L1',
           T0.LineNum AS 'Row No',
           T0.ItemCode AS 'ItemCode',
           T0.Dscription AS 'Item Name',
           t0.whscode,
           T0.Quantity AS 'Quantity',
           T0.StockPrice AS 'COGS Price',
           ISNULL(SUM(T0.Quantity * T0.StockPrice), 0) AS 'COGS Value',
           T0.VatSum AS 'Tax Amount',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.PriceBefDi
                                      ELSE (T0.PriceBefDi * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.INMPrice
                                      ELSE (T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN SUM(T0.Quantity * T0.INMPrice)
                                      ELSE SUM(T0.Quantity * T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.LineTotal
                   END
               0
           ) AS 'Sales Value',
           t9.linetotal AS 'Freight',
           T3.DocType AS 'DocType',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = -90
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'BED',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = -60
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'Cess',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = 9
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'HeCess',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  (rin4.StaType = 1 OR rin4.staType = 8)
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'VAT',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = 8
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'CST'
    FROM   rin1 T0
           LEFT JOIN OITM T1
                ON  T1.ItemCode = T0.ItemCode
           LEFT JOIN OITB T2
                ON  T2.ItmsGrpCod = T1.ItmsGrpCod
           LEFT JOIN [dbo].[Orin] T3
                ON  T3.DocEntry = T0.DocEntry
           LEFT JOIN OCRD T4
                ON  T4.CardCode = T3.CardCode
           LEFT JOIN OSLP T5
                ON  T5.SlpCode = T4.SlpCode
           LEFT JOIN rin12 T6
                ON  T6.DocEntry = T0.DocEntry
           LEFT JOIN OCST T7
                ON  T7.Code = T6.StateB
                AND T7.Country = 'IN'
           LEFT JOIN OCST T8
                ON  T8.Code = T6.StateS
                AND T8.Country = 'IN'
           LEFT JOIN rin3 t9
                ON  t9.docentry = t3.docentry
    WHERE  T3.[DocDate] >= @FROM
           AND T3.[DocDate] <= @TO
           AND t3.U_UNE_GCAT = '2'
    GROUP BY
           T1.U_grp01,
           T3.DocEntry,
           T3.DocNum,
           T3.DocDate,
           T0.LineNum,
           T3.CardCode,
           T3.CardName,
           T5.SlpName,
           T4.IndustryC,
           T4.U_Une_Zone,
           T6.CityB,
           T7.Name,
           T6.CityS,
           T8.Name,
           T0.VatSum,
           T0.Currency,
           T0.Rate,
           T3.DocType,
           T0.Price,
           T0.LineTotal,
           T2.ItmsGrpNam,
           T0.ItemCode,
           T0.Dscription,
           T0.StockPrice,
           T0.INMPrice,
           T0.PriceBefDi,
           T0.Quantity,
           t9.linetotal,
           t0.WhsCode
    rgds
    Kennedy

Maybe you are looking for

  • DoGet() and service() method differences in servlets

    can you give the differences between doGet() and service() methods in servlets. where to use doGet() and where to use service() thanks

  • Financial Reports - Extract Report names?

    We have over 100+ reports for a well established Planning application and need to streamline the report list to reflect the current business needs. Our plan is to create a new report register and would like to export the current report list to an exc

  • Aperture cannot read RAW exported from IDC?

    When I shoot RAW with the kit lens of my nex6 it usually get distorted pretty bad. So what I'm trying to do is first open it up with Sony's image editor called IDC (latest version) and then export the RAW file from IDC then import that fixed file bac

  • File system check recs on new ASAs

    Just curious if anyone knows why I'd be seeing these on a new ASAs. The last two I received had these fsck records: f-monona-1# sh flash --#--  --length--  -----date/time------  path  182  16275456    Dec 13 2010 16:46:02  asa821-k8.bin  223  1596211

  • Black swatch tool won't stay black

    Another minor annoyance inPhotoshop CC: for some reason the black toggle-able color swatch in the tool pallet won't stay rich black, but degrades to about 85% charcoal grey, without warning. I open a file, start drawing with the brush/path tool, usin