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 9050 articles. 12 followers. Post

4 Replies
2425 Views

Similar Articles

[PageSpeed] 53


  • 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...

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 ...

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 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...

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 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...

Query 400/SQL 400 Contract Position Available in NJ Immediately! #2
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...

Hide Query String
Is there a way to prevent query string showing in the address bar with out using hidden fields with javascript? Thanks in advance. Sachin wrote: > Is there a way to prevent query string showing in the address bar with > out using hidden fields with javascript? [...] No, use POST instead of GET. PointedEars On 2005-12-12, Sachin <mahalwarawa@gmail.com> wrote: > Is there a way to prevent query string showing in the address bar with > out using hidden fields with javascript? Thanks in advance. change the from from's method from get to post. probably easier ti do in...

String
Hi, Here is a small program that is wrtten to simply use substr. When the second parameter in substr (length of the string to be extracted) is lesser than 0, the output is the entire string (I'm using gcc 4.1.0) My questions are : 1. Is this behaviour correct ? ( Or should this case be an exception?) 2. If it is correct, what is the idea behind this behaviour ? using namespace std; #include <iostream> #include <string> int main() { string s("This is a test string"); cout << s.substr(0,-1) << endl; return 0; } Thanks, Sumedha Swa...

Query String #2
OK I have done this several times before, but now cannot see the wood for the trees. I want to search the database table "news" for all items with the field "active" set to "Yes", and then output the field "title" for each returned result. The database connection is OK. I get an error message Fatal error: Call to undefined function mysql_fetch_objects() What am I doing wrong... Its been a long day, sorry.. <?php $query = ("SELECT title FROM news WHERE active='Yes' "); $result = mysql_query($query) or die ('Error in query: $qu...

concatenate strings in a query
Sometimes I have to do reports that take a table like that (silly example): CREATE TABLE SILLY_EXAMPLE ( KEY INTEGER, DATA VARCHAR2(4000) ) ; INSERT INTO SILLY_EXAMPLE VALUES (1,'AAA'); INSERT INTO SILLY_EXAMPLE VALUES (1,'BBB'); INSERT INTO SILLY_EXAMPLE VALUES (1,'CCC'); INSERT INTO SILLY_EXAMPLE VALUES (2,'XXX'); INSERT INTO SILLY_EXAMPLE VALUES (2,'YYY'); and give an output like that: Key Data --- -------------- 1 AAA,BBB,CCC 2 XXX,YYY I always solved using PL/SQL and a for..loop cursor with some logic inside the loop. I'm wonde...

doing query for an array of strings
Hi! What I would like to do is this: SELECT * FROM 'tableName' WHERE ColumnName is in ARRAY and ARRAY has the form of a set or array, like {"foo", "bar", "raz", "ma", "taz"}. I can't do it like "...WHERE ColumnName='foo' OR ColumnName='BAR' OR ..." because I don't know those strings and how many of them are in the set before. -- Dan On Fri, 18 Jan 2008 18:52:10 +0100, yataaa wrote: > Hi! > > What I would like to do is this: > SELECT * FROM 'tableName' WHERE ColumnName is in ARRA...

aliasing query strings
Fellow developers, I Am trying to find a way to alias my query strings so I can optimize my site for search engines. Currently my site is doing well in search results with my static content, but since I've switched to dynamic content (same material) the engines don't fine my stuff, not even the build in search that comes from my host. so simply, my question is, how can I change: www.anysite.com/details.php?cat=food to www.anysite.com/food.htm My site depends heavily on search engine traffic, so any help would be greatly appreciated. "Russel H" <r@h.noway> wr...

parsing query strings
yes, it would generally be better to just let CGI do it; but is there a way to let CGI parse arbitrary strings and stuff them into the param() hash, or will I have to write a wrapper? -- "Six by nine. Forty two." "That's it. That's all there is." "I always thought something was fundamentally wrong with the universe" Quoth sreservoir <sreservoir@gmail.com>: > yes, it would generally be better to just let CGI do it; but is there a > way to let CGI parse arbitrary strings and stuff them into the param() > hash, or wil...

# Sign in the Query String
Hi All, I am passing a query string to the browser from my servlet something like this res.sendRedirect("CC.jsp?FLAG=YES&ADDR1=#3502 North PL&CITY=NY"); My jsp page on IE 5.50 interprets these values correctly and I get the desired attribute. But one of my clients who also has the same version of IE the JSP page is not able to see the values after FLAG=YES it ADDR1=#3502 North PL , CITY=NY are not received as Request parameters by the page. Let me know if anything specific to the browsers settings. Also I think to be on the safe side I need to encode the URL. But witho...

Query To String Converter
I thought I remember a utility that lets you cut a Select statement from a query and it converts it to be used in VB. Takes the work out of making sure the syntax is correct. Anyone know of such a utility? "BerkshireGuy" <berkshireguy2005-commerical@yahoo.com> wrote in news:1167664757.152231.18330@h40g2000cwb.googlegroups.com: > I thought I remember a utility that lets you cut a Select statement > from a query and it converts it to be used in VB. Takes the work out > of making sure the syntax is correct. > > Anyone know of such a utility? The SQL created...