If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2 export with table join(?)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-11, 02:27
jbglotz jbglotz is offline
Registered User
 
Join Date: May 2011
Posts: 3
db2 export with table join(?)

We're using V9.5_FP5 on AIX 5.3

I have one table call_detail with call, calldate, callid and many more columns. I have 2nd table CALLIDLIST_TAB with a list of callids.

I want to export all the records from table call_detail for date 5/7/11 that also have callids in table CALLIDLIST_TAB.

I was thinking it would be something like this:

db2 -v "export to arcexp050711.ixf of ixf messages arcexp050711.msg select * from schemaname.call_detail where calldate = '05/07/2011' and
where callid in (select CALLID from schemaname.CALLIDLIST_TAB)";

but I'm getting this error:

SQL3022N An SQL error "-104" occurred while processing the SELECT string in the Action String parameter.
SQL0104N An unexpected token "callid" was found following "5/07/2011' and
where". Expected tokens may include: "<space>". SQLSTATE=42601


Something's wrong with my syntax...I'm obviously not a sql expert...I think it's a simple fix though. I hope anyway ..Thanks for your help!

Last edited by jbglotz; 05-14-11 at 11:02.
Reply With Quote
  #2 (permalink)  
Old 05-14-11, 07:09
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
select * from schemaname.call_detail where calldate = '05/07/2011' and
where callid in (select CALLID from schemaname.CALLIDLIST_TAB)
If you couldn't find an error in this SQL,
you should learn SQL again from beginning.

Don't stick too much on error message text.
Most time, error message text is a key to solve the issue.
But, if the error was syntax error(SQL0104N, SQLSTATE=42601),
sometimes the message text may mislead you.

Last edited by tonkuma; 05-14-11 at 07:21.
Reply With Quote
  #3 (permalink)  
Old 05-14-11, 07:36
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Here is an example of SQL0104N error.

Code:
------------------------------ Commands Entered ------------------------------
select * from employee where where empno = '000100';
------------------------------------------------------------------------------
SQL0104N  An unexpected token "empno" was found following "employee where 
where".  Expected tokens may include:  "<space>".  SQLSTATE=42601
But, this worked.
Code:
------------------------------ Commands Entered ------------------------------
select * from employee where_ where empno = '000100';
------------------------------------------------------------------------------

EMPNO  FIRSTNME     MIDINIT LASTNAME        WORKDEPT PHONENO HIREDATE   JOB      EDLEVEL SEX BIRTHDATE  SALARY      BONUS       COMM       
------ ------------ ------- --------------- -------- ------- ---------- -------- ------- --- ---------- ----------- ----------- -----------
000100 THEODORE     Q       SPENSER         E21      0972    2000-06-19 MANAGER       14 M   1980-12-18    86150.00      500.00     2092.00

  1 record(s) selected.
Reply With Quote
  #4 (permalink)  
Old 05-14-11, 11:08
jbglotz jbglotz is offline
Registered User
 
Join Date: May 2011
Posts: 3
Quote:
Originally Posted by tonkuma View Post
If you couldn't find an error in this SQL,
you should learn SQL again from beginning.

Don't stick too much on error message text.
Most time, error message text is a key to solve the issue.
But, if the error was syntax error(SQL0104N, SQLSTATE=42601),
sometimes the message text may mislead you.

It would be great if I had time to learn SQL from the beginning. Thanks for taking the time to help. I realize it's a generic syntax error. I just thought someone would see what's wrong quickly. Thanks again.
Reply With Quote
  #5 (permalink)  
Old 05-14-11, 13:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by jbglotz View Post
I just thought someone would see what's wrong quickly.
Each subselect contains only one WHERE clause.
Reply With Quote
  #6 (permalink)  
Old 05-14-11, 22:47
jbglotz jbglotz is offline
Registered User
 
Join Date: May 2011
Posts: 3
solved

Quote:
Originally Posted by n_i View Post
Each subselect contains only one WHERE clause.
Thank you! I knew it was something that would be obvious to someone! thanks again...query worked nicely.
Reply With Quote
  #7 (permalink)  
Old 05-17-11, 03:21
jamiforyou jamiforyou is offline
Registered User
 
Join Date: Aug 2010
Posts: 3
Quote:
Originally Posted by jbglotz View Post
We're using V9.5_FP5 on AIX 5.3

I have one table call_detail with call, calldate, callid and many more columns. I have 2nd table CALLIDLIST_TAB with a list of callids.

I want to export all the records from table call_detail for date 5/7/11 that also have callids in table CALLIDLIST_TAB.

I was thinking it would be something like this:

db2 -v "export to arcexp050711.ixf of ixf messages arcexp050711.msg select * from schemaname.call_detail where calldate = '05/07/2011' and
where callid in (select CALLID from schemaname.CALLIDLIST_TAB)";

but I'm getting this error:



SQL3022N An SQL error "-104" occurred while processing the SELECT string in the Action String parameter.
SQL0104N An unexpected token "callid" was found following "5/07/2011' and
where". Expected tokens may include: "<space>". SQLSTATE=42601


Something's wrong with my syntax...I'm obviously not a sql expert...I think it's a simple fix though. I hope anyway ..Thanks for your help!

hello
When sql statements contain special characters, for example,
line breaks, carriage returns, line feeds, receive the error SQLState=42601.
Remove special characters from sql statements

Regards
jamil
Reply With Quote
Reply

Tags
aix, export, join, sql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On