Insert into Hash table from a Routine

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
cecilia
Participant
Posts: 33
Joined: Thu Jan 15, 2004 9:55 am
Location: Argentina
Contact:

Insert into Hash table from a Routine

Post by cecilia »

Hi
Does everybody have an example of a DS routine that create and insert data into a hash table?
thanks, Cecilia
raju_chvr
Premium Member
Premium Member
Posts: 165
Joined: Sat Sep 27, 2003 9:19 am
Location: USA

Re: Insert into Hash table from a Routine

Post by raju_chvr »

viewtopic.php?t=86342&highlight=write+cache+defer

take a look at the above code. Ray has posted some code for creating HASH FILE from DS BASIC.

GOOD Luck !!
cecilia
Participant
Posts: 33
Joined: Thu Jan 15, 2004 9:55 am
Location: Argentina
Contact:

Re: Insert into Hash table from a Routine

Post by cecilia »

Thanks. I looked at that code yesterday, but I'm not sure if I have to use WRITE statement in order to insert data as in any table, or I have to take some considerations for hash tables.
I can handle it as any table?
I looked at UtiliyHashLookup routine for getting some ideas :)
Regards, Cecilia
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You can create the hashed file as indicated, or you can use a CREATE TABLE command called via DSExecute. For example:

Code: Select all

Stmt = "CREATE TABLE MyTable ("
Stmt := "   key INTEGER NOT NULL DEFAULT NEXT AVAILABLE,"
Stmt := "   col1 VARCHAR, "
Stmt := "   PRIMARY KEY (key));"
Call DSExecute("UV", Stmt, Output, ReturnCode)
... and, of course, check (via ReturnCode) that it succeeded! 8)

You can use the WRITE statement, which is a destructive overwrite of the record whose key value you provide in the WRITE statement.

You can also use a regular INSERT command, called via DSExecute subroutine. This may be more comfortable, though the string manipulation you need (similar to that for the earlier example) may be initially off-putting. Remember, too, that "UniVerse" commands tend to be case sensitive.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cecilia
Participant
Posts: 33
Joined: Thu Jan 15, 2004 9:55 am
Location: Argentina
Contact:

Post by cecilia »

Thanks Ray
I still have a question. The creation worked fine when I logged as DataStage administrator, but in other case DataStage/SQL: "FOCUS\cmachado" is not an SQL user is the return message.
How could I sign the user to DSExecute or what permission (less than administrator, of course) I have to give to cmachado in other to be able of create the table?
Thanks again, Cecilia
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

As the Administrator (a user with DBA privilege), either from the client window in Administrator client or via a telnet session to the project:

Code: Select all

GRANT CONNECT TO cmachado;
GRANT SELECT,INSERT,UPDATE,DELETE ON tablename TO cmachado;

GRANT CONNECT TO FOCUS\cmachado;
GRANT SELECT,INSERT,UPDATE,DELETE ON tablename TO FOCUS\cmachado;
 
You may be able to get by without granting the table privileges. Try just the grant of CONNECT privilege first; that may be sufficient.
What I'm thinking here is that the default privileges on a UV table are all privileges to all users, unless specific privileges are granted.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply