truncate command in ODBC

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

truncate command in ODBC

Post by samsuf2002 »

Hi All , i am running a parallel job on LINUX my database is SQL server and target stage i am using is ODBC .I need to truncate the table before every insert so i used OPEN COMMAND as TRUNCATE TABLE tablename it is giving me error as invalid command But when i used DELETE command it worked fine . But i would preffer to go with truncate as the size of the data will be big.

Any Suggestions

Thanks in Advance
hi sam here
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You sure you have truncate permissions ?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Can you post the "exact" error message you get.
Also any surrounding error messages if any.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Do I need to have permission for that , because i can truncate the table by going into the data base . What kind of permissions do i need?
hi sam here
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

I guess you have the permission to truncate the table but still it will be better to confirm with your DBA. re you trying to clear the table and insert or just want to truncate the table and where are you using this command? Also paste the error message here.

Sam
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If you can do it from outside datastage then you do have Truncate permissions. Thats not it. Also make sure your using the same id to access the database within datastage.
You said that DELETE FROM TABLE works, you meant the delete command works in the OPEN command option? Please confirm.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Ultramundane
Participant
Posts: 407
Joined: Mon Jun 27, 2005 8:54 am
Location: Walker, Michigan
Contact:

Post by Ultramundane »

Does DS put the open command in a transaction.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

i am trying to truncate the table and insert for every new load. i dont have the error message now since i have ran the job with DELETE command and it ran fine . when i read the message it was showing as "invalid command for TRUNCATE TABLE tablename"

Dsguru , DELETE command worked for open command
hi sam here
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perhaps it needs a trailing semi-colon in the OPEN command?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Thanks a lot Ray its working now i used trailing semi-colon in open command
.
hi sam here
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

So how come the DELETE command was working without a semi-colon :roll:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Because DELETE is DML and TRUNCATE TABLE is not.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Makes sense. Thanks for the clarification Ray.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Hi , On the day when we discussed this topic my problem was solved at that time i ran the job with sample file like 1000 recs now i am running the job with 8 million recs , i am surprised to see the same error stating the query in open command " TRUNCATE TABLE table name ;" as invalid command . Can any one help me out here .

Thanks in Advance
hi sam here
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Size should not matter, in this situtaion. Check with your DBA's.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Post Reply