ODBC Source- incorrect number of result columns.

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

ODBC Source- incorrect number of result columns.

Post by deepak.shanthamurthy »

Hi,

In one of my ODBC sources am having an user defined SQL Query with a group by clause in it.
Inspite of the source definition having all the columns required the job fails giving the following error message :
"SQL statement has incorrect number of result columns"
The sql works fine and am also able to view data in the source stage...

Any Idea whats happening??

~
Deepak
Deepak
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Post your SQL please.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
dwandbi
Participant
Posts: 29
Joined: Sat Feb 04, 2006 6:17 pm

check

Post by dwandbi »

To see whether you have same columns listed on Source inputs stage and Target output stage.

thanks,
Tom
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

Post by deepak.shanthamurthy »

it is exactly similar to this query here....

Select
dept_id,
department_name,
sum(salary)
From
employee
group by
dept_id,
department_name
Deepak
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I know you're new here, so welcome aboard. Please post your exact SQL because soooo many times the "just like this SQL" isn't just like the SQL.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

Post by deepak.shanthamurthy »

Ok here it comes....

select
dept_id,
sub_dept_no,
dept_seq_no,
sum(salary) as sum_salary
from
Employee
group by
dept_id,
sub_dept_no,
dept_seq_no

My source stage has all the four columns in the select clause...
Deepak
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

Post by deepak.shanthamurthy »

well.....
Thanks for the help ....
I just had to tick the Group check box in the source columns tab.....
Deepak
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You should try recreating the job using just ODBC-->XFM-->SEQ. If you're on DS 5, there could be something flaky where the job isn't correctly put together underneath the covers.

You don't need to use the "as sum_salary" because DS doesn't care. It runs the query as a cursor and just reads from the cursor. Columns are positional in nature, so when using user-defined SQL you must make sure datatypes, size, and scale match your definitions.

The group by shouldn't be an issue. If you switched your SQL back to generated and just streamed out the data, does it work still?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

deepak.shanthamurthy wrote:well.....
Thanks for the help ....
I just had to tick the Group check box in the source columns tab.....
There you go :roll: . Anyways, job's done.

gateleys
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Hmmm, that shouldn't have made any difference. With generated SQL, that matters because it is writing the query for you and would add a GROUP BY clause with your columns. You would also have to put something into the DERIVATION column to MIN/MAX/SUM/COUNT/etc the non-grouping columns.

It sounds like somehow your query was generated and not user-defined.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

Post by deepak.shanthamurthy »

Well.... the job is quite not done....
it works when i just have this source write to a file....
but when i join this source with another table it continues to plague me with the same error............
Deepak
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Does the other table have exactly the same four columns defined exactly the same way?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
deepak.shanthamurthy
Participant
Posts: 17
Joined: Tue Apr 11, 2006 2:35 pm

Post by deepak.shanthamurthy »

No the other table just has the 3 key columns.....
the job is working now....but then i dont know what exactly the problem was.....
As it was just a group by clause .... i changed the query to a generated query and added the sum clause in the derivation as suggested by one of the responses above...and it worked fine....
but iam still not sure why it did not work when i used a user defined query which was exactly the same......
Thanx for the help
Deepak
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

More than likely because it wasn't exactly the same. The trick is figuring out what the difference was...
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply