Getting Started with Adobe After Effects - Part 6: Motion Blur
Ask
Ask questions, discuss or help others by answering
Related Posts · View All
SQL Server 142
TSQL 76
SSRS 70
SSIS 66
XML 54

Top Categories · View All
SQL Server 142
TSQL 76
SSRS 70
SSIS 66
XML 54

using Execute sql task and Precedence Constraint for data insertion

Apr 26 2012 12:00AM by karteek   

Hi Sudeep,

i am migrating data from some source into a table in first dataflow task, then
i want to check for table a particular column record is present or not using Execute sql Task, using precedence constraint, if the record is not their then in the next dataflow task it will fetch from other source and data is loaded .

if record is present then next dataflow task should not run.

please NeedHelpful

for more information: http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/5a4ccc3d-f6b6-4933-947a-ec932052c272

Submitted under: Microsoft SQL Server · SSIS - SQL Server Integration Services ·  ·  · 


karteek
304 · 0% · 143

18 Replies

  • The problem is due to not assigning Alias to your query output

    In executesql task in General Tab change SqlStatement property as below and in resultset property set as SingleRow and in Result Set tab set
    ResultName = RetResult
    VariableName = User::RowPresent1

    IF EXISTS (SELECT 1 FROM myDestination WHERE RecordID = x)
    THEN
       SELECT 1 as RetResult;
    ELSE
       SELECT 0 as RetResult;
    
    commented on Apr 26 2012 6:28AM
    Mitesh Modi
    18 · 10% · 3078
  • Hi Mitesh Modi , here i am using oracle database,

    so, i changed code to

    declare c integer; X integer;
    begin select count(*) into c from ba_account where NAME='UNKNOWN';
    if c > 0 then X :=1; else X :=0; end if;
    end

    in Result Set tab i set ResultName = X VariableName = User::RowPresent1

    it is giving error:

    Error: No result rowset is associated with the execution of this query. [Execute SQL Task] Error: An error occurred while assigning a value to variable "RowPresent1": "Exception from HRESULT: 0xC0015005".

    then i set Result Name to number 0 it is giving same error ,

    then next i set to 1 same error,

    then X same error

    please Suggest me for this what i want to set or any change in the oracle code ?

    commented on Apr 27 2012 12:57AM
    karteek
    304 · 0% · 143
  • Hi Karteek,

    I think in oracle column aliasing is working like this. in your example you have declare x variable. there is no need to declare variable.

    In oracel aliasing working like that below

    SELECT table1.Col1 AS "This is an alias" FROM table1
    

    OR

    SELECT table1.Col1 "This is an alias" FROM table1
    

    So you have to execute code like that

    declare c integer;
    begin 
    select count(*) into c from ba_account where NAME='UNKNOWN';
    if c > 0 then 
       select 1 "RetResult"; 
    else 
       select 0 "RetResult";  
    end if;
    end
    

    and then

    ResultName = RetResult
    VariableName = User::RowPresent1

    http://www.iforerunner.com/SQL/elearningcolumnalias.html

    commented on Apr 27 2012 3:37AM
    Mitesh Modi
    18 · 10% · 3078
  • HI Mitesh Modi ,Thanks for your Fast reply

    whenever i am executing above mentioned code

    declare c integer; begin select count(*) as c from ba_account where NAME='UNKNOWN'; if c > 0 then select 1 "RetResult" ; else select 0 "RetResult" ; end if; end;

    it is giving error message

    [Execute SQL Task] Error: Executing the query "declare c integer; begin select count(*) into c ..." failed with the following error: "ORA-06550: line 7, column 27: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 7, column 4: PL/SQL: SQL Statement ignored ORA-06550: line 9, column 26: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 9, column 4: PL/SQL: SQL Statement ignored ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    so, i changed it to

    declare c integer; begin select count(*) as c from ba_account where NAME='UNKNOWN'; if c > 0 then select 1 as "RetResult" from dual ; else select 0 as "RetResult" from dual ; end if; end;

    then error message:

    [Execute SQL Task] Error: Executing the query "declare c integer; begin select count(*) as c fr..." failed with the following error: "ORA-06550: line 4, column 1: PLS-00428: an INTO clause is expected in this SELECT statement ORA-06550: line 7, column 4: PLS-00428: an INTO clause is expected in this SELECT statement ORA-06550: line 9, column 6: PLS-00428: an INTO clause is expected in this SELECT statement ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    *please NeedHelpful.*

    commented on Apr 27 2012 5:52AM
    karteek
    304 · 0% · 143
  • you have written

    select count(*) as c from ba_account
    

    instead of

    select count(*) into c from ba_account
    
    commented on Apr 27 2012 6:15AM
    Mitesh Modi
    18 · 10% · 3078
  • like that below

    declare c integer; 
    begin 
    select count(*) into c from ba_account where NAME='UNKNOWN'; 
    if c > 0 then 
    select 1 as "RetResult" from dual ; 
    else 
    select 0 as "RetResult" from dual ; 
    end if; 
    end;
    
    commented on Apr 27 2012 6:22AM
    Mitesh Modi
    18 · 10% · 3078
  • Thanks Mitesh Modi for Quick response, i created a stored procedure

    CREATE OR REPLACE PROCEDURE Test143 AS
    c number(20);
    X number(20);
    BEGIN SELECT COUNT(*) into c FROM ba_account where NAME='UNKNOWN'; if c > 0
    then
    X := 1;
    else
    X := 0;
    end if; END;

    case 1: in the ResultSet tab i set

            ResultName : 0,
    

    it is giving error message

    [Execute SQL Task] Error: Executing the query "exec Test143" failed with the following error: "ORA-00900: invalid SQL statement ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    case 2:in the ResultSet tab i set

            ResultName : X,
    

    error message:

    [Execute SQL Task] Error: Executing the query "exec Test143" failed with the following error: "ORA-00900: invalid SQL statement ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    case 3:in the ResultSet tab i set

            ResultName : 1,
    

    error message:

    [Execute SQL Task] Error: Executing the query "exec Test143" failed with the following error: "ORA-00900: invalid SQL statement ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    please suggest me what value we have to set for ResultName ? or any other changes in stored procedure ?

    please NeedHelpful.

    commented on Apr 30 2012 2:18AM
    karteek
    304 · 0% · 143
  • Here your procedure doesn't return any thing. execute procedure in oracle and its output should be something like that

    X
    -
    1
    

    before end of procedure you have to write select query which return x as column with o or 1 as value

    commented on Apr 30 2012 3:12AM
    Mitesh Modi
    18 · 10% · 3078
  • Hi Mitesh Modi thanks for your quick responce,

    you mentioned before end of procedure you have to write select query which return x as column with o or 1 as value

    i changed procedure:

    CREATE OR REPLACE PROCEDURE Test143 (RECCOUNT OUT NUMBER) AS
    c number;
    X number;
    BEGIN SELECT COUNT(*) into c FROM ba
    account where NAME='UNKNOWN'; if c > 0
    then
    X := 1;
    else
    X := 0;
    end if; select X into REC_COUNT from dual;

    -- DBMSOUTPUT.PUTLINE(REC_COUNT); END;

    here REC_COUNT is out parameter i executed this code in sqldeveloper it is working fine.

    in execute sql task:

    sql statements :

    1) how to call this stored procedure ,

    so its return value which can be assigned to ResultName in ResultSet tab ,??

    in general oracle procedure with parameters can be execute using

    declare id1 number; begin Test143(id1); end;

    it return some value either 0 or 1

    2) how above statements should be written into execute sql task--sql statements--??

    or other better appraoch for Overall to this Thread.

    my aim is if the record is not loaded into table then next dataflow task should insert this value

    in next dataflow task i can make use of text file contains all the required records. this text file is used as source lookup with this table

    then unmatched records will get.

    this unmatched records will be loaded into this table

    but this approach is not correct . so, for this i am Forcefully using this execute sql task with precedence constraint

    Unfortunately this is not working.....

    commented on Apr 30 2012 5:38AM
    karteek
    304 · 0% · 143
  • what value we have to set for ResultName in ResultSet tab ,?

    commented on Apr 30 2012 8:28AM
    karteek
    304 · 0% · 143
  • Try this below code

    /*OLEDB Connection Type*/
    EXEC Test143 ? OUTPUT
    

    set Resultset = None

    and in parameter mappings

    variablename = @x
    Direction = Output
    DataType = Long
    Parameter Name = 0
    Parameter Size = -1

    see the first link of my previous post

    commented on Apr 30 2012 9:25AM
    Mitesh Modi
    18 · 10% · 3078
  • Hi Mitesh Modi thanks for your quick responce,

    as per your Suggestion , i created: user variable :x, datatype : int32 ,Value: 0, and in the Parameter Mapping as per your suggestion i added and i executed the package but

    error message:

    **Error: ORA-00900: invalid SQL statement

    [Execute SQL Task] Error: Executing the query "EXEC Test143 ? OUTPUT" failed with the following error: "One or more errors occurred during processing of command.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.**

    commented on Apr 30 2012 11:23PM
    karteek
    304 · 0% · 143
  • Hi Mitesh Modi ,

    in Execute Sql Task --General tab- i set Resultset = None

    i am using Connection Type:OLE DB

    i gone through

    http://blogs.msdn.com/b/mattm/archive/2006/11/08/stored-procedures-with-output-parameters.aspx

    but it is not working for oracle stored procedure.,

    Finally I realized that in my Scenario, Oracle Statements does not work with Execute Sql task.

    Thanks for Valuable time spent on this thread

    commented on May 1 2012 6:00AM
    karteek
    304 · 0% · 143

Your Reply


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]