Page 1 of 1

Insert into Hash table from a Routine

Posted: Fri Jan 16, 2004 8:54 am
by cecilia
Hi
Does everybody have an example of a DS routine that create and insert data into a hash table?
thanks, Cecilia

Re: Insert into Hash table from a Routine

Posted: Fri Jan 16, 2004 9:34 am
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 !!

Re: Insert into Hash table from a Routine

Posted: Fri Jan 16, 2004 10:09 am
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

Posted: Fri Jan 16, 2004 3:37 pm
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.

Posted: Wed Jan 21, 2004 9:22 am
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

Posted: Wed Jan 21, 2004 3:57 pm
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.