Truncate statement in a stored procedure

How can I execute a DDL statement, TRUNCATE TABLE table_name, from a stored procedure. In fact, I have tried the following:
execute immediate ' truncate table table_name ';
but it doesn't work. Do you have any ideas.
The Oracle version is 7.3.
Thanks in advance.

The syntax for using dbms_sql is
DECLARE
v_cur INTEGER;
v_ret INTEGER;
BEGIN
v_cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cur, 'TRUNCATE TABLE your_tab', dbms_sql.v7);
v_ret := DBMS_SQL.EXECUTE(v_cur);
DBMS_SQL.CLOSE_CURSOR(v_cur);
END;
It's usually worth puting this in a stored procedure and passing the DDL statement in as a parameter, saves you having to type all this out everytime.
If you don't have the dbms_sql package installed, the scripts are usually found under rdbms/admin

Similar Messages

  • JDBC/select/async statement to JDBC/stored procedure/sync call

    Hi
    We have JDBC/select/async statement to JDBC/stored procedure/sync call i.e sender and receiver are JDBC.
    PI has to pick all the the records of single internal order number at a time from sender system and upload to receiver JDBc,
    gets the response and routes to sender/insert statement.
    This should run only once per day.
    We will have multiple Internal orders daily, each order consisting of 10 to 20 records but only one IO related records has
    to upload to Receiver/JDBC
    What are the options available ?
    We have thought of following options
    1. SQL query is already to pick, but we have to pick records at one time daily. example: morning,evening or midnight.
       At that time it can pick multiple times but it should not pick through out day
    2. Is there any option in BPM so that we can group IO's at a time and upload ? If so what are the steps need to use
       Any additonal receive step need to be used to pick the records from the table.
    Thanks

    hi
    as i can understando you, you will receive mani IO and you must execute one IO in the receiver SP? if so, you can solve this usssing a ccBPM where you will have to create a mapping(0.N) where the source and the target structure will be the same, the diferrence will be in the occurrance of the target structure which will have to be 0.N (Tab signature in Message Mapping). then back to the ccBPM define a block with the property ForEach. this will  loop any times accord with the number of IO that you receive from the sender. as a result you will execute one SP for each IO.
    so, you ccBPM will be
    RS>TS>BLOCK(Multiline container and single container of source structure)>TS->SS
    RS:Receive Step
    TS:Trans. Step
    SS:Send Step
    Also the container will be:
    source--> type Abs
    source_multiline --> type Abs
    target -->type Abs
    Thanks
    Rodrigo P.
    Edited by: Rodrigo Alejandro Pertierra on Jun 24, 2010 4:54 PM

  • DDL Statements in a Stored Procedure

    Is there some technique which can be used to execute DDL statements in a stored procedure? I want to drop and recreate a table and a number of indexes. Is there a way for me to do this within a stored procedure?
    Thanks in advance for your assistance!!!

    BEGIN
       EXECUTE IMMEDIATE 'CREATE TABLE bonus (id NUMBER, amt NUMBER)';
    END;http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems18.htm#33889

  • Writing mulitple sql statements in 1 stored procedure

    Hi all, can i know how to create mulitple sql statements in 1 stored procedure??
    Eg the first sql statement will generate few results and my second sql statement will based on the first statement result to execute its second results and my third sql statements will on the second results to generate the final results which will be passed back to jsp pages as a resultset??
    For the time being, i only know how to create a single sql statement in one stored procedure..i had surf through the oracle website but cant find any solution. Can anyone help me?? Samples or links to any website will do.. Thanks alot...

    Hi Irene,
    If I understand your question correctly, then I have already written
    a similar (PL/SQL) stored procedure without any problems.
    However, I do think your question is more suited to the following
    forum:
    http://forums.oracle.com/forums/forum.jsp?id=478021
    I also think it will help others to answer your question if you
    include the following information:
    1. Version of Oracle you are using.
    2. The error message you are getting.
    3. The part of your code that is causing the problem.
    Also, have you looked at the following web sites?
    http://asktom.oracle.com
    http://metalink.oracle.com
    Good Luck,
    Avi.

  • Rollback of JDBC Statement on error - Stored Procedure

    Hi All,
    We are using the JBDC receiver adapter for inserting the record and for that we are using the Strored Procedure and we have N number of the records for insertion in a single mapping so, we have given the occurence of the Statement 1 : unbounded as, multiple statement will be executed so, my query is if one of statement fails because of some error(Mapping error or data error) what will happen to the statement which are already executed, do they rollback? or it is not possible in case of stored procedure?
    Regards,
    Gaurav

    Hi,
    This is one of the solution but i guess there is one more issue, if we have 10 statements and third statement shows error and Stored Exception exception branch is able to catch then it will rollback the previous statement but can we able to restrict another 7 pending statement for execution or not?
    Regards,
    Gaurav

  • Callable statement with oracle stored procedure error

    i'm calling a stored procedure in java with the following code. However i constantly recieve this error
    so what is going on please HELP
    Parameter Type Conflict: sqlType=2006
    my call statement would be this:
    call Statement = {call getUserByLogin(?,?,?,?)}
    if(storedProcedureName=="getUserByLogin"){
    strCStmt = ("{call " + storedProcedureName +"(?,?,?,?) }");
    cStmt.setObject(1, "system");
    cStmt.setObject(2, "username");
    cStmt.setObject(3,"password");
    cStmt.registerOutParameter(4, java.sql.Types.REF);
    rs = cStmt.executeQuery();
    i've also tried it with a setString as the IN parameter:
    here's the stored procedure:
    CREATE OR REPLACE PROCEDURE getUserByLogin (
    arg_subscriptionName IN varchar,
    arg_loginName IN varchar,
    arg_password IN varchar,
    arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
    ) AS
    var_userNum int;
    BEGIN
    select
    u.userNum into var_userNum
    from
    userInfo u,
    subscription s
    where
    s.subscriptionName = arg_subscriptionName AND
    s.subscriptionNum = u.subscriptionNum AND
    u.loginName = arg_loginName AND
    u.password = arg_password;
    if (var_userNum is null) then
    var_userNum := 0;
    end if;
    getUser(var_userNum, arg_rec_userinfo_valLanguage);
    END;

    i'm calling a stored procedure in java with the
    following code. However i constantly recieve this
    error
    so what is going on please HELP
    Parameter Type Conflict: sqlType=2006
    my call statement would be this:
    call Statement = {call getUserByLogin(?,?,?,?)}
    if(storedProcedureName=="getUserByLogin"){
    strCStmt = ("{call " + storedProcedureName +"(?,?,?,?)
    cStmt.setObject(1, "system");
    cStmt.setObject(2, "username");
    cStmt.setObject(3,"password");
    cStmt.registerOutParameter(4, java.sql.Types.REF);
    rs = cStmt.executeQuery();
    i've also tried it with a setString as the IN
    parameter:
    here's the stored procedure:
    CREATE OR REPLACE PROCEDURE getUserByLogin (
    arg_subscriptionName IN varchar,
    arg_loginName IN varchar,
    arg_password IN varchar,
    arg_rec_userinfo_valLanguage OUT
    types.rec_userinfo_valLanguage
    ) AS
    var_userNum int;
    BEGIN
    select
    u.userNum into var_userNum
    from
    userInfo u,
    subscription s
    where
    s.subscriptionName = arg_subscriptionName AND
    s.subscriptionNum = u.subscriptionNum AND
    u.loginName = arg_loginName AND
    u.password = arg_password;
    if (var_userNum is null) then
    var_userNum := 0;
    end if;
    getUser(var_userNum, arg_rec_userinfo_valLanguage);
    END;
    /Hai,
    Try with this if u are using Oracle.
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    (inbetween ur code)
    cStmt.registerOutParameter(4, OracleTypes.CURSOR);
    //in place of "cStmt.registerOutParameter(4, java.sql.Types.REF);"
    Hope u reply with joy.
    regards,
    Siva Kumar Annavaram

  • Create "dynamic" statements in a stored procedure

    hello
    in my stored procedure I need to write a statement like this:
    FUNCTION myfunct (mytable IN VARCHAR2)
    BEGIN
    EXECUTE IMMEDIATE
    'SELECT COUNT(*)
    INTO myvar
    FROM ' || mytable ||
    'WHERE mycol = ' || currval;
    In short I need to create a sort of "dynamic" statement in which the tablename (nad other...) is a variable....
    but I do not guess it's ok...
    How can I do?

    Hi,
    With dyanmic SQL, the INTO clause is part of the EXECUTE IMMEDIATE statement, not the query.
    Try something like this:
    CREATE OR REPLACE FUNCTION     myfunct
    (       mytable       IN     VARCHAR2
    RETURN     PLS_INTEGER
    IS
         return_num     PLS_INTEGER;
         sql_txt          VARCHAR2 (1000);
    BEGIN
         sql_txt := 'SELECT  COUNT (*)'
              || ' FROM ' || mytable;
         dbms_output.put_line (sql_txt || ' = sql_txt in myfunct');
    --     EXECUTE IMMEDIATE sql_txt INTO return_num;
         RETURN     return_num;
    END     myfunct
    /It's a good idea to develop dynamic SQL as shown above; putting the dynamic statement into a variable that can easily be displayed for debugging.
    When it looks right, then un-comment the EXECUTE IMMEDAITE statement.
    Before moving the code into Production, comment out (or remove) the put_line statement.

  • DDL statement/s in stored procedures (FUNCTION)

    Hello all,
    I was trying to create a small function that tests keywords on the basis of successful/failed table creation. If a table can be created with a keyword as identifier, it is a non-reserved keyword, if table creation fails, it is a reserved keyword:
    CREATE OR REPLACE FUNCTION createTableForKeyword (keyword VARCHAR) RETURN BOOLEAN IS
    BEGIN
    CREATE TABLE keyword (x NUMBER);
    -- if no exception occurred, table creation succeeded
    DROP TABLE keyword; drop it
    RETURN FALSE; -- FALSE means non-reserved
    EXCEPTION
    WHEN OTHERS THEN
    -- if exception occurred, table creation failed
    RETURN TRUE; -- TRUE means reserved
    END createTableForKeyword;
    This would have been my first PL/SQL program, but I get the following error:
    PLS-00103: Found symbol "CREATE" when expecting one of:
    begin case declare exit ................
    .............. merge pipe
    I had to translate the error message from German, but it should suffice. Obviously DDL statements in functions are not allowed. How do I solve my problem then, given a table that has one column containing the keyword?:
    CREATE TABLE Keywords (keyword VARCHAR(30));
    I was looking too call this function from a loop, but how would I do this without a function? How do I capture table creation fails without exceptions in functions?
    TIA
    Karsten

    To run DDL inside stored procedure you must use Dynamic SQL. Use EXECUTE IMMEDIATE
    To see if a word is a reserved word just query V$RESERVED_WORDS
    Thanks,
    Karthick.

  • Extraction SQL statement from oracle stored procedure stored in file

    Hi,
    I am newbie to oracle stored procedure. I need to extract the list of sqls present in oracle stored procedure. Besides that I also want to parse these sql statements to get the list of tables and columns used. Is there any tool which can help me in doing thats.
    thanks,
    govind

    why don't check on user_dependencies table instead?
    select referenced_name,referenced_type
    from user_dependencies
    where name='<your stored procedure name in upper case>'
    and referenced_type = 'TABLE'HTH,
    Prazy

  • Got error when use case statement in oracle stored procedure

    Hi,
    I have a query like:
    select merchant_id,
    case
    when product_type='K' then 'Production'
    when product_carrier='UC' THEN 'Shipping'
    end the_type
    from product_tbl
    where merchant_id=10114
    It works fine. But as soon as I put it into a stored procedure, I got error like:
    Encountered the symbol "CASE" when expecting one of the following:
    ( - + mod null <an identifier>
    Please help!

    Oracle 8i doesn't support CASE into PL/SQL, so as Kamal said, create a view with the CASE, and use this view into your PL/SQL.
    Nicolas.
    And an example here :
    Re: Execute Immediate doesnot work in 8i (8.1.7) and Ref Cursor not exec qu
    Sorry Kamal.
    Message was edited by:
    N. Gasparotto

  • User can Execute SQL Statement but not Stored Procedure

    I have a function in Access that calls a stored procedure to update a table. When I run it, it works fine but when the users try to run it, they get an error.
    If I change it run the actual SQL syntax that is in the stored procedure then the users can run it and update the table without any problems, which makes no sense to me. It's doing the same exact thing as the stored procedure. I'd much rather have them be
    able to run the procedures then writing the SQL in VBA modules because that's going to end up being a lot of code.
    Any idea on why it's like this and how to correct it? Any assistance would be appreciated.

    Hello,
    When you give a user permission to run a stored procedure, everything on that procedure but Dynamic SQL will be executed
    without evaluating user permissions on the objects the stored procedure deals with.
    On the link I provided above, you will see how to provide permissions to stored procedures. Try creating database roles, add user to database roles, then assign permissions to database roles.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Reg: Truncate table command in Stored Procedures

    Hi All,
    I wrote one procedure in which i used 'Truncate Table command' and while compiling I am getting an error. I searched on google but again many queries has been asked there but no suitable solution is there. So please help me in understanding this matter.I will be really obliged of you.
    Gursimran Singh

    Hi thanks for your reply. The error I am getting is here
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    := . ( @ % ;
    The symbol ":= was inserted before "TABLE" to continue.
    I appreciate your step to use 'execute immediate 'truncate table table_name';. but the thing is that the system is not allowing my to use TRUNCATE than how come i use the above expression.
    Second thing is that there is no error in syntax, everything is fit and fine.
    Gursimran

  • Fails to execute all statements in a stored procedure

    We are executing a stored proc on SQL Server 7.0. We are using the jdbc odbc bridge. The procedure has database inserts on seven tables.
    It executes fine when it's executed from the SQL server query analyzer. All the inserts go through without any problem.
    We have a problem when the proc is executed from the front-end. All the inserts except the last two go through without any problem. The sixth insert is partially completed (two out of 300 rows are inserted) and the seventh one is not at all executed.
    No error messages are generated. Surprisingly the stored proc executes fine when executed from the front-end from a Win 98 machine. It's giving a problem only on Win 2000. Could somebody please help us in finding a fix for this problem. Why is it behaving differently when executed from the front-end on a Win 2000 mahinne.
    Thanks in advance.

    Why is it behaving differently when executed from the front-end on a Win 2000 mahinne. Possible reasons.
    -Because you aren't sending the same data.
    -It is has an internal error and that is being ignored.
    -It isn't going to the same database and the stored proc is actually different.

  • Unable to execute EXECUTE IMMEDIATE statement in a stored procedure...

    Hi People,
    I use oracle 10g.In which i tried a procedure with follwing code and am thrown with the error that says,
    SQL>   create or replace procedure ptable(ptab varchar2) is
      2  lstmt varchar(200);
      3  begin
      4  lstmt:='CREATE TABLE '||ptab||'(a int,b varchar2(30)) ';
      5  execute immediate lstmt;
      6  end;
      7  /
    Procedure created.
    SQL>  exec ptable('hos');
    BEGIN ptable('hos'); END;
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "VIDYA.PTABLE", line 5
    ORA-06512: at line 1Procedure has been created but error occurs while executing it.why do i get this error even though i possess DBA privilege?.which permission is lagging for me?.help me with ur suggestions.thanks in advance.
    With Regards
    VIDS

    Yep Yep.Perfect.It was the CREATE ANY TABLE privilege which i was lagging.I granted it to my schema and now got created with the table.Thanku so much for such a quick reply :).
    With Regards
    VIDS

  • 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

Maybe you are looking for