Query/400 String to nummeric

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hi!

I've got a problem converting a string value in a nummeric value:
converting nummerin ino string is not a problem
field1    digits(field2)

does anybody know the other way?

Thanks 
Michael
0
Reply jovicevic_m (1) 7/2/2003 9:28:45 AM

See related articles to this posting


"Michael" <jovicevic_m@dsdohmen.de> a �crit dans le message de news: ca50984b.0307020128.14ae06b7@posting.google.com...
> Hi!
>
> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
>
> does anybody know the other way?
>
> Thanks
> Michael

Maybe you can find a workaround in the embedded SQL statements of a Qmqry instead.
Use RTVQMQRY and CRTQMQRY commands and allow information from your QRYDFN.
HTH
Mercury


0
Reply nospam.carpediemps (83) 7/2/2003 1:13:12 PM

If you're using SQL maybe something like this would help:
SELECT field1, CAST(field2 as CHAR(10)) AS charfield2 FROM mytable

> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
0
Reply budimlic (202) 7/2/2003 2:55:58 PM

Michael wrote:
> I've got a problem converting a string value in a nummeric value:
> converting nummerin ino string is not a problem
> field1    digits(field2)
>
> does anybody know the other way?

http://mcpressonline.com/mc?14@44.6Tfxazekbxg.6@.f00945e/4

Bill


0
Reply billzbubbXXX (18) 7/2/2003 10:08:59 PM

"Bill Z Bubb" <billzbubbXXX@netscape.net> wrote in message news:<bdvl4v$11ktq1$1@ID-91878.news.dfncis.de>...
> Michael wrote:
> > I've got a problem converting a string value in a nummeric value:
> > converting nummerin ino string is not a problem
> > field1    digits(field2)
> >
> > does anybody know the other way?
> 
> http://mcpressonline.com/mc?14@44.6Tfxazekbxg.6@.f00945e/4
> 
> Bill

CONVERTING CHARACTER DATA TO NUMERIC IN QUERY/400
Query/400 does not provide a native method for converting character data to 
numeric, but with the following hack, the conversion is possible. I have a 
character field (four digits) that's used for generic purposes in a 
particular database file. Although the field's format is character, the 
field sometimes represents numeric data. To perform math operations on such 
data in Query, you must first convert the field to numeric. By using the 
MICROSECOND keyword in the Define Result Fields section of Query, you can 
convert the character data to a numeric field for later use in calculations.

For example, create a field called TIMESTAMP using Query's Define Result 
Fields panel, specifying 

'1988-12-25-17.30.00.00' || CHARFIELD4

in the panel's Expression column. The field CHARFIELD4 in this example 
represents a four-digit character field containing the characters 0 (zero) 
through 9 (nine).

Next, use the MICROSECOND keyword on the TIMESTAMP field to create a numeric 
copy of CHARFIELD4's character data. Here's what the Define Result Fields 
panel will look like:

Field     Expression                           Column Heading Len Dec
TIMESTAMP '1988-12-25-17.30.00.00' || CHARFIELD4               26
NUMERIC6  MICROSECOND(TIMESTAMP)                                6   0

The MICROSECOND keyword takes the six rightmost digits in the TIMESTAMP 
field and converts them to numeric. In the example, the character field is 
only four digits long, so 00 is concatenated with the character field to 
create a valid timestamp with six digits of milliseconds.

If a given character field is larger than six digits, you'll need to break 
down the above process into multiple steps and perform a math operation on 
the individual numeric components to combine them.
0
Reply mariusz.andrzejczak (1) 7/4/2003 3:17:21 PM
comp.sys.ibm.as400.misc 9055 articles. 12 followers. Post

4 Replies
2545 Views

Similar Articles

[PageSpeed] 21


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

how to convert url with query string to url without query string
Hi All, I would appreciate any help in converting an url with query string (http://mywebsite/cgi-bin/web_case_mgt.exe? CASE_KEY=00000000630520110213&STYPE=DISPLAY) to one that does not contain any parameters (http://mywebsite/cgi-bin/web_case_mgt.exe). My application is a cgi application with the server side generating dynamic html pages (using C++). On the server side I am replacing the current web page (web_new_case.exe) with a new one by generating the following JavaScript code: <form> <Script language="JavaScript" type="text/javascript"> location.replac...

CGI
Hi, I'm using the CGI::upload_hook functionality and would like to get a parameter value passed in via POST *before* calling the upload hook to process files. i.e. Something like this: my $query = new CGI();<br/> $query->param("myParam");<br/> $query->new(\&hook); Now according to the CGI docs this doesn't look possible: "If using the function-oriented interface, call the CGI::upload_hook() method before calling param() or any other CGI functions: CGI::upload_hook(\&hook,$data);" ....and indeed my exprience bears this out - If I try an...

Query re: apache and URL query strings
Our website uses the standard query string arrangement: something.php?this=1&that=2 We're in the process of moving over to an alternate arrangment utilizing apache's lookback function. something/999/00/456 My question is: If the second example is more search engine friendly why don't all sites running apache use this method? Is there a performance hit that I missed in my reading or some security issue related to the second example? kb I don't think there's any performance issues except with the fact that you have to parse your "query" into your own vari...

string A = string A + string B (adding strings)
Hi, how can I perform the operation of adding string to string. string_A = string_A + string_B In particular I have to do: handles.hsl_current_string{1}(hsl_current_value{1}, :) = [handles.hsl_current_string{1}(hsl_current_value{1}, :), ' ' z1_value, ' ' z2_value, ' ' z_value] where: string_A = handles.hsl_current_string{1}(hsl_current_value{1}, :) string_B = ' ' z1_value, ' ' z2_value, ' ' z_value I am dealing with GUI, string_A is the value of the listbox, and string_B is the value I would like to add to the string_B and rep...

sql query problem: joining on a string within a string
Hi Everyone, I have a problem that I need help with. I have 2 tables, table A & B. Table A has a field called familyid and table B, a field called clientid. Another person here at my office, created this field 'familyid' by truncating the clientid field (so we hope, she's on maternity leave right now and can't be reached). The familyid is contained within the clientid as shown below, and can range anywhere from 3-5 characters (clientid is fixed at 8 characters). Both are character variables. Eg. Clientid 10003888 Familyid 0388 I just need a list of clientids that contain ...

Strings, Strings and Damned Strings
I have an int variable (always <100) that I want to convert to a two character string, e.g. if myint = 1, mystr = "01" if myint = 81, mystr = "81" At the moment I can't figure out how to do this cleanly. Then I wish to push a bunch of these strings into an array, for example: typedef char LABEL[3]; LABEL mystrArray[100]; But having read a couple of tutorials I am still no clearer on the best way to do an "array of strings" in this situation, nor how to do it. Any help much appreciated! cheers, Ben Ben wrote: > I have an int variable (always &...

Strings, STRINGS, and crazy strings!
Oh my head... Someone, please bail this choking programmer out of a fix. Here's what I got. 1. A multi-line Textbox control. 2. Enter 3 lines of text (each line separated by hitting the Enter key). 3. In my routine, I transfer the Textbox.text into a string variable, say sString. 4. Then I parse this string with my Parsestring routine that places each individual string into an array called sWords() and the string count into lCount. 5. Next is a For/Next loop to print each string found in sWords() at the same starting point on my Picturebox control (the textbox is in this conta...

string.fine(string+string...
Hi after reading the docs, I was hoping this would work, but I can't find out why. string a = "I "; string b = "am"; int ego; if(sentence.find((a+b).c_str(),0)!= string::npos) ego++; from the docs **************** size_type find( const string& str, size_type index ); size_type find( const char* str, size_type index ); size_type find( const char* str, size_type index, size_type length ); size_type find( char ch, size_type index ); thanks Gary Wessle <phddas@yahoo.com> writes: > Hi > > after reading the docs, I was hoping this would work, ...

String[] to String
/* I am writing this class to see the output of:args.toString();I want to see if the toString() method on the String[] will convertthe array contents into one string or it will write out it's typename,i.e. the <code>Class</code> class' name.As observed, the output is[java.lang.String@1693e2;which looks like the array's underlying type's name and the startingmemory address.*/public class Ats /*implying Array To String */{ public static void main(String[] args) { if ( args.length == 0 ) System.out.println("Usage: ats arg1 [arg2 [arg3...]]"); else Syste...

when string is not a string
Curious javascript sample. Consider the following code: var s = "asd" var f = function() { return typeof(this) } An expression typeof(s) returns true (as it is expected), but f.call(s) returns false! To make matters worse consider the following snippet: var s = "asd" var f = function() { return this instanceof String } An expression f.call(s) returns true, but (s instanceof String) returns false! The question is why call transforms this to an object? Is it made for unification, e.g. to make this iterable using 'for (var i in this)' loop?...

Query string
Hi at all, How can I do to pass into a frame the query string? Infact I need to use the query string into a frame. Regards Peter On Tue, 05 Oct 2004 09:01:12 GMT, Peter wrote: > How can I do to pass into a frame the query string? I suspect the following eaxample by Richard Cornford will work with or without frames.. <http://google.com/groups?selm=cbsbgk%24m09%241%24830fa795%40news.demon.co.uk> -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensesc...

String query
I'm trying to compare two fields in a table. If the whole of the first field is found somewhere within the second field, I need to output the second field into a third field.. e.g. Field1 = abcd Field2 = xyzabcdefg Since Field1 is found within Field2, Field3 =xyzabcdefg I 'm able to do this if the wholecontents of Field1 exactly matches the whole contents of Field2, viz - Field3: IIF([Field1] = [Field2],[Field2],"") However, I can't get this expression to recognise when Field1 matches only part of Field2. Regards Bernadette [Field3] =IIf(Instr([Field2],[Field1...

String or string
I am doing something where I do=20 If "force" || "spells" Puts "blah" When I use it it gives a warning about comparing strings, what's happening a= nd how do I fix it? Scratch.mit.edu. Go there! -gbear605= It doesn't seem to mind if those are pre-assigned ... ruby-1.9.2-p0 > if "force" || "spells" ruby-1.9.2-p0 ?> puts "blah" ruby-1.9.2-p0 ?> end (irb):3: warning: string literal in condition (irb):3: warning: string literal in condition blah => nil ruby-1.9.2-p0 > f = "forc...

string of strings...
I got an array of id's : ids = [22443, 22468, 22371, 22218, 22472, 22377, 22245] I would like to get a string of strings (to be used in SQL WHERE..IN clause " '22443' , ' 22468' , ' 22371' , ' 22218' , '22472' , '22377' , '22245' " If a use ids.join(','), I get "22443,22468,22371,22218,22472,22377,22245" which is obviously not useful for SQL.... is there any shorcuts or should I concatenate each element ? thanks joss On 12/19/06, Josselin <josselin@wanadoo.fr> wrote: > I got an array...

string query
Hi, I've been experimenting further to understand about ordering strings. I had changed the code which tested ordered a list of char ( which worked ) to string but it's not giving the results I was expected. I was expecting to have the strings in an increasing order. Now, I'm getting confused and would appreciate if someone can explain why I'm getting these results is greatly appreciated. Am I going about this the correct way ? struct testRec { char name[5]; struct testRec *nextrec; }; typedef struct testRec records; typedef records *recordptr; void addName(recordptr ...

Query String
How do you put the value of a form field into the query string. I have a select field named title on a submission form. I'd like the selected value to be put on the Form line echo "<form name='form1' method='post' action='admin/edit.php?selectfield=what goes here? '>"; thanks for looking. function load() { require_once("../login.php"); login(); mysql_select_db("db"); $options = "select id from table order by id"; $optres = mysql_query($options); $opt_results = mysql_num_rows($optres); echo &quo...

string + string
Hi any idea why I am getting something like main.cpp:177: error: invalid operands of types ‘const char [11]’ and ‘const char [8]’ to binary ‘operator+’ when trying to compile something like int main(int argc, char* argv[]) { string a = ".........." + "......."; cout << a << endl; } how can I solve this, I have few lines and use + to concatenate them together. thanks Gary Wessle wrote: > Hi > > any idea why I am getting something like > > > main.cpp:177: error: invalid operands of types 'const char [11]' and 'const ch...

Re: sql query problem: joining on a string within a string
Hi Neerav, The "cartesian not optimized" is not an error, it is just a NOTE when you join tables with the comma. It is not signifying that anything is wrong. Your code actually is fine syntactically. However, using the CONTAINS could potentially generate incorrect matches. I would suggest either pre-prep'ing a temporary column if speed is essential or just changing to use the SUBSTR to get exact matches. e.g. proc sql ; create table aaa as select a.familyid, b.clientid from pro as a, client as b where substr(b.clientid,3,5) eq a.familyid; quit; One more note, is that the ca...

Query in AS 400
Hi! I am trying to accomplish something in a query on the AS400. I have two fields: LNAME which is the last name FNAME which is the first name how do i create these two as one is LNAME is SMITH and FNAME is BOB I would like to create it as SMITH, BOB I used the || in define views and entered the following: LNAME || '," || FNAME but I get SMITH ,BOB It is taking into consideration all of the spaces for the field size... how do I over come this. Any help would be greatly appreciated. On Mar 31, 8:17 am, lcollin...@hotmail.com wrote: > Hi! > > I am t...

Query/400
Does anyone know how to convert characters to numbers in Query/400?!? Specifically, taking a character date field and converting it to a numeric date field. Any help would be appreciated. Thanks in advance. DN. DannyN wrote: > Does anyone know how to convert characters to numbers in Query/400?!? > Specifically, taking a character date field and converting it to a > numeric date field. Any help would be appreciated. Thanks in advance. > DN. > Firstly you may need to re-arrange the field to match your system date format. In query use F17 (I think - not near a server atm) in de...

Query Query
I'm new to Access (and databases in general) and have the following problem.... TABLE_A is basically just a list of events occurring on a system. It has fields; "EVENT_ID" (auto number), "EVENT_TIME", "EVENT_DESCRIPTION". TABLE_B is a list of activities that are undertaken in reaction to the events of TABLE_A. It has fields; "ACTIVITY_ID" (auto number) "ACTIVITY_TIME", "ACTIVITY_DESCRIPTION", "SOURCE_EVENT". "EVENT_ID" in TABLE_A is linked with "SOURCE_EVENT" in TABLE_B, allowing me to build a qu...

Query 400/SQL 400 Contract Position Available in NJ Immediately!
I have the following position available immediately & I wanted to see if you or anyone you know of might be interested. Please let me know what you think! JOB DESCRIPTION: Strong SQL Query, Cobol, fluent English both verbal and written, tech design skills, MS Office tools, production supt on call reqd. Preferred: iSeries/AS400, DataStage, SQL (create, insert, update), CL, DDS, data warehousing, data modeling, extract/ transformation/ load, lifecycle dev, requirements dev, Analysis and Documentation. Nice to have: RPG, Crystal Reports, financial industry experience, job scheduler. Dura...

Re: sql query problem: joining on a string within a string #2
Neerav did not indicate how big his tables are. That is critical. If the orders of magnitude are both in the thousands, the cartesian size will be in the tens of millions, and may be tolerable. Then Neerav can use the nice, concise code he has. If the scale is much larger, some Plan B is necessary. It appears from later posts that Mark's code is inadequate because the CLIENTID substrings to be matched can vary in length and position. However, there are only 15 possibilities (3 characters starting in 1 through 6, 4 characters starting in 1 through 5, five characters starting in 1 through 4...

Re: sql query problem: joining on a string within a string #3
Neerav, For fast and efficient, I think, you have the problem reversed. If you can trust the birth dates they form buckets for a fast and efficient match because that matching can be done with a sort. Then the search for matching parts of ID's need only be conducted within buckets, hence the quantity of pairs to look at is relatively small compared to the Cartesian product of the files. As mark explains, this is the meaning of the euphuism "cannot be optimized". It really means "Can you help with a better strategy?" I would look at >proc sql ; >create ta...