How to acces a database table with BCI?

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
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

How to acces a database table with BCI?

Post by olgc »

Hi every body,

A ODBC data source is set up and an entry is added into uvodbc.config. How to write the code to access the database with BASIC SQL Client Interface? Can some one there provide a sample code? The code does:

1. Set up a connect to a database,
2. query a table (select ... from ...)
3. return the result

Do we use the following statement to connect to a database? what's connect.env?

status = SQLConnect (connect.env, data.source, logon1, logon2)

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

Post by kcbland »

You do realize that the ODBC drivers that ship with DS are only licensed thru the ETL tools, and any direct usage via programming, which includes your DS BASIC programs, is not covered under the licensing agreement? This means you will get 30-day usage warning messages on every query executed, and then it stops working until you purchase those drivers. Of course, if you're using your own separate ODBC drivers, ignore my commentary.

But, what are trying to do and why are you doing it this way? If you're accessing Oracle, SQL-Server, DB2/UDB, Sybase, MySQL, etc, there are command line programs from these databases that can execute SQL scripts and return data to the screen for parsing. Why wouldn't you prefer that method?
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
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

We own other your own ODBC drivers.

The reason for BCI ODBC is to build the auto-balancing table. You get the number of records from Datastage and Database, then check these two to see if they are the same.

Once we ran across case these two were different in production.

If you use BCI ODBC, one simple job can do the whole balancing things. Can you suggest better approach?

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

Post by kcbland »

How about use DS API's to extract link metrics for row counts and write them to a text file. Then use a standard job to load that data into a database table. Simple SQL in your target database can compare row counts.
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
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

The data you suggested is one of the two in my solution. Another one is read from database. Then compare them to see if they are equal. I had a case, they were different. That cased big problem.

Thanks,
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

Any one does BCI ODBC programming there?

Thanks,
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, I do, though primarily wearing my UniVerse hat rather than my DataStage hat.

You can find a well-documented example, a function to execute any DML statement, here
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

Ray,

Oh, Very good documented routine, indeed, thanks very much.

But when I invoke the routine, the error is:

t..Trans (bciExecuteDML): SQL Statement = select count(*) from EDWAPP.T_PARTY_ADDRESS;


t..Trans (bciExecuteDML): SQL Error: SQL State = 37000, DBMS code = -104
[DataStage][SQL Client][ODBC][DataDirect][ODBC DB2 Wire Protocol driver][UDB DB2 for Windows, UNIX, and Linux]ILLEGAL SYMBOL ;; VALID SYMBOLS ARE WAPP.T_PARTY_ADDRESS

You see the SQL statement is "select count(*) from EDWAPP.T_PARTY_ADDRESS;"

Why "ILLEGAL SYMBOL ;; VALID SYMBOLS ARE WAPP.T_PARTY_ADDRESS"

Thanks again,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm asuming it's trying to tell you that the semi-colon at the end of the query is the 'illegal symbol'. Remove it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The database is objecting to EDWAPP.T_PARTY_ADDRESS - the error message is telling you that WAPP.T_PARTY_ADDRESS is a legal identifier.

Please verify that you are using a schema.table combination that is valid.

(I need to add that the routine is working correctly, being able to report this error. 8) )
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Oh, well. Close but no cigar.
-craig

"You can never have too many knives" -- Logan Nine Fingers
olgc
Participant
Posts: 145
Joined: Tue Nov 18, 2003 9:00 am

Post by olgc »

No matter it has ';' at the end or not, and the sql is perfect from any other clients or environments, the error is the same from routine. Sometime this illegel, another run another illegal.
Post Reply