INSERT into Oracle table as SELECT from MS Access table
I'm trying to pull some data across from an MS Access database. I really need to pick and choose what is coming across, so migration isn't what I need. I can connect to the Access DB from SQL Developer, export data and so forth. However, I can't seem to find a way to directly access data in the MDB file from an Oracle connection. The two options that I can think of which would be perfect (if they are possible) are:
1. If it's possible to SELECT between two open connections in SQL Developer. I can (and have) had both my Oracle conection where I want the data to go and the source Access connection opened simultaneously, but I can't see any way to address a query from one connection to another.
2. If it's possible to create the equivalent of a database link to the Access MDB file from within my Oracle database so that I can address the query via that.
Right now I'm exporting individual tables from Access to files, then doing a bunch of Search and Replace operations to convert them to SQL scripts with INSERT statements in the format required, then running those scripts in my Oracle connection. It works, but is very slow and tedious.
You need to create a database link based on Database Gateway for ODBC. This gateway allows you to connect from an Oracle database to a foreign data store using a 3rd party ODBC driver.
A suitable 3rd party ODBC driver which allows you to connect from Oracle to MS Access is the ODBC driver from Microsoft available on Windows platforms - I'm not aware of any 3rd party ODBC driver for MS Access available on Unix platforms.
So when using DG4ODBC on Windows you can connect from your Oracle database (even when the database resides on Unix) to DG4ODBC on Windows which then connects to the Ms Access database using the MS Access ODBC driver.
There's a separate Forum for those configs:
Heterogeneous Connectivity
Similar Messages
-
How to extract data from xml and insert into Oracle table
Hi,
I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
I need to extract the values of these columns and insert into the table
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
<Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>Re: Insert from XML to relational table
http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta= -
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 -
How to read the data from XML file and insert into oracle DB
Hi All,
I have below require ment.
I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
Many Thanks.Sounds a lot like this question, only with less details.
how to read data from XML variable and insert into table variable
We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us. Plenty of examples abound on the forums that cover the topics you seek as well. -
HOW TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE??
NEED TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE.
this is another method
http://www.mssqltips.com/sqlservertip/2484/import-data-from-microsoft-access-to-sql-server/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Insert into oracle DB using vb2005
I have a form that has click button1. The problem with this code is after insert command something should be inserted into oracle DB but nothing there(so how to execute insert command and commit it using VB2005), any suggestion should refer to the code.
Imports System
Imports System.Data ' VB.NET
Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
'System.Data.OracleClient lets you access Oracle databases.
Public con As System.Data.OracleClient.OracleConnection = New System.Data.OracleClient.OracleConnection() 'Oracle.DataAccess.Client.OracleConnection()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim range As Excel.Range
Dim rCnt As Integer
Dim cCnt As Integer
Dim Obj As Object
xlApp = New Excel.ApplicationClass
xlApp.Visible = True
xlWorkBook = xlApp.Workbooks.Open("c:\employee.xls")
xlWorkSheet = xlWorkBook.Worksheets("sheet1")
range = xlWorkSheet.UsedRange
For rCnt = 2 To range.Rows.Count
For cCnt = 1 To range.Columns.Count
Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
'MsgBox(Obj.value)
Next
Next
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim daOracle As New OracleDataAdapter
Dim InsertCommand As New OracleCommand
daOracle.InsertCommand = New OracleCommand
'1.Create connection object to Oracle database
Dim con As OracleConnection = New OracleConnection()
Try
'2.Specify connection string
con.ConnectionString = ("Data Source=mgra;User Id=tmar; Password=grams")
'3. Open the connection through ODP.NET
con.Open()
Catch ex As Exception
'4.display if any error occurs
MsgBox(ex.Message, Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "OraScan")
'3.Create command object to perform a query against the database:
Dim cmdQuery As String = "SELECT * FROM employee"
InsertCommand.CommandText = "insert into meta_objecttypes values(4,'table','table','ERStudio','Demo')"
daOracle.InsertCommand = InsertCommand
' Create the OracleCommand object to work with select
Dim cmd As OracleCommand = New OracleCommand(cmdQuery)
cmd.Connection = con
cmd.CommandType = CommandType.Text
'get the DataReader object from command object
Dim rdr As OracleDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
cmd.ExecuteNonQuery()
'check if it has any row
While rdr.Read()
rdr.Close()
End While
Finally
' Close and Dispose OracleConnection object
con.Close()
con.Dispose()
End Try
End Sub
End ClassFor best results, please repost this to the ODP.NET forum.
-
Bulk insert into oracle using ssis
Hi ,
Can someone please suggest me the way to Bulk insert data into oracle database? I'm using oledb which doesnt support bulk insert into oracle.
Pls note I cant use Oracle ATTUnity as it requires enterprise edition but i have only Standard edition and hence that option is ruled out.
Is there any other way that I can accompolish BULK insert?
Please help me out.
Thanks,
PrabhuHi Prabhu,
I am very late to help you solve the query but following is the solution to 'Bulk Insert into Oracle' that worked for me.
To use below code for SSIS 2008 R2 in a
Script Task component you would need following API references.
Prerequisites:
1. C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
2. Install "Oracle Data Provider For .NET 11.2.0.1.0" and add a reference to
Oracle.DataAccess.dll.
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
* Description : SQL to Oracle Bulk Copy/Insert
* Created By : Mitulkumar Brahmbhatt
* Created Date: 08/14/2014
* Modified Date Modified By Description
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Data.OleDb;
namespace ST_6e18a76102dd4312868504c4ef95279d.csproj
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
#region VSTA generated code
enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
#endregion
public void Main()
ConnectionManager cm;
IDTSConnectionManagerDatabaseParameters100 cmParams;
OleDbConnection oledbConn;
DataSet ds = new DataSet();
string sql;
try
/********** Pull Sql Source Data into a Dataset *************/
cm = Dts.Connections["SRC_CONN"];
cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
oledbConn = (OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection;
sql = @"Select * from [sourcetblname]'';
OleDbCommand sqlComm = new OleDbCommand(sql, oledbConn);
OleDbDataAdapter da = new OleDbDataAdapter(sqlComm);
da.Fill(ds);
cm.ReleaseConnection(oledbConn);
/***************** Bulk Insert to Oracle *********************/
cm = Dts.Connections["DEST_CONN"];
cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
string connStr = ((OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection).ConnectionString;
cm.ReleaseConnection(oledbConn);
sql = "destinationtblname";
using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connStr.Replace("Provider=OraOLEDB.Oracle.1", "")))
bulkCopy.DestinationTableName = sql;
bulkCopy.BatchSize = 50000;
bulkCopy.BulkCopyTimeout = 20000;
bulkCopy.WriteToServer(ds.Tables[0]);
/***************** Return Result - Success *********************/
Dts.TaskResult = (int)ScriptResults.Success;
catch (Exception x)
Dts.Events.FireError(0, "BulkCopyToOracle", x.Message, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
finally
ds.Dispose();
Mitulkumar Brahmbhatt | Please mark the post(s) that answered your question. -
Hi Guys,
I was just hoping to get your opinion on something.
I have a procedure in Production that is taking longer and longer to finish and sticks on one certain section of code.
The code is an INSERT into the main dimension table.
This same procedure runs fine on TEST and the section of code completes an awful lot quicker.
The traffic on Production is a lot heavier and there have been applications developed by people other than myself which SELECT from this dimension table. I'm assuming, based on the fact the code in Test and Production are identical, that this increased traffic could be eating up the bandwith and slowing the jobs.
So, I was thinking - if I create Views and let the other applications hit the views as opposed to the main table, will this help speed it up. I did this before on a Teradata platform using a 'dirty read' which worked quite well but Oracle doesn't seem to offer this option.
What do you guys think? Could this work or do I need to take a different approach.
Thank You.GerardMcL wrote:
I meant ordinary views.
I was wondering if there was a way of putting some locking code in or asking for a dirty read that would speed up the SELECT from the table?There is no such thing as a dirty read with Oracle -- Teradata, SQL Server, Sybase, IBM, etc., have different locking architectures where reads can block write and writes can block reads, and that is not an issue with Oracle.
If there's a query performance problem, which is what that will be if the SELECTs are slow, then if you could follow the following links, that will help diagnosis immensely:
[How to Post A Tuning Request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]
And:
[When your Query takes too long|http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597]
There is such as thing as stale reads, against Materialized Views, which are views that actually materialize and store the results of a query, and which then can subsequently be queried. -
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 AMHi 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. -
SELECTing from a large table vs small table
I posted a question few months back about teh comparison between INSERTing to a large table vs small table ( fewer number of rows ), in terms of time taken.
The general consensus seemed to be that it would be teh same, except for teh time taken to update the index ( which will be negligible ).
1. But now, following teh same logic, I m confused why SELECTINg from a large table should be more time taking ("expensive" ) than SELECTing from a small table.
( SELECTing using an index )
My understanding of how Oracle works internally is this :
It will first locate the ROWID from teh B-Tree that stores the index.
( This operation is O(log N ) based on B-Tree )
ROWID essentially contains teh file pointer offset of teh location of the data in teh disk.
And Oracle simply reads teh data from teh location it deduced from ROWID.
But then the only variable I see is searching teh B-Tree, which should take O(log N ) time for comparison ( N - number of rows )
Am I correct above.
2. Also I read that tables are partitioned for performance reasons. I read about various partiotion mechanisms. But cannot figure out how it can result in performance improvement.
Can somebody please helpuser597961 wrote:
I posted a question few months back about teh comparison between INSERTing to a large table vs small table ( fewer number of rows ), in terms of time taken.
The general consensus seemed to be that it would be teh same, except for teh time taken to update the index ( which will be negligible ).
1. But now, following teh same logic, I m confused why SELECTINg from a large table should be more time taking ("expensive" ) than SELECTing from a small table.
( SELECTing using an index )
My understanding of how Oracle works internally is this :
It will first locate the ROWID from teh B-Tree that stores the index.
( This operation is O(log N ) based on B-Tree )
ROWID essentially contains teh file pointer offset of teh location of the data in teh disk.
And Oracle simply reads teh data from teh location it deduced from ROWID.
But then the only variable I see is searching teh B-Tree, which should take O(log N ) time for comparison ( N - number of rows )
Am I correct above.
2. Also I read that tables are partitioned for performance reasons. I read about various partiotion mechanisms. But cannot figure out how it can result in performance improvement.
Can somebody please helpIt's not going to be that simple. Before your first step (locate ROWID from index), it will first evaluate various access plans - potentially thousands of them - and choose the one that it thinks will be best. This evaluation will be based on the number of rows it anticipates having to retrieve, whether or not all of the requested data can be retrived from the index alone (without even going to the data segment), etc. etc etc. For each consideration it makes, you start with "all else being equal". Then figure there will be dozens, if not hundreds or thousands of these "all else being equal". Then once the plan is selected and the rubber meets the road, we have to contend with the fact "all else is hardly ever equal". -
Hi all,
I have some xml data which i would like to insert into oracle tables.
Where to start up with this?Hi,
Here's another good place to start: [XML DB FAQ|http://forums.oracle.com/forums/thread.jspa?threadID=410714&tstart=0]
You seem to be especially interested in second post in there.
Regards
Peter -
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 AdvanceHi 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 -
Error while executing SQL query -' Must Specify Table to select from'
Hi all,
While executing query using query generator
it shows error message
[Microsoft][SQL Native Client][SQL Server]Must specify table to select from.
2). [Microsoft][SQL Nativ
SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
FROM dbo.[OPCH] T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
WHERE T0.DocDate >='[%0]' AND T0.DocDate <='[%1]' AND T0.DocType = 'I'
GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
It's executing fine in MS SQL Server Studio Management.
Please give y'r ideas to solve the problem.
Jeyakanthantry this, it works fine in my B1:
SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
(Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
FROM dbo.OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
WHERE T0.DocDate >='[%0]' AND T0.DocDate <='[%1]' AND T0.DocType = 'I'
GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
B1 don't like brackets!
Regards -
How to assign tasks in Approval Workflow to a set of users selected from a Lookup table
Hi all,
I am new to Project Server and I am using Project Server 2013 On premises deployement. Please help me on how to achieve the below scenario:
I have a requirement where, the initial PDP will have 2 fields (Reviewers and Approvers), wherein the engineer himself will select who the reviewer and approver from the Lookup tables.
Now I have to start task process with these selected people for approval.
Say for example , engineer has selected Alice and Bob as 2 reviewers, then
In the workflow I have :
Start Task process with
Project Data: Reviewers (which is giving error as
[System.ArgumentException: AssignedTo at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager
bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) ]
Then I tried logging the value of Project Data: Reviewers, It logged the value as Alice, Bob (which looks pretty good),
Then I tried assigning only 1 person as Reviewer, then also I get the same error.
So can anybody please tell me where I went wrong. Is it not possible to fetch the data from the values selected as Project Data from the Lookup tables ? If not then what is the workaround I can use to achieve this ?
Thanks,
ShankyHi Paul,
Yes I am using SP designer for Workflows. And yes, You were right, there was a mismatch in the names of AD account and the Lookup table, now with 1 person selected from the lookup table it is assigning the task properly. However with multiple selection,
it is failing.
As Robert mentioned, the fetched value is a text as "Alice, Bob", which makes 2 usernames as a single text. So when I try to assign a task to this group, which returns value as "Alice, Bob", workflow fails to find such AD user, as it
is an invalid value.
So is there any way I can seperate this out to form 2 different username ? I checked for string extraction function in th Workflow, but nothing helped me for this scenario.
Any input will be helpful.
Thanks,
Shanky
Maybe you are looking for
-
Direct comparison old and new mini into tv
Hi all. I notice a slew of threads berating the display quality of the mini and I want to put my chime in. I have a 1.6 core duo mini and I replaced it Saturday with a new one. I have a 32 in LCD in the living room, the old one was hooked up with a d
-
Configuration of Leave Encashment Method in ESS
Hi, We are implementation ESS for our client, Here in ESS i am not getting dropdown values for Time Account & Leave Encasement Method. How can i configure? Thanks & Regards Kishore Jagarlamudi
-
How far in the Future will AS2 be supported?
Hi I've been developing Flash stuffs for almost a decade, i consider myself advanced in AS2 .. i am also very advanced in PHP.. Throughout all my projects I've always used Flash, AS2, mySQL and PHP, and have made tons of applications , some mission c
-
Final Cut Pro and Canon 5D Mark II
Hi, I have been shooting on the Canon 5D for a few months now. My problem is when i have to edit the footage. I have tried converting to Apple ProRes using compressor, fcp, mpeg stream and i find a lot of jitters if the moving shots - i have been usi
-
How do I send a audio file by text on iphone5
How do I send an audio file (audio clip) by text message on the iPhone5?