473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Reading data from Navision to SQL Server: Date issues

Hi:

I'm trying to read data from Navision 2.60 ERP with own database to a
SQL Server 2000 database via ODBC. All is working except just one
thing, how to filter data with a date field.

I have some big tables that have a date field and I just want to read
data from one or few days, not all the table, cos I will be doing this
every day (datawarehousing).
If I write in my SQL Server DTS:

SELECT *
FROM MYNAVISIONTABLE
WHERE (MYDATE = { d '2005-06-30' })

It works! This notation is the one required by C/ODBC Navision driver.

Now I want to change 2005-06-30 for something like "sysdate" or "today"
or similar... to execute this all days.... any ideas?
THANK YOU,

Regards
Fran

Jul 23 '05 #1
2 7069
I don't know anything about Navision, however if you're using a DTS
Execute SQL or Transform Data task, the query executes directly on the
connection, so you should be able to use whatever function Navision has
for the current date (if that makes any sense).

If that doesn't work, then you could look at building up the SQL
statement dynamically (as far as I know, you can't use a variable
inside an ODBC escape clause). One way is to use the DTS COM object
model - build the whole SQL string dynamically, then set the
SQLStatement property of the ExecuteSQLTask object. This could be done
from an ActiveX or Dynamic Properties task in the same package.

If this isn't helpful, you might want to give some more details of
exactly how you're executing the SQL statement within the DTS package.
You should probably also consider posting in
microsoft.public.sqlserver.dts and/or microsoft.public.navision to see
if there's a better way to handle this.

Simon

Jul 23 '05 #2
Hello:

Thank you for your help Simon, the key was to build dynamicaly the SQL
string as you said. Sadly Navision C/ODBC 2.60 driver doesn't seem to
have many features...

I tell you how I did it, in the case someone someday reads this and has
the same problem and wants to solve it fast:

I build a DTS with 2 connections (Origin and Target) and a Data
Transformation Task between them with all the transformation changes I
want. Until here everything as I had before.

My goal is to read only the data that I want filtering it with a date
variable. For example you have some million registers in a table and
want to extract each day just the few new records.

Now I add an ActiveX Task with the following code:
(Probably there's an easiest way to do this, I'm not an expert here,
but this works...)
'************************************************* *********************
' Secuencia de comandos ActiveX Visual Basic
'************************************************* ***********************
Option Explicit

Function Main()
Dim pkg, stp, tsk, cus, sql

'************************************************* ***********************
' Dealing with dates in Navision C/ODBC: They have to be
<{d'aaaa-mm-dd'}>
' Being the first d from date... options: t from time and ts from
timestamp
' The Month function will give you just one number if you are before
October

Dim mes

mes = Month(Date)

If mes <10 Then
mes = "0" & mes
end if

'************************************************* ***********************

Set pkg = DTSGlobalVariables.Parent

' Notice here that DTSStep_DTSDataPumpTask_1 is the name of the Data
' Transformation Task

Set stp = pkg.Steps("DTSStep_DTSDataPumpTask_1")
Set tsk = pkg. Tasks(stp.TaskName)

Set cus = tsk.CustomTask

' Construct the sql statement

sql = "select * from MyTable where (MyDateField > {d'" & Year(Date) &
"-" & mes & "-" & Day(Date) & "'})"

'Assign the SourceSQLStatement property of the custom task

cus.SourceSQLStatement = sql

Main = DTSTaskExecResult_Success
End Function


I put a green (Success) line from this Task to the Origin Connection of
the Data Transformation Task, so that the ActiveX scritp runs the
first, build the SQL sentence, and then the Data Transformation Task
Origin Connection runs the SQL Sentence selecting only the proper data.
You can see this work just looking at the Origin Connection and in the
SQL box you'll see the SQL sentence generated in the last execution of
the DTS.

Thanks!

Regards,
Fran

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Gordon | last post by:
I'm investigating getting Microsoft Navision to do stuff from a Python script. The recommended way seems to be to use message queues (MSMQ). I can get Navision to send a message to itself fine. I...
0
by: Steve | last post by:
Hello I have just been given a new project requiring that I create a new web application in Microsoft .NET that integrates with Navision Axapta v 3.0 While I am aware that I would be able to...
0
by: Peter T. | last post by:
Hello , we use sql-server 7.0 with navision client 2.60a . Now we want to upgrade to sql server 2000. The upgrade process works fine but when I try to connect to the sql 2000 server with navision...
4
by: Xavi | last post by:
I would like to know if someone has prove the integration and comunication between Biztalk nad Navision and if it works fine. Thank you
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
1
by: Mike | last post by:
Hi, We are in the process of evaluating a system that would allow us to receive data from third-parties and send data to partner companies. Our infrastructure includes Microsoft Navision, a SQL...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
0
by: Navision Recruiter | last post by:
What we're getting you for Christmas: ·Excellent benefits package ·Exciting Career Path ·Great Team of Professionals ·Compensation $75k - $90k USD dependent upon experience Permanent role...
0
by: azuro | last post by:
Hi, Is there any ways to extract data within a specified date range from Navision database? Thanks.
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.