Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Unable to pass year as string in sql query
rawal79
Hi,
I am using BIRT 2.3.2 and i want to pass string into my sql query.
In BIRT my query is as follows
var sqlText = new String();
var sqld= new String();
sqld= '2013' ;
// Add query to sqlText variable.
sqlText =" select pmnum,SITEID,(select description from locations where pm.location = locations.location) "
+ "as Site, "
+ "(select wonum from workorder where "
+ "workorder.pmnum = pm.pmnum and targstartdate > sqld+'-07-01' and targstartdate "
+ "<'2013-08-01') as july "
+ " from pm where siteid = 'A' "
+ "and status = 'ACTIVE' "
+ "and pfmanticipated > 0 "
+ "ORDER BY pmnum "
The above query is pulling no data. If i use '2013'+'-07-01' instead of sqld+'-07-01' it will work. Any idea why it is behaving like this,my basic concern is to pass (year) string as parameter and then concatenate with month and day('-07-01') that is hard coded. Cheers
Find more posts tagged with
Comments
Tubal
Not sure if this is why, but your quotes might be in the wrong place.<br />
<br />
Try:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>+ "workorder.pmnum = pm.pmnum and targstartdate > '" + sqld + "-07-01' and targstartdate "</pre>
rawal79
<blockquote class='ipsBlockquote' data-author="'Tubal'" data-cid="116845" data-time="1368726620" data-date="16 May 2013 - 10:50 AM"><p>
Not sure if this is why, but your quotes might be in the wrong place.<br />
<br />
Try:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>+ "workorder.pmnum = pm.pmnum and targstartdate > '" + sqld + "-07-01' and targstartdate "</pre></p></blockquote>
rawal79
Hi,
Thanks for your email. I have applied the new code but it is not pulling data. Basically my target is to pass parameter as string like '2013/2014' for financial year and after passing parameter i want to get string before '/' that is 2013 and then i want to use that year in my code like '07-01' basically my date would become 2013-07-01. Is there any other alternate way of achieving this task. Cheers
rawal79
Hi,
I tried to change situation and it works
+ "workorder.pmnum = pm.pmnum and targstartdate > convert(datetime,'" + params["fromdate"] + "-07-01') and targstartdate "
Right now i am passing parameter fromdate 2013 as integer and it is working, but my real target is to pass string like 2013/2014 for financial year. When i tried pass 2013 as string it is pulling no data. Is there any way that i can resolve this issue. Cheers