Hash File open/read/update in the server routine
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 9
- Joined: Tue Dec 09, 2003 2:20 pm
Hash File open/read/update in the server routine
I'm trying to write a server routine. in that i have to open a hash file which has like 6 columns. The key column is "NAME", Based on the input argument( Which is "NAME") i have to go to that perticular record in the hash file and update the other fields.
i'm trying to open the hash file using OPENPATH but it is picking up the ON ERROR/ ELSE statements. Also have problem in parsing the record, record has like varchar, numeric and varchar types.
Any help would be really appreciated...
Thanx,
San
i'm trying to open the hash file using OPENPATH but it is picking up the ON ERROR/ ELSE statements. Also have problem in parsing the record, record has like varchar, numeric and varchar types.
Any help would be really appreciated...
Thanx,
San
Please paste your logic and identify it with the code button. Please also paste the fully qualified path and filename.
Your problem could anything from bad logic, unqualified path to file, permissions in the directory, etc.
Data type is irrelevant in hash files. There is no difference between a varchar column and a numeric column, as there is no inherent data typing in hash files.
Please paste the logic you are trying to use to parse the hash file record content.
Your problem could anything from bad logic, unqualified path to file, permissions in the directory, etc.
Data type is irrelevant in hash files. There is no difference between a varchar column and a numeric column, as there is no inherent data typing in hash files.
Please paste the logic you are trying to use to parse the hash file record content.
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
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
-
- Participant
- Posts: 9
- Joined: Tue Dec 09, 2003 2:20 pm
Code: Select all
OPENPATH '/open/devel/work/hash' to f.infile
ELSE ABORT
QUIT=@FALSE
Loop
read RCD from f.infile else QUIT=@TRUE
UNTIL QUIT DO
FileName = RCD[1,20]
IF(FileName = InputArg )
THEN RCD[21]=0 RCD[22] = 0
QUIT=@True
REPEAT
ErrorCode = 0
Okay, let's pretend your hash file is named FRED.
Code: Select all
OPENPATH '/wherever/FRED' TO F.FRED Else
Call DSLogFatal("Unable to open FRED", "YourFunction")
End
SELECT F.FRED
Done = @FALSE
Loop
READNEXT KEY Else Done = @TRUE
Until Done Do
Read FredRow From F.FRED,KEY Then
* Do something
End
Repeat
Call DSLogInfo("All Done", "YourFunction")
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
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
Your internal logic makes no sense. There's no WRITE statement, so you are not writing back any data. Furthermore, you have no SELECT statement, so you are not putting any data into a selection list (queue). You also are not reading the content of the file, because you do not specify the READ command correctly. You basically are just doing substring manipulation, as opposed to column checking ( brackets are not array delimiter tokens).
Could you please describe the functional requirement as well as the data.
Could you please describe the functional requirement as well as the data.
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
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
-
- Participant
- Posts: 9
- Joined: Tue Dec 09, 2003 2:20 pm
Sandy, a hash file is a binary file. Every row has a key that is unique, so you can call it the primary key. That key is ran through an algorithm to determine the placement of the row in the file. You need to know the key in order to find the row again in the file.
See here for a more thorough explanation of hash files:
There are 2 and only 2 ways to get a row out of a hash file. Either you know the key and can directly retrieve the row; or you dump the contents of the hash file. In the code sample I gave you, I setup a loop to cycle through the hash file. The BASIC statement
put into an active queue the list of all primary keys in the hash file. The READNEXT statement fetches the next key from that list. The READ statement retrieves the row from the hash file. The syntax
uses the KEY variable and gets the row located in that file pointer (F.FRED).
If you know the primary key, you do not need to setup a loop. You simply directly read the row! Ex:
"your key value" can be a literal as in this example, or a variable.
Again, please state your functional requirements. It is difficult to help people when we don't know what you need to do, we only see what you want to do. We have yet to address updating your row. We probably will tell you not to do what you're doing once we know what it is that needs to be done. This type of logic is exactly why the tool has a graphical metaphor, with stages designed to do this easily, without any knowledge of the underlying technology.
See here for a more thorough explanation of hash files:
Code: Select all
http://www.dsxchange.com/viewtopic.php?t=85364
Code: Select all
SELECT F.FRED
Code: Select all
Read FredRow From F.FRED,KEY Then
If you know the primary key, you do not need to setup a loop. You simply directly read the row! Ex:
Code: Select all
Read FredRow From F.FRED,"your key value" Then
Do This
End Else
Do that
End
Again, please state your functional requirements. It is difficult to help people when we don't know what you need to do, we only see what you want to do. We have yet to address updating your row. We probably will tell you not to do what you're doing once we know what it is that needs to be done. This type of logic is exactly why the tool has a graphical metaphor, with stages designed to do this easily, without any knowledge of the underlying technology.
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
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
-
- Participant
- Posts: 9
- Joined: Tue Dec 09, 2003 2:20 pm
The requirement is like this. we have a hash file that is being shared by many jobs. It has information of all the web sites that the corporation track. This hash file is used as a reference further in the jobs. At any given time the hash file has the most recent information that's being processed for that perticular site. All the jobs are run in a batch and if any of the sites information is not available, it sends the information in the hash file which is wrong. if we are running the job for that particular site before we start processing, initialise the fields and then continue.
Thank you very much for all the help.
Thank you very much for all the help.
Okay, but why are you writing a BASIC subroutine to handle modification of data in this file? Why can't a regular old Server GUI metaphor transformation job do the work for you?
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
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
-
- Participant
- Posts: 9
- Joined: Tue Dec 09, 2003 2:20 pm
If you state your functional requirements, I'm sure we could tell you how to do it easily with a GUI job.
The Inner Circle members are here to help in these types of situations. Rather than teach BASIC file i/o, we'd rather people concentrate on using the tool. I'm pretty sure that what you're doing could/should be handled via a job design.
The Inner Circle members are here to help in these types of situations. Rather than teach BASIC file i/o, we'd rather people concentrate on using the tool. I'm pretty sure that what you're doing could/should be handled via a job design.
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
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