Showing posts with label output. Show all posts
Showing posts with label output. Show all posts

Monday, March 26, 2012

Esql/C calling stored procedure with output parameters

I'm trying to write an esqlc program that will run a stored procedure that returns several output parameters. I haven't been able to find any documentation to date that explains how to run the "EXEC SQL EXECUTE procname" command and specify the output parameters.

My stored procedure "aek_proc1" takes one input parameter (p1 - an 8-character string) and 3 output parameters (p2 - an integer; p3 - an 8-character string, and p4 a 40-character string).

My esqlc program contains the following code.

EXEC SQL BEGIN DECLARE SECTION;
char p1[9];
int p2;
char p3[9];
char p4[41];
WXEC SQL END DECLARE SECTION;

sprintf(&p1[0], "GL");
p2 = 0;
sprintf(&p3[0], "");
sprintf(&p4[0], "");

EXEC SQL EXECUTE aek_proc1 :p1,
:p2 OUTPUT,
:p3 OUTPUT,
:p4 OUTPUT;

I am getting errors at runtime about constants being passed for OUTPUT parameters.

I can run the same stored procedure in Query Analyser and it works beautifully (see below)

declare @.p1 char(8)
declare @.p2 integer
declare @.p3 char(8)
declare @.p4 char(40)

set @.p1 = 'GL'

execute aek_proc1 @.p1, @.p2 output, @.p3 output, @.p4 output

select @.p1 p1, @.p2 p2, @.p3 p3, @.p4 p4

Any idea what I'm doing wrong or how it should be coded?

I'd really appreciate any advice you can offer!!

I've spend hours browsing this newsgroup and found lots of examples of how to do this in VB and from Query Analyser but I can't find any examples for ESQL/C that work.

So, please help!!!

Thanks,

AllanK :rolleyes:Oops.

Don't know why the host variable names got turned into smileys, but that bit should have read...

EXEC SQL EXECUTE aek_proc1 :p1,
:p2 OUTPUT,
:p3 OUTPUT,
:p4 OUTPUT;|||Have you tried to replace : with @.?|||I tried changing the EXEC SQL EXEC command in the ESQL/C program to read...

EXEC SQL EXEC aek_proc1 @.p1, @.p2 OUTPUT, @.p3 OUTPUT, @.p4

after which I got the runtime error...

"0137- Must declare the variable '@.p1'."

I tried adding...

EXEC SQL DECLARE @.p1 char(8);
EXEC SQL DECLARE @.p2 int;
EXEC SQL DECLARE @.p3 char(8);
EXEC SQL DECLARE @.p4 char(40);

EXEC SQL SET @.p1 = 'GL';
EXEC SQL SET @.p2 = 0;
EXEC SQL SET @.p3 = '';
EXEC SQL SET @.p4 = '';

EXEC SQL EXEC aek_proc1 @.p1, @.p2 OUTPUT, @.p3 OUTPUT, @.p4 OUTPUT;

but the error persists.

Any further suggestions?

Thanks,

AllanK

Wednesday, March 7, 2012

ErrorColumn field from Datasource Error Output

Hi,

The problem is, ErrorColumn contains ID. Is the following code reference safe ?
columnname = Me.ComponentMetaData.InputCollection.FindObjectByID(Row.ErrorColumn).Name

Is there any possibility for FindObjectByID to return NULL Reference in any case ?In many cases ErrorColumn is NULL.|||It contains ID, how do I translate it to Column Name ?
I have defined names in connection manager.|||I don't believe you can.|||Why I couldnt ?

That sucks|||

Fahad349 wrote:

Why I couldnt ?

That sucks

Because the column ID is the metadata ID of the column in the previous component, not the current component. So the ID being passed in isn't in the current component's metadata.

Indeed it isn't the best situation.

|||Dang on SQL Server team

Is there any harder way to do it ?|||

Fahad349 wrote:

Dang on SQL Server team

Is there any harder way to do it ?

You are welcome to submit a feature request: http://connect.microsoft.com/sqlserver/feedback

Errorcodes Ole DB destination error

I send my error output (errorcode , errorcolumn) of an Ole DB destination to another Ole DB destination. How do I know which errordescription belongs to an errorcode. For example errorcode "-1071607683"?

http://blogs.conchango.com/jamiethomson/archive/2005/08/08/1969.aspx

-Jamie

|||

Tnx! Is there also a way to do this with the error column name. So get the column name with the column number?

Friday, February 24, 2012

Error: The value was too large to fit in the output column "colName" (60).

Hi All,

I'm trying to transfer data from DB2 Database to SQL Server 2005.

Well, i used the OLE DB Source, the Data Conversion Component and the OLE DB Destination component.

I have five Data flows with this configuration above. But I am receiving an error message from one of them.

Please check below the error message:

"[Source Table TARTRATE [1]] Error: The value was too large to fit in the output column "ADJ_RATE_PCT" (60). "

"[Source Table TARTRATE [1]] Error: The "component "Source Table TARTRATE" (1)" failed because error code 0xC02090F8 occurred, and the error row disposition on "output column "ADJ_RATE_PCT" (60)" specifies failure on error. An error occurred on the specified object of the specified component."

Could you please help me with this issue?

Thanks in advance.

Thiago

The ADJ_RATE_PCT column in your data flow has a defined maximum width. You'll be able to find out what it is by double clicking the data-path leading from the source component.

What has happened is that a value has come in that is bigger than that defined maximum. So, you'll have to increase that maximum in the source component.

-Jamie

|||

Hi Jamie,

Thanks for your answer, but i still dont have a solution for this.

I tried to change the field width but i still have the same error message.

I think it is related with the field type. I received the same error message in another package and the field type is the same ( numeric , Precision 4 and Scale 2 ) as the first one.

I will continuing trying to figure out what is happening.

Thanks in advance.

Thiago

|||My guess is that, like Jamie said, a value is coming in that is bigger than the type. Based on the error message, and the type, it sounds like the value probably has a precision larger than 6. Have you tried increasing the precision (and possibly scale) of the output column in the advanced editor (inputs and outputs tab) of the source component?|||

Hi All,

Guys, thanks for your answer but I just don't know what to do now.

I changed the Precison (to 5) and Scale (to 3) in the Adavnced Editor following this sequence: Advanced Editor --> Input and Output Properties --> DataReader Output --> External Columns --> Select the column then change these two Data Types Properities: Precision and Scale. I tried to re-run the package and i still have the error message.

I saw that there is another "option" in the DataReader output menu called "Output Columns". I can't change any property in this menu. I guess these columns ( in the Ouptut Columns menu) are the return types from the source table ( im using a "select" command in a DB2 table ).

Another detail: in the "Output Columns" menu, the field that is returning error, has the precision 4 and Scale 2 ( remember: i cant change these values, they are automatically assigned by the component )). I think these values are comming from the source table. Am i right?

Thanks in advance for your help and atention.

Regards.
Thiago

|||

Hi Thiago,

Yes, in the DataReaderSrc you cannot change the properties of the output columns -- they are fixed at what the provider said the metadata was for the source column. Changing it in the External Columns will have no effect...

Your original post said you used the OLE DB Src -- if that is correct, you CAN change these properties there... Can you give that a try?

Thanks,
Mark

|||

Hi All,

Finally I find out what were happening in my application.

It was not related with the SQL2005 but with the DB2 ODBC Driver.

Follow below the instrunction how to fix this error in your DB2 ODBC Driver:

When you reconfigure your connection ( in the ODBC ), you have an Advanced button. So, you should click there and look for a Service Tab. In this service tab you have some "know workarounds".
There are two workarounds in this tab ( called PATCH 1 and PATCH2). In the second patch you have an option with this description: "Always use period for decimal separator in character output". You MUST select this option then type "15" in the value text box.

After that, just click ok and your DB2 ODBC driver will be configurated.

Thank you all for your answers.

See ya.

Thiago