![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#3
| |||
| |||
|
|
I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#4
| |||
| |||
|
|
Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#5
| |||
| |||
|
|
Jacco I am not using VBScript. I want to do it in designer. "Jacco Schalkwijk" wrote: You can use an ActiveX task with the following script: DTSGlobalVariables("SystemDate").Value = Date() You can use the Global Variable in your queries by using a question mark in the place where you want the variable to be used and assigning the global variable to it on the parameters tab. -- Jacco Schalkwijk SQL Server MVP "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#6
| |||
| |||
|
|
Ok fine. I have created the Global variable in the VBScript task. But how to refer to that variable in the SQL Queries and whether it would work in Oracle or not b/c SQL Execute task would send the query to run on the Oracle plateform. Would it replace the variable with its variable before sending it. Like I want to use the following query select * from Table where DateCol=[DateGlobalVariable] "Darren Green" wrote: Ok that makes sense. You use a table to store the date. I have a table that stores various information about the current run for example, including dates and times, around the work period for the current (ET)load. First task populates this table for the current run. Maybe it is on the wrong server though. The DTS way using a global variable is to use an ActiveX Script Task to set the variable first as Jacco suggested. This is done through the designer, so can you explain what you perceive as the problem? -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news 7FF0114-F4A9-4D47-8F9D-5FDBDC7C97D9 (AT) microsoft (DOT) com...Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#7
| |||
| |||
|
|
From Jacco- You can use the Global Variable in your queries by using a question mark in the place where you want the variable to be used and assigning the global variable to it on the parameters tab. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:B14366DF-9AF6-4350-A6E3-EC2F3267835C (AT) microsoft (DOT) com... Ok fine. I have created the Global variable in the VBScript task. But how to refer to that variable in the SQL Queries and whether it would work in Oracle or not b/c SQL Execute task would send the query to run on the Oracle plateform. Would it replace the variable with its variable before sending it. Like I want to use the following query select * from Table where DateCol=[DateGlobalVariable] "Darren Green" wrote: Ok that makes sense. You use a table to store the date. I have a table that stores various information about the current run for example, including dates and times, around the work period for the current (ET)load. First task populates this table for the current run. Maybe it is on the wrong server though. The DTS way using a global variable is to use an ActiveX Script Task to set the variable first as Jacco suggested. This is done through the designer, so can you explain what you perceive as the problem? -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news 7FF0114-F4A9-4D47-8F9D-5FDBDC7C97D9 (AT) microsoft (DOT) com...Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#8
| |||
| |||
|
|
What do u mean by parameters tab. Can u plz give an example "Darren Green" wrote: From Jacco- You can use the Global Variable in your queries by using a question mark in the place where you want the variable to be used and assigning the global variable to it on the parameters tab. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:B14366DF-9AF6-4350-A6E3-EC2F3267835C (AT) microsoft (DOT) com... Ok fine. I have created the Global variable in the VBScript task. But how to refer to that variable in the SQL Queries and whether it would work in Oracle or not b/c SQL Execute task would send the query to run on the Oracle plateform. Would it replace the variable with its variable before sending it. Like I want to use the following query select * from Table where DateCol=[DateGlobalVariable] "Darren Green" wrote: Ok that makes sense. You use a table to store the date. I have a table that stores various information about the current run for example, including dates and times, around the work period for the current (ET)load. First task populates this table for the current run. Maybe it is on the wrong server though. The DTS way using a global variable is to use an ActiveX Script Task to set the variable first as Jacco suggested. This is done through the designer, so can you explain what you perceive as the problem? -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news 7FF0114-F4A9-4D47-8F9D-5FDBDC7C97D9 (AT) microsoft (DOT) com...Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#9
| |||
| |||
|
|
Thanks Darren, Darren I have used the following query insert into date_test (select d_date from bis_dwh.d_date where d_date >= ? ) in the SQLExec task and when I click on the parameters tab it gives me the following message "The SQL statement does not contain any parameters" I have created the Global variable in the ActiveX Script task just as Jacco told and have verified that the variable has been created in the package properties. Why I am getting the above msg? "Darren Green" wrote: Open the Exec SQL Task, there are four buttons just above the OK, Cancel set. One of them is Paramaters. Click it. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:EA4D543C-7C87-4F9B-9339-A24624CB76E6 (AT) microsoft (DOT) com... What do u mean by parameters tab. Can u plz give an example "Darren Green" wrote: From Jacco- You can use the Global Variable in your queries by using a question mark in the place where you want the variable to be used and assigning the global variable to it on the parameters tab. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:B14366DF-9AF6-4350-A6E3-EC2F3267835C (AT) microsoft (DOT) com... Ok fine. I have created the Global variable in the VBScript task. But how to refer to that variable in the SQL Queries and whether it would work in Oracle or not b/c SQL Execute task would send the query to run on the Oracle plateform. Would it replace the variable with its variable before sending it. Like I want to use the following query select * from Table where DateCol=[DateGlobalVariable] "Darren Green" wrote: Ok that makes sense. You use a table to store the date. I have a table that stores various information about the current run for example, including dates and times, around the work period for the current (ET)load. First task populates this table for the current run. Maybe it is on the wrong server though. The DTS way using a global variable is to use an ActiveX Script Task to set the variable first as Jacco suggested. This is done through the designer, so can you explain what you perceive as the problem? -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news 7FF0114-F4A9-4D47-8F9D-5FDBDC7C97D9 (AT) microsoft (DOT) com...Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
#10
| |||
| |||
|
|
The following SQL works fine in DTS - insert date_test select d_date from date_test where d_date >= ? I appreciate your are struggling, and that is fine, but please make some effort to do basic debugging first. If I take your SQL and change it slightly to use a table I have, and a real value instead of a parameter, this fails in QA- insert into date_test (select d_date from date_test where d_date >= getdate() ) Server: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'select'. Server: Msg 170, Level 15, State 1, Line 2 Line 2: Incorrect syntax near ')'. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:8CAB2AAB-9384-4A43-BB99-851B69541CE7 (AT) microsoft (DOT) com... Thanks Darren, Darren I have used the following query insert into date_test (select d_date from bis_dwh.d_date where d_date >= ? ) in the SQLExec task and when I click on the parameters tab it gives me the following message "The SQL statement does not contain any parameters" I have created the Global variable in the ActiveX Script task just as Jacco told and have verified that the variable has been created in the package properties. Why I am getting the above msg? "Darren Green" wrote: Open the Exec SQL Task, there are four buttons just above the OK, Cancel set. One of them is Paramaters. Click it. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:EA4D543C-7C87-4F9B-9339-A24624CB76E6 (AT) microsoft (DOT) com... What do u mean by parameters tab. Can u plz give an example "Darren Green" wrote: From Jacco- You can use the Global Variable in your queries by using a question mark in the place where you want the variable to be used and assigning the global variable to it on the parameters tab. -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:B14366DF-9AF6-4350-A6E3-EC2F3267835C (AT) microsoft (DOT) com... Ok fine. I have created the Global variable in the VBScript task. But how to refer to that variable in the SQL Queries and whether it would work in Oracle or not b/c SQL Execute task would send the query to run on the Oracle plateform. Would it replace the variable with its variable before sending it. Like I want to use the following query select * from Table where DateCol=[DateGlobalVariable] "Darren Green" wrote: Ok that makes sense. You use a table to store the date. I have a table that stores various information about the current run for example, including dates and times, around the work period for the current (ET)load. First task populates this table for the current run. Maybe it is on the wrong server though. The DTS way using a global variable is to use an ActiveX Script Task to set the variable first as Jacco suggested. This is done through the designer, so can you explain what you perceive as the problem? -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news 7FF0114-F4A9-4D47-8F9D-5FDBDC7C97D9 (AT) microsoft (DOT) com...Yeh I can do this in SQL like in Oracle I can have the following SQL select * from Table where DateCol=sysdate but the problem is that my ETL takes around 5 hrs to load the data into the warehouse and I have to schedule the ETL at 11:00 pm. So if I use the sysdate in SQL queries then in one SQLExecute Step I would have different date and in the that might execute after midnight the sysdate would return a diferent value. So no consistency. Thats why I want to store the cuurent system date in the global variable at start of the ETL and then use that value for all the steps. "Darren Green" wrote: Can you not do this in SQL? I don't know Oracle, but in T-SQL I would just do something like- SELECT * FROM Table WHERE DateCol = CURRENT_TIMSTAMP -- Darren Green http://www.sqldts.com "Akber" <Akber (AT) discussions (DOT) microsoft.com> wrote in message news:45E52F58-2F2C-4BF2-A93D-25769BB535C4 (AT) microsoft (DOT) com... I want to set the current system date in a global variable and then user that variable in diiferent SQL Execute tasks. How can I do this ? My Database is basically the Oracle 9i and I am using DTS Packages for ETL. I am using Microsoft OLE DB provider for Oracle. How can I set the current system date as the global variable and then use that variable in my SQL queries -- Thanks Akber. |
![]() |
| Thread Tools | |
| Display Modes | |
| |