Questions regarding queryText (Stored Procedure)

lpurba
edited February 11, 2022 in Analytics #1
Hi all,I have a question about queryText.Here is the problem that I have.I have <oda-data-set-extensionID="org.eclipse.birt.report.data.oda.jdbc.SPSelectDataSet" name="StudentId" id="11">, and inside this element I have:<property name="queryText">{call tm.display_student()}</property>.In this case, I am accessing the data thru stored procedure, instead of directly using SELECT statement.And in my <method name="beforeOpen"> I have this for my report parameter (StudentId):<![CDATA[StudentId = reportContext.getParameterValue("StudentId");if (StudentId != '' && StudentId ! = null) { queryString = "SELECT student_id, fname, lname FROM students WHERE student_id = '" + StudentId + "'"; this.queryText = queryString;}]]>So, by having this 'beforOpen', this queryText will be executed if there is a value for "StudentId" report parameter.My question is: is it possible to call or to have stored procedure (display_student()) on "beforeOpen" method instead of accessing the data directly by having SELECT statement?Regards-Laurent

Comments

  • lpurba
    edited December 31, 1969 #2
    Sorry, I am going to re-post the same question, because the beforeOpen method was not able to display:
    Hi all,I have a question about queryText.Here is the problem that I have.I have <oda-data-set-extensionID="org.eclipse.birt.report.data.oda.jdbc.SPSelectDataSet" name="StudentId" id="11">, and inside this element I have:<property name="queryText">{call tm.display_student()}</property>.In this case, I am accessing the data thru stored procedure, instead of directly using SELECT statement.And in my <method name="beforeOpen"> I have this for my report parameter (StudentId):StudentId = reportContext.getParameterValue("StudentId");if (StudentId != '' && StudentId ! = null) { queryString = "SELECT student_id, fname, lname FROM students WHERE student_id = '" + StudentId + "'"; this.queryText = queryString;}So, by having this 'beforOpen', this queryText will be executed if there is a value for "StudentId" report parameter.My question is: is it possible to call or to have stored procedure (display_student()) on "beforeOpen" method instead of accessing the data directly by having SELECT statement?Regards-Laurent
  • rmurphy
    edited December 31, 1969 #3
    Hi Laurent,Let me know if I an not understanding correctly. You want to pass a parameter into the report in the reportContext, and use that value to pass into your stored procedure to affect the results you get back. Correct?It appears you have successfully done this using a SQL Select statement. I have been successful there as well. I will try this with a Stored Procedure.In the mean time, is there any reason that you cannot pass in the value as a parameter instead of through the reportContext? I have done this with a stored procedure and it works great. Let me know...Rob
  • lpurba
    edited December 31, 1969 #4
    Hi Rob,Thanks for your reply.I did use parameter before. I don't why I changed it to reportContext.Anyway, I found the solution.queryText = "SELECT * FROM display_student() WHERE student_id = '" + StudentId + "'";Thanks!-Laurent