Pass a variable value to SQL Command in OLEDB Source
Hi,
I have the OLEdb Source where it has SQL Command as Data Access Mode. Below is the sample query that i have in that.
DECLARE @MonthOffSet int = 24
DECLARE @PaidDate_SK_Low datetime = dateadd(mm,MONTH(getdate())-@MonthOffSet-1,dateadd(year,datediff(year,0,dateadd(YY,0,getdate())),0))
DECLARE @PaidDate_SK_High datetime = dateadd(dd,-1,dateadd(MM,@MonthOffSet,@PaidDate_SK_Low))
followed by select statement which has where clause.
Instead of hard code the value 24, i am trying to get the value from variable. I know there is a limitation to add the parameters only in where clause. Is there any work around or solution.
But i need to use the first four lines of code in lot other packages which has different sql statement. But if i make whole query variable then i have a limitation on length 4000 char.
DECLARE @MonthOffSet int = 24
DECLARE @PaidDate_SK_Low
datetime = dateadd(mm,MONTH(getdate())-@MonthOffSet-1,dateadd(year,datediff(year,0,dateadd(YY,0,getdate())),0))
DECLARE @PaidDate_SK_High
datetime = dateadd(dd,-1,dateadd(MM,@MonthOffSet,@PaidDate_SK_Low))
in my select statement in where clause i am using date range between @PaidDate_SK_Low
datetime and @PaidDate_SK_High
datetime
Any suggestions
Similar Messages
-
How to pass a variable for a SQL query in OLEDB source?
Hi All,
I am new to SSIS and working on it past few days. Can anyone please help me getting through a scenario where I need to pass a variable in the SQL statement in OLEDB source connection. Please find below for the details.
eg:
1) I have a SQL table with the columns SerialNumber, Name, IsValid, FileName with multiple rows.
2) I have the file Name in a variable called Variable1.
3) I want to read the data from my SQL table filtering based on the FileName (Variable1) within a data flow task and pull that data to the destination table.
Question: In the data flow task, added source and destination DB connection with a script component in between to perform my validations. When trying to retrieve the data from source using the variable (i.e. SQL Query with variable), I am not able to add
the query as the SQL statement box is disabled. How to filter the data based on the variable in the source DB ?
Any help/suggestions would be of great help.
Thanks,
SriJust to add with Vaibhav comment .
SQL Command : SQL query either with SQL variable or any condition or simple Sql statement
Like ;
Select * from dimcustomer
SQL Command using Varible :
Sometimes we design our dynamic query in variable and directly use that variable name in oledb source.
If you Sql query needs a condition based on SSIS variable .
you can find a Example here :
http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
http://www.select-sql.com/mssql/how-to-use-a-variable-inside-sql-in-ssis-data-flow-tasks.html
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
Problems passing timestamp variable to block-SQL command not properly ended
Can you please help me answer or direct me to resources in answering the following.
I'm attempting to pass a timestamp variable to a block but am getting errors with every method I've tried yet.
The example below is attempting to generate a list of all sales dates for orders after the 21st of March 2000.
DECLARE
BeginDate Orders.PurchaseDate%TYPE :=to_date('21-3-2000', 'dd-mm-yyyy');
Target Orders.PurchaseDate%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(to_char(BeginDate));
SELECT Distinct PurchaseDate from Orders into Target WHERE PurchaseDate>BeginDate;
END;
When running it - it returns
ORA-00933: SQL command not properly ended ORA-06512: at line 8Please advise-- I"m still trying to get a timestamp into an execute immediate statement.
Declare
BeginDate Orders.PurchaseDate%TYPE :=to_date('21-3-2000', 'dd-mm-yyyy');
var_date Orders.PurchaseDate%TYPE ;
BEGIN
DBMS_OUTPUT.PUT_LINE(to_char(BeginDate,'DD.MM.YYYY'));
sql1 = 'SELECT MAX(PurchaseDate) INTO Target from Orders WHERE PurchaseDate> :var_date';
Execute Immediate sql1 Using BeginDate;
DBMS_OUTPUT.PUT_LINE(to_char(Target,'DD.MM.YYYY'));
END;
Thanks again for the replies, I'm still not there yet even after re-reading the documentation that applies to this,
Using what follows below the Execute Immediate line/syntax is the problematic part of this...
to quote the block line still returning errors.
This line which would seem natural...
Execute Immediate sql1 Using BeginDate;returns -- missing keyword
Modified with this line attempts to pass another variable to the block also errors.
Execute Immediate sql1 Using BeginDate, var_date;returns -- ORA-01006: bind variable does not exist
Perhaps I'm not getting some key concept here, but I would think passing a variable into execute immediate would be
as simple as passing a string or int into a *.bat,*.sh file or function/procedure in any other language.
And/or I'm missing a key element or understanding to how this syntax should work.
Thank you very much for your previous replies any other ideas welcome. -
Pass Parameter to IN Operator in SQL Command in OLEDB source
Hi,
I am trying to pass multiple values as one parameter. Eg: I need to get the employess with gender in ('M','F')
query: select eno, ename, sal, gender from emp where gender in (?)
Created a variable 'varGender' with the value - 'M','F'
And passed the parameter mapping in OLEDB Source. But this is not returning any records.
Please advise.
Thanks.Hi Vaibhav,
Thanks for your kind reply.
I need to pass the same where condition to multiple source queries and we don't want to repeat the same condition in all queries and replace with a variable. Also the query is too big to keep it in the Variable. Please help me.
Thanks
Put the required filter values in a staging table and then use it in a join condition with all the other tables in all the other tasks.
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to pass session variable value with GO URL to override session value
Hi Gurus,
We have below requirement.Please help us at the earliest.
How to pass session variable value with GO URL to override session value. ( It is not working after making changes to authentication xml file session init block creation as explained by oracle (Bug No14372679 : which they claim it is fixed in 1.7 version Ref No :Bug 14372679 : REQUEST VARIABLE NOT OVERRIDING SESSION VARIABLE RUNNING THRU A GO URL )
Please provide step by step solution.No vague answers.
I followed below steps mentioned.
RPD:
****-> Created a session variable called STATUS
-> Create Session Init block called Init_Status with SQL
select 'ACTIVE' from dual;
-> Assigned the session variable STATUS to Init block Init_Status
authenticationschemas.xml:
Added
<RequestVariable source="url" type="informational"
nameInSource="RE_CODE" biVariableName="NQ_SESSION.STATUS"/>
Report
Edit column "Contract Status" and added session variable as
VALUEOF(NQ_SESSION.STATUS)
URL:
http://localhost:9704/analytics/saw.dll?PortalGo&Action=prompt&path=%2Fshared%2FQAV%2FTest_Report_By%20Contract%20Status&RE_CODE='EXPIRED'
Issue:
When I run the URL above with parameter EXPIRED, the report still shows for ACTIVE only. The URL is not making any difference with report.
Report is picking the default value from RPD session variable init query.
could you please let me know if I am missing something.Hi,
Check those links might help you.
Integrating Oracle OBIEE Content using GO URL
How to set session variables using url variables | OBIEE Blog
OBIEE 10G - How to set a request/session variable using the Saw Url (Go/Dashboard) | GerardNico.com (BI, OBIEE, O…
Thanks,
Satya -
How to pass Temp variable value instead of Table name in From clause.
Hi,
I have an requirement to pass the Temperorary variable value instead of Table name in FROM Clause in SQL.
But I am strugglint to pass this variable value.
E.g., a Varchar2(5) := 'aa';
Select * from a;
Here I come to mention a - 'aa'. But the SQL looks for 'a' as Table. But its should look into 'aa' as Table name.
Kindly guide me.
Thanks.SQL> declare
a varchar2 (5) := 'emp';
v varchar2 (100);
cur sys_refcursor;
begin
open cur for 'Select ename from ' || a;
fetch cur into v;
while cur%found
loop
dbms_output.put_line (v);
fetch cur into v;
end loop;
close cur;
end;
JAMES
SCOTT
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
KING
TURNER
ADAMS
FORD
MILLER
PL/SQL procedure successfully completed. -
Passing CPM variable value to BW report/query
Is it possible to pass CPM variable values from SEM scorecard to BW supporting reports.
Not sure if this is what you are looking for, but it's my first thought of what I would try:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/3.0b report-report interface.pdf -
Can we Pass two variable values in to one Varaible which is Cust Exit?
Hi all,
Can we pass two Variable values to a Variable which is Custexit?(For Example posting Period and the fiscalyear in to the FicalPeriod )
Regards
KiranHello,
For that example you had to "convert" both post period and fiscalyear into fiscalperiod, and yes it is possible, but not throwing up the two values, you had to do it yourself in the user exit code.
Diogo. -
How to pass a variable value into a custom planning function via a web
Can some one tell me
How to pass a variable value into a custom planning function via a web template?
What are the different types of Planning function parameters available and what is the difference between them?
Thanks
babuHi Sutrtha,
Yeah I got the pop up asking to select the variables used, I have selected ENTITY_ID that was used by the interfaces, but on execution of the package the Scenario did not work as the passeed variable #ENTITY_ID is set to 0 instead of the value I am passing.
Am I missing something?
Regards
B -
Virtual KF(as Date) in Cube and pass the variable value to this VKF runtime
Hi ,
User would enter 1 date using date variable untime.
My cube also has 1 Completed Date (KF).
And i wann do comparisan based on input variable and exisitng variable.
Can i add 1 Virtual KF(as Date) in Cube and pass the variable value to this VKF runtime and do the calculation in cube ???
I know the same thing i can do in formula , but i have some different req.which i am unable to explain u here .
So please let me know can i use VKF if yes how ???
Points would be thrown for all .
Bapuit's the exact posting from your last post. Please don't duplicate the postings, so that we can help you in one thread and not so many different threads
-
Passing global variable values from databse to forms
I am using forms 6i and database is oracle 9i.
I am trying to run a form stand alone ( by pressing CTRL-R) without putting it in the application.
since when this form is placed in the application menu it works fine as it has been passed global variables values from the database .
now i am trying to run the form without menu and thus i want to pass the values of global variables .please let me know where should i pass these values in form .is it be WHEN-NEW-FORM-Instance trigger or in Pre-form trigger.
i know what are the global variable values passing into the form from database.
i can hard code any values to check if the form runs well or not.If you intend to do this sort of testing regularly you might want to consider creating a seperate form with a control block which allows entry of the name of the form you want to run, the names of the globals and their values, and do a CALL_FORM.
-
Passing a variable to an SQL Expression Field
Is it possible to pass a value or variable to an SQL Epression field? I want to sum the values of open invoices for a particulat customer and want to do this using an SQL Expression Field. I need this sum in a subreport and since I can not put a subreport in a subreport I want to do it using an SQL Expression.
Thanks.
RalphThat would require a SELECT statement in the expression and they really are not designed to do that.
If you can't do this client side write a stored procedure then you have full control and CR is just used to display the data. -
How Pass a variable to a Host command
I want to pass a variable to host command from a form, My Block is mytable in the field is Docs.
I want to use Host(start acroexe32 d:\Files\..Here to insert the vaiable for the value in mytable.docs)
nullTry this
Host( 'start acroexe32 '| |:mytable.docs | |'''', No_Screen );
Ashish -
Open a crystal report from WAD with passing the variables values
Hi,
I need to know is there any way to link SAP WAD to crystal reports (open a crystal report from WAD)and pass the values of the variables which are entered in the Web App. (e.g. Customer id,year) should be passed to the Crystal Report.
Maybe we need to pass parameter by WAD URL but this is just my assumption and have no idea how to do this with passing variable values.
right now I know the method of how Bex queries which are used as data source for crystal reports but in my current scenario we have the structure like this that bex queries link with WAD and then WAD is linked with crystal reports.
No doubt that Crystal report is target option in RRI but there the source is Bex Query only but in current scenario we are looking WAD (web template) as a source to crystal report or crystal report called in WAD.
Please suggest something on same.
Thanks
Take care
Vishal sharmaHello Vishal.
Did you find a solution for this problem?
I'm facing right now the same problem, I need a way to link SAP WAD to crystal reports (open a crystal report from WAD) and pass the values of the variables which are entered in the Web App. (e.g. Customer id,year) should be passed to the Crystal Report.
Have found an answer to this issue? If yes, please kindly inform how have you solved this.
Best Regars
Armando Santos -
How to pass the variable value to reports as a parameter
hi
i have facing a problem that i want to pass the value of a variable that i had calculate in a procedure like
SELECT nvl(BASIC_PAY,0) INTO v_basic FROM EMP WHERE EMP_ID=P_EMP_ID;
so i want to send the variable value v_basic as a parameter through form to report...and simlarly other variables values which i have calculate in procedure....
need ur help to solve this problem
thanks in advanceit's the exact posting from your last post. Please don't duplicate the postings, so that we can help you in one thread and not so many different threads
Maybe you are looking for
-
Pavilion dv7 - Can I add a second hard drive?
I have an HP Pavilion dv7 2173cl laptop. I've read that I can add a second internal hard drive. Is that correct? If so, what is the max size that it will take? Any special type that I should buy? Thanks! This question was solved. View Solution.
-
ITunes wont load on my computer
Hey itunes wont load on my computer. It has been working for years but now it dosent work any more.
-
How to obtain the file name of the cached file
Hi All, I am using JMF to play a MP3 file from an HTTP link and I need to know the file name of the locally cached file. I found that I can obtain the cache directory using Manager.getCacheDirectory() and I can see the cached file there but its file
-
Hi, I need to exclude cache folders from backup and am using java.util.regex for this. I am reading the regex like D:\test\b\cache.*? from a simple text file using BufferedReader. I Thought the problem was related to the backslash escapes but I am no
-
I want to be able to search for songs the way I could before itunes 11
Please tell me there is a way to switch the search feature back to the original before this update. I hate the fact that my search comes up with albums and artists etc when all I want to do is search for a song and have it show up in the list form. I