Why doesn't SSRS like an IF Statement in my SQL Stored Procedure???

I have multiple IF Statements at the end of my SQL Stored Procedure Process that utilizes a @ReportTypeName Parameter to produce the chosen report result set
IF @ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
BEGIN
SELECT DISTINCT
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
FROM [#TempTable_Distinct_Individual_Member_All_Info]
WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
(SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans])
ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
END
IF @ReportTypeName = 'HMO-POS Renewals'
BEGIN
SELECT DISTINCT
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
[#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
FROM [#TempTable_Distinct_Individual_Member_All_Info]
INNER JOIN [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]
ON [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR] = [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
END
Microsoft Visual Studio and SQL Server Reporting Services did not like this! When I added my dataset and parameters accordingly, my Dataset had no fields...almost as if running the Stored Procedure in the background to get its Metadata was not working. I
know this works because I tested it as a result of a straight EXEC Command. Why doesn't Microsoft Visual Studio and SQL Server Reporting Services not like this IF? I did end up getting around this by parameterizing the WHERE clause based on the @ReportTypeName
chosen.
WHERE (@ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
(SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
OR (@ReportTypeName = 'HMO-POS Renewals'
AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] IN
(SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
I appreciate your review and am hopeful for a reply.
Thanks!

Hi ITBobbyP,
I have tested on my local environment and can reproduce the issue, the issue can be caused by the temp table you are using which will also cause the data not display.
I have use below sample table and record to have a test and details information below for your reference:
Right click the DataSet to select the "DataSet Properties" and click the query designer to execute the stored procedure by click the "!" to check if you can get the data:
If you got some error, the issue can be cause by the temp table invalid, so please make sure you have add the query to create and insert  recored to temp table like below:
CREATE PROCEDURE vickytest0311_1
@ReportTypeName nvarchar(50)
AS
create table #VickyTest
column1 int,
column2 varchar(20)
insert into #VickyTest values (1,'Test1')
insert into #VickyTest values (2,'Test2')
insert into #VickyTest values (3,'Test3')
IF @ReportTypeName ='Test1'
BEGIN
select * from #VickyTest
where Column1=1
END
IF @ReportTypeName ='Test2'
BEGIN
select * from #VickyTest
where Column1=2
END
GO
3. I recommend you to not use the temp table and you will not need to add the create and insert statement in the stored procedure.
4. If you still got no data, please try to click the "Refresh fields" as below:
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support

Similar Messages

  • Added new parm to an existing SQL stored procedure CR 11 doesn't like it

    Hi
    I have added a new parameter to an existing SQL stored procedure (SQL 2000).  This stored procedure is currently being called from a Crystal XI report.  It prompts for a date which works great.  (The report was created with this parameter).  I added a new parameter to the stored procedure.  When I do a preview in Crystal, it prompts for the new parameter, but is NULL when I look at the SQL query and it brings back no data.  If I try to verify the database, it tells me that I am missing parameter @ProcessType (varchar(5))--(name of new parameter).  I have physically added this parameter to the crystal report with the select expert and still no luck.  I have already tried renaming the procedure but am unable to update datasource location because of this parameter.  The report is very detailed and I do NOT want to create a new report.

    Unfortunately, I have tried and retried to do this.  Nothing changes.  I usually would get a message like database has changed, proceeding to fix report.  I don't get this.  It merely tells me database is up to date and only returns the 1 parameter, yet when I go to the datasouce and try to update it, it tells me that I have not supplied the new parameter.
    I have tried everything, from closing Crystal reports and then going so far as to reboot my machine, just in case their was some kind of caching going on.
    I have even asked other people I work with to look at it to make sure I am not doing something dumb...

  • How to automate DDL statements in batch or stored procedure?

    I'd like to write a start file or stored procedure to create synonyms for all tables owned by the current user as well as any to which the user has been granted access. However, no DDL statement like create synonyms is allowed in stored procedures. How can I solve this problem?
    I am very new to Oracle, can anyone recommend a site that publishes lots of PL/SQL scripts?

    Phyllis,
    It looks like a problem with permissions, as Narayan Archarya said.
    In order to test your code, I connected as user scott, copied your code, put two hyphens in front of the line that begins with execute immediate, compiled it, set serveroutput on, and executed it as:
    SQL> EXECUTE create_synonyms ('scott')
    It worked properly, displaying:
    cursor is opened.
    stmt_str = CREATE SYNONYM ADDRESSES FOR SCOTT.ADDRESSES
    rowcount = 1
    and continued in this manner, incrementing the row counts and displaying a stmt_str for each table. This confirms that there is no problem with the code. It has got to be a problem with privileges.
    To test the theory that it is a problem with privileges, I connected as system manager and created user abc, granting connect, resource, and create table to abc. I then connected as abc and created a table named abc. I then recompiled the create_synonyms, set serverouput on, and I executed it as:
    SQL> EXECUTE CREATE SYNONYMS ('ABC')
    Once again it worked properly, displaying:
    cursor is opened.
    rowcount = 1
    stmt_str = CREATE SYNONYM ABC FOR ABC.ABC
    rowcount = 1
    end
    PL/SQL procedure succesfully completed.
    I then tried executing it as (while still connected as user abc):
    SQL> EXECUTE create_synonyms ('scott')
    and I got:
    cursor is opened.
    rowcount = 0
    end
    PL/SQL procedure succesfuly completed.
    I tried the reverse, by connecting as user scott and executing as:
    SQL> EXECUTE create_synonyms ('abc')
    and got the same:
    cursor is opened.
    rowcount = 0
    end
    PL/SQL procedure succesfuly completed.
    I then connected as user abc and entered:
    SQL> GRANT SELECT ON ABC TO SCOTT;
    Then I connected as scott, set serveroutput on, and executed again as:
    SQL> EXECUTE create_synonyms ('ABC')
    and it worked:
    cursor is opened.
    rowcount = 1
    stmt_str = CREATE SYNONYM ABC FOR ABC.ABC
    rowcount = 1
    end
    PL/SQL procedure successfully completed.
    So, the conclusion is that there is a problem with privileges, probably related to the user executing the procedure and/or the user creating the procedure not having privileges to the tables created by the user that corresponds to the table_owner parameter passed to the procedure.
    This may not be the whole problem as far as permissions, but it is probably part of it.
    null

  • Why Dynamic Parameter is not working, when i create report using stored procedure ?

    Post Author: Shashi Kant
    CA Forum: General
    Hi all
    Why Dynamic Parameter is not working, when i create report XI using stored procedure ?
    Only i shaw those parameters which i used in my stored procedure, the parameter which i create dynamic using stored procedure
    is not shown to me when i referesh the report for viewing the results.
    I have used the same procedure which i mention below but can not seen the last screen which is shown in this .
    ============================================================================================
    1. Select View > Field Explorer2. Right-click on Parameter Fields and select New from the right-click menu.3. Enter u201CCustomer Nameu201D as the name for your parameter4. Under u201CList of Valuesu201D select u201CDynamicu201D5. Under the Value column, click where is says u201Cclick here to add itemu201D and select Customer Name from the drop-down list. The dialog shown now look like the one shown below in Figure 1. Click OK to return to your report design.
    Dynamic Parameter Setup6. Next, select Report > Select Expert, select the Customer Name field and click OK.7. Using the drop-down list beside select u201CIs Equal Tou201D and using the drop-down list, select your parameter field (it should be the first field). 8. Click OK to return to your report design and see the parameter dialog.The parameter dialog will appear and show you a dynamic list of values that is updated each time your run your report. It couldnu2019t be easier! In our next tutorial, we will be looking at how to use this feature to create cascading parameter fields, where the values are filtered by the preceding selection.
    Dynamic Parameters in Action
    My question is that whether dynamic parameter is working with storedprocedure or not.
    When i added one table and try to fetch records using dyanmic prameters. after that i am not be able to find the dynamic parameter option when i referesh my report.
    One more thing when i try the static parameter for my report, the option i see when i referesh the screen.
    Please reply soon , it's urgent
    Regards
    shashi kant

    Hi Kishore,
    I have tested the issue step by step by following you description, while the first issue works well in my local environment. Based on my research, this can be caused by the lookup expression or it indeed return Male value based on the logic. If you use the
    expression below, it will indeed only return the Male record. So please try to double-check the record in the two datasets and the expression in your environment:
    =lookup(first(Fields!ProgramID.Value,"DataSet1"),Fields!ProgramID.Value,Fields!Gender.Value,"DataSet2")
    As to the second issue, please try to use the following expression:
    =Count(Lookup(fields!ProgramID.value,fields!ProgramID.value,fields!Gender.value,"DataSet2"))
    Besides, if this issue still exist, in order to trouble shoot this issue more efficiently, could you please post both the .rdl  file with all the size properties to us by the following E-mail address?  It is benefit for us to do further analysis.
    E-mail: [email protected]
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Sql stored procedure using IN Statement

    hi below is my stored procedure, but im not able to get the results
    alter PROCEDURE homepageitems
            @categoryid int,
                    @websiteid  int
            ,@websiteitems VARCHAR(15)
    AS
    BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.
        SET NOCOUNT ON;
       SELECT Product.id, Product.name, Product.Price, categoryid FROM product where  Product.Published=1 and Product.Deleted=0
         and Categoryid=@categoryid and websiteid=@websiteid and product.id in (' + @websiteitems + ')
    END
    GO
    DECLARE    @return_value int
    EXEC    @return_value = [dbo].[homepageitems]
            @categoryid = 67,
            @websiteid = 2,
            @websiteitems = N'75530,75667,75518,75953'
    SELECT    'Return Value' = @return_value
    GO
    Msg 245, Level 16, State 1, Procedure homepageitems, Line 20
    Conversion failed when converting the varchar value ' + @websiteitems + ' to data type int.
    and Im supplying the correct values of websiteitems (75530,75667,75518,75953) and Product.id is integer field, how do i supply when im using IN Statement

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you have no idea).
    Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    This is not a correct schema design; can you fix this mess? 
    A procedure is named <verb>_<object>.
    There is no such thing as a “category_id” in RDBMS! A column is “<attribute>_<attribute property>” but this is two <attribute property>'s without an <attribute>. This is like adjectives without a noun! 
    Using integers to encode the homepage categories is an awful design. Have you been to a library? Look at the Dewey Decimal Classification system. Noobs never bother to properly design encoding schemes; really hopeless noobs use IDENTITY! 
    Aren't websites named and not numbered? What integer did you use to get to this website? See the point? 
    There is no such thing as a generic “id” or “name”  or "category" in RDBMS. Table names are collective or plural nouns to show us that they are sets. 
    We do not use flags in RDBMS, so your “publication_flag” and “deletion_flag” are both verbs (attributes are noun!) and a huge design flaw. 
    Finally, you have made one of the classic Noob errors that most people un-learn in 3rd or 4th week of SQL. You cannot past a string to IN() and expect that string to be parsed for you! Think about how silly that is and get a laugh at yourself. SQL is compiled,
    not interpreted like 1960's BASIC! 
    Google my articles on the long parameter list for the procedure. But your real problem is an awful schema, improperly designed in both the DDL and data architecture. 
    Post the DDL and maybe we can fix it. But you need to get a book on basic data modeling as well as one on SQL. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Clubbing two statements into one in Stored Procedure

    I am writing a stored procedure and one of the statement goes like this
    IF
    LOWER(@in_data_detail_info)
    LIKE('%low_price%')
    BEGIN
    set @out_price_col_desc
    =
    'Low Price'
    end
    IF
    LOWER(@in_data_detail_info)
    LIKE('%low_price%')
    BEGIN
    set @price_type
    =
    'low_price'
    end
    since
    IF
    LOWER(@in_data_detail_info)
    LIKE('%low_price%') 
    is common, can i club it into one something like this
    IF
    LOWER(@in_data_detail_info)
    LIKE('%low_price%')
    BEGIN
    set @out_price_col_desc
    =
    'Low Price'
    and @price_type
    =
    'low_price'
    end
    it was showing error, can we write something similar to reduce the number of lines.

    Hi Syed, Please post the error that you get. A quick glance at the block of code "since" what is that since for?
    and in last IF block "set @out_price_col_desc
    =
    'Low Price'
    and @price_type
    =
    'low_price'
    " change it like below.
    set @out_price_col_desc = 'Low Price'
    set @price_type = 'low_price'
    Hope this helps..........
    Ione

  • Why 'wrong number of parameters' error in this call to a stored procedure?

    A stored procedure exists that inserts a new record and returns the newly generated record ID. This stored procedure is called from a WinForms application but at the ExecuteNonQuery time an exception is thrown indicating that the wrong number of parameters
    has been supplied. If I take out the one parameter that is marked as ParameterDirection.Output then the ExecuteNonQuery does not throw an exception.
    CREATE PROCEDURE [dbo].[API_InsertIntoManu]
    @Name nvarchar(50),
    @Description nvarchar(2000)
    AS
    SET NOCOUNT ON
    INSERT INTO Manu (
    [Name],
    [Description]
    VALUES (
    @Name,
    @Description
    SELECT SCOPE_IDENTITY() As InsertedID
    END
    GO
    The C# code that calls the above SP looks like this:
    using (SqlConnection conn = new SqlConnection( "<snipped>" ))
    using (SqlCommand cmd = new SqlCommand( "[dbo].[API_InsertIntoManu]", conn ))
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add( Name, SqlDbType.NVarChar, 50 ).Value = "some name";
    cmd.Parameters.Add( Title, SqlDbType.NVarChar, 200 ).Value = "some title";
    // This parameter is supposed to receive the new row's ID but instead triggers a 'wrong number of args' exception.
    cmd.Parameters.Add( "InsertedID",SqlDbType.Int ).Direction = ParameterDirection.Output;
    conn.Open();
    // This is where the exception gets thrown.
    cmd.ExecuteNonQuery();
    iReturn = (int)cmd.Parameters[InsertedID].Value;
    Richard Lewis Haggard

    In you sp the size of Title var is 2000 and not 200, correct this:
    cmd.Parameters.Add( "@Title", SqlDbType.NVarChar, 200 ).Value
    Fouad Roumieh

  • Why doesn't AirTunes like oggs?

    I guess this could also be in the AirPort Express forum, but here goes:
    iTunes will (fairly) happily play back oggs with the help of the QuickTime plug-in available from www.xiph.org with OggDrop X. Yet it won't stream oggs to my remote speakers. I thought that iTunes also needed QT to encode/decode AAC files, which stream perfectly well. So surely it's not the use of QTper se which causes a problem. I've tested that anyway by selecting QT in the Airfoil application chooser while iTunes is playing an ogg, which doesn't work. I imagine that the AAC codec is built into QT rather than being a plug-in like the ogg codec, but surely all that iTunes sees is a helper application decoding audio files for it?
    I've downloaded Airfoil which is a great little app (at last I can listen to BBC Radio 4 in my living-room in Melbourne!), but I feel I must be missing something simple here. Can anybody explain why AirTunes doesn't like oggs?

    ...and I have the same result when trying to stream to Apple TV.  Please help, someone!!

  • Why doesn't Verizon allow retirees from state employment to continue to receive discounts?

    I worked for the state of Texas for 25 years.  I am now disabled but being paid by the State of Texas' Employee Retirement System as a continuing "disabled employee".  Verizon (customer service) doesn't recognize this as a valid form of state employment; therefore I am losing my discount.  WHY? It seems contradictory that a continuing employee - or retiree from employment should continue to receive benefits.  If not through state employment; why not as a disabled person?  I just think Verizon is not being fair with a discount they should be providing. 

    sttxdisabled wrote:
    I worked for the state of Texas for 25 years.  I am now disabled but being paid by the State of Texas' Employee Retirement System as a continuing "disabled employee".  Verizon (customer service) doesn't recognize this as a valid form of state employment; therefore I am losing my discount.  WHY? It seems contradictory that a continuing employee - or retiree from employment should continue to receive benefits.  If not through state employment; why not as a disabled person?  I just think Verizon is not being fair with a discount they should be providing. 
    People need to understand whether your employer offers a discount and how much that discount is is up to your employer not Verizon. Verizon has nothing to do with whether Texas wants to give retirees discounts.  Considering what party runs your state is should not be shocking that neither retirees or disabled people get anything. 1/4 of your state is uninsured that's all you need to know about how your state is run.

  • Why does TO_CHAR not like me adding a fraction then specifying FF?

    Why does TO_CHAR not like me adding a fraction?
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS') FROM Dual;
    TO_CHAR(
    17:36:07
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS.FF') FROM Dual;
    SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + .733409047, 'HH24:MI:SS.FF') FROM Dual
    ERROR at line 1:
    ORA-01821: date format not recognized
    -- NUMTODSINTERVAL() saves the day.
    SQL> SELECT TO_CHAR(TO_TIMESTAMP('1/1/2012', 'DD/MM/YYYY') + NUMTODSINTERVAL(.733409047, 'DAY'), 'HH24:MI:SS.FF') FROM Dual;
    TO_CHAR(TO_TIMESTA
    17:36:06.541660800

    Hi,
    Date arithmetic only works with DATEs.
    If you want to do something similar with TIMESTAMPs, use NUMTODSINTERVAL:
    SELECT  TO_CHAR ( TO_TIMESTAMP ('1/1/2012', 'DD/MM/YYYY') + NUMTODSINTERVAL (.733409047, 'DAY')
              , 'HH24:MI:SS.FF'
    FROM      dual
    ;Here's exactly what's happending:
    When you say "d + n", d is supposed to be either a NUMBER or a DATE. When you pass any other datatype, Oracle tries to convert d to either a NUMBER or a DATE. In this case, d was a TIMESTAMP; Oracle realized that it could convert that TIMESTAMP into a DATE, and did so. The 1st argument to TO_CHAR, therefore, was a DATE, but '.FF' only works with TIMESTAMPs.
    There are a couple of things about how Oracle handles this that I find annoying, but I don't know of any better work-around.
    Edited by: Frank Kulash on Feb 16, 2012 1:39 PM

  • Calling a Stored Procedure using SSRS Custom Data Processing Extension

    I need SSRS Custom Data Processing Extension to call a stored procedure for my ssrs report. I refered many links regarding this, but i cannot find it. Instead of that there are examples for Data processing extensions that uses XML files and also multiple
    data sources.
    I want Data Processing Extension to call a stored procedure.
    Please Help. Thanks in advance

    Sorry why do you need a Data Processing Extension for that? Cant you directly call the procedure
    from SSRS dataset? Whats the RDBMS which holds this procedure?
    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

  • Sender JDBC adapter : Update SQL Statement : stored procedure

    Hi,
    Can we use a stored procedure in the sender jdbc adapter in 'Update SQL Statement'.
    The problem i am facing is like, we are selecting data from two tables in 'SQL statement for query' and then in 'Update SQL Statement' , we need to delete that data from these two tables.
    Please let me know if it is possible.
    Thanks,
    Rohit

    you can use a Stored procedure in the
    Query SQL Statement
    You have the following options:
    ·        Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
    ·        Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
    The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs.
    so have your whole select and update as part of this single Stored procedure

  • Creating multiple datasets using mulitple select statements as part of one macro / stored procedure

    Hi,
    I am working on a report what has 10 datasets derived from 10 different select statements.
    Is it possilbe to save those 10 select statements as a macro / stored procedure and then use that macro to generate those dataset in the ssrs report builder ?
    AshishSinghal

    Hi AshishSinghal84,
    According to your description, you want to write multiple select statements in a procedure, then use the procedure as dataset in the report, right?
    According to my knowledge, when we write multiple select statements in a procedure, we have to create relationship between these select statements, otherwise it will only return the first one query's fields. If you are using SSRS 2008 R2, you can use Lookup
    function to display these fields from different datasets on one data region control, but the prerequisite is that you must have one common field. For more information about lookup function, please see:
    http://msdn.microsoft.com/en-us/library/ee210531.aspx
    If all these solution you cannot achieve due to your special condition, the last workaround is to use subreport to display all the fields together.
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • Collable statement and stored procedure problem

    Hi,
    I am using a collable statement to execute a stored procedure.
    The stored procedure is a bit complex since it uses a function to retrieve sequence nextval (newId),
    than insert a row and returns the newId.
    Anyway, I checked it with sql plus and it works, but when trying to execute it from my Java code, I get the following error message:
    java.sql.SQLException: ORA-06550: line 1, column 33:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( ) , * @ % & | = - + < / > at in mod not range rem => ..
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between is null is not || indicator is dangling
    The symbol ")" was substituted for ";" to continue.
    Anyone can help?
    Thanks,
    Michal

    My PL/SQL code:
    CREATE OR REPLACE FUNCTION getNotifSeq RETURN NUMBER
    IS
    newId NUMBER;
    BEGIN
         SELECT NOTIFICATION_SEQ.NEXTVAL INTO newId FROM DUAL;
    RETURN newId;
    END;
    run
    CREATE OR REPLACE PROCEDURE insertNotifMsg (
    sentBy IN VARCHAR,
    subject IN VARCHAR,
    msg IN VARCHAR,
    newId OUT NUMBER)
    IS
    BEGIN
    newId := getNotifSeq;
    INSERT INTO NOTIFICATIONS(NOTIF_ID,SENT_BY,SUBJECT,MSG)
    VALUES(newId,sentBy,subject,msg);
    END insertNotifMsg;
    run;
    My Java code to call the procedure:
    try
    conn = myDBconn.getConnection();
    CallableStatement callStmt = conn.prepareCall("{call insertNotifMsg(?,?,?,?}");
    callStmt.setString(1,notif.getSentBy());
    callStmt.setString(2,notif.getSubject());
    callStmt.setString(3,notif.getMsg());
    callStmt.registerOutParameter(4, Types.INTEGER);
    ResultSet rs = callStmt.executeQuery();
    if (!rs.next()) {
    throw new SQLException("ERROR: Notification was not inserted into database!");
    long newId = callStmt.getInt(4);
    callStmt.close();
    notif.setNotifId(newId);
    conn.commit();
    callStmt.close();
    finally
    myDBconn.closeConnection(conn);
    Thanks,
    Michal

  • SELECT statement in stored procedure

    I want to be able to execute a simple SELECT statement from within a stored procedure and return a stream of data which consists of all the rows from the SELECT statement.
    Ultimately, I want to ouput this stream of data to a Crystal Report.
    Apparently, Oracle will not allow you to execute a simple SELECT statement from within a stored procedure. It will only allow execution of a SELECT INTO statment, which requires that you define a cursor, etc. etc.
    Any way around this?
    Thanks
    Bill

    Look into REF CURSORs. Still not sure about whether APEX uses them though.... Good luck.

Maybe you are looking for