Query/400 String to nummeric

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
7/2/2003 9:28:45 AM
comp.sys.ibm.as400.misc 9109 articles. 13 followers. Post Follow

4 Replies
3254 Views

Similar Articles

[PageSpeed] 59
"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
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
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
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
7/4/2003 3:17:21 PM
Reply:
Similar Artilces:

plpgsql , dynamic queries
Hi, I am having problems in forming a dynamic query that can be used in Execute statements. Problem: I have database fields that are either INT or VARCHAR. Both can have NULL. If I use variables that hold the db field's values ... how do I need to quote them to pass them to the query string. example: _var1 := NULL; _var2 := ''NULL''; or queryStr := ''WHERE name NOTNULL"; queryStr := ''WHERE name ='' || _var2/1 _var3 := ''somename''; quereyStr := ''SET name='' || _var3; I tried...

query: what was this command?
I read in a magazine the other day that there's a simple thing you can type in word that causes it to repeat a word or phrase you put in brackets, as many times as you specify. It was a really simple little command which I memorized..then immediately forgot. Can anyone here suggest what it might have been? Thanks in advance. ...

Mulitple Table Query Help
I'm not sure the follow multiple table query is the right way to do what I need to do although it seems to be working: $php_SQL = "SELECT * ". "FROM basics, personal, photos ". "WHERE basics.member_name = personal.member_name ". "AND basics.member_name = photos.member_name ". "AND basics.account_creation_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)"; I primarily need to return a resultset for all member_names (they are index key and unique) filtered for the last 30 days on the basics.account_crea...

Why isn't this query working in python?
Hi all, I'm trying to run the following query: amember_db = MySQLdb.connect(host="localhost", user="**********", passwd="*****", db="*******") # create a cursor self.amember_cursor = amember_db.cursor() # execute SQL statement sql = """SELECT payment_id FROM amember_payments WHERE member_id=%s AND expire_date > NOW() AND completed=1 AND (product_id >11 AND product_id <21)""", (self.uid) print sql self.amember_cursor.execute(*sql) ...

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

FTP from AS/400 IFS to PC
Hi I have seen different posts for doing FTP to 400 to get and put files. How do I do FTP from AS/400 to PC and sent a file in an IFS directory Thanks in advance Dn Same way you'd do other stuff. Connect to PC using As/400 FTP client. Issue the command namefmt 1 You're now in "IFS mode". then use use put or get and specify the path/filename. ex: namefmt 1 put /tmp/myfile.txt /pc/path/myfile.txt or namefmt 1 cd /pc/path lcd /tmp put myfile.txt D wrote: > Hi > > I have seen different posts for doing FTP to 400 to get and put files. > > How do ...

fmincon query
I am trying to understand how 'fmincon' works for my minimization problem from the printed output. Actually, fmincon prints some output and then exits giving error message. The output is like this : End diagnostic information 9 0.0000000000 2.71580405e-03 0.0000271580 11 0.0027158040 4.56840681e-03 0.0000456828 13 0.0072842109 2.71580405e-03 0.0000271560 9 0.0000000000 2.71580405e-03 0.0027158040 11 0.0027158040 4.56840681e-03 0.0045684056 13 0.0072842109 2.71580405e-03 ...

Problem with a query
Three days I have been fighting with a query that shows a message "Type mismatch". The query is the following: SELECT * FROM "Africa.DBF" UNION ALL SELECT * FROM "Sunny Italy.DBF" I confess I'am working with the BDE and with dBase files. But the strange thing is that the following works perfectly: SELECT * FROM "Africa.DBF" UNION ALL SELECT * FROM "Arabia.DBF" All of the datasets have the same structure. Looking at the dataset content, I can't see anything abnormal. I can't think of anything causing the problem. D...

query browser and administrator for DB2?
Hi, I am new to DB2. I was wondering whether DB2 has a visual client that enables creating, executing, and optimizing SQL queries. Just like the Query Browser for MySQL. Also whether DB2 has a visual administration console that enables you to easily administer your DB2 environment. Just like the Administrator tool for MySQL. Where can I download that? Thanks. Roy "Roy" <royliuk@hotmail.com> wrote in message news:1171496123.437240.62450@q2g2000cwa.googlegroups.com... > Hi, > > I am new to DB2. I was wondering whether DB2 has a visual client that ...

basic question about runtime query parsing
Say I have a c library which implements various database functions and contains relevant data structures. For effeciency, I keep 'records' of a 'table' in a nativ c struct (so 4 'columns' in a table will show up as 4 attributes of a struct). I can understand how this will work if all someone wants to do is do queries. But what is usually done for 'create table' command issued by a user? By that I mean, if someone issues 'create table(x int, y int, z int),' I parse it and figure out I need a struct{int x, int y, int z} (this struct will then be passed...

Querying CPU frequency
Hallo, I want to compute delay/run times using the TSC. For that I need the frequency with which the TSC increases. As much as I understand it's equal to the internal CPU frequency. Therefore on a "2.66 GHz" CPU the TSC will increase its tick with 2.66 GHz frequency. Is there any EASY and GENERIC way to query CPU frequency that will work on all "latest" Intel and AMD CPUs ? With "latest" I'd say the CPUs that were thrown on the market in the last 10 years. I came up with a solution based on channel 0 of the PIT and the TSC. It works an...

query with table alias
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C4C8A5.2E1B8110 Content-Type: text/plain; charset="ISO-8859-1" Hello, I think I have found a query problem when the query has an alias for a table and use alias item and table name. I ilustrate the problem with a simple table and query. prr=# create table foo (c1 int2, c2 int2); CREATE TABLE prr=# insert into foo values (1, 1); INSERT 301891 1 prr=# insert into foo values (2, 2); INSERT 301892 1 prr=#...

Re: Query Help
Wouldn't that return every A.id ? since A.id would be compared to -1, and the wouldnt' be the same. I want: select min(A.id) such that A.charge, B.userid, C.employee_id in ( select A.charge , B.user_id , C.employee_id from A inner join B using (user_id) inner join C using (employee_id) except select X.charge , Y.user_id , Z.employee_id from X inner join Y using (user_id) inner join Z using (employee_id) ) "scott.marlowe" <scott.marlowe@ihs.com> wrote: >On Thu, 23 Oct 2003 yusuf0478@netscape.net wrote: &...

so many "denied recursion for query from" messages for CNAME domain,why?
Hello, all. I have operated bind 8.x for authorative for some domain. the domain is CNAME like this at that dns server www.test.example.com IN CNAME www.xyz.test.example.com. www.xyz.test.example.com. IN A 192.168.151.234 But I can see lots of messages like below(about 3~5% of the total query) Oct 6 19:40:26 ns named[29298]: denied recursion for query from [121.xx.xx.x].33244 for www.test.example.com IN and when I test using dig, above "denied recursion for query from " messages occur only that doesn't answer usin...

spreadsheet string to array or Read Spreadsheetfile into Array
Hi, I am using this attched txt-file (spreadsheet file)&nbsp;to read out the data to an array, but I get only the first column into the 2-D&nbsp;array. All the other columns are not read into it. What do I wrong? Thanks Test.txt: http://forums.ni.com/attachments/ni/170/190879/1/Test.txt Hi, I used space (/s) as delimiter indication but it didn't work either. Yes Thanks, I realized it myself after reading the HELP on the following String Control: "Right-click a string control or indicator and select '\' Codes Display from the shortcut menu to instruct LabVIEW to int...

Query help #4
Hi Friends, I have a question related to sql statement.Hope you guys can give me some suggestions. There are two columns storing the company's name. I want to retrieve those records where first three words are matching. For eg Table A Col1 Liberty Mutual Ins. Group Stud Farm Insurance cos Lehman brothers holdings International paper Delphi Bank of america Table B Col2 Liberty Mutual Ins. Stud farm insurance Lehman brothers Coca-cola Walgreen Bank of america >From the above columns I want to select following rows:- Liberty Mutual Ins. Group Stud...

Query Question #4 #2
I have a table that contains the following: Job Number Contractor Name Bid I would like a query to return the lowest bid and the corresponding contractor for each job number. Can anyone help? I would greatly appreciate it. -- -- Karl A. Homburg Electrical Engineer U.P. Engineers & Architects, Inc. 100 Portage Street, Houghton, MI 49931 PH: (906) 482-4810 FX: (906) 482-9799 SELECT jobnum, contractorname, bid FROM YourTable AS T WHERE bid = (SELECT MIN(bid) FROM YourTable WHERE jobnum = T.jobnum) -- David Portas SQL Server MVP -- ...

String trouble
I am using a function that does a very basic encryption (rotation based) of data. Data is a string which may contain a..z,A..Z,0..9,[],(),|,{}"', length limited to 255 chars. The problem I have is the following: Let's say my $string is 'This is a string' At a given moment encrypt ($string) yields '6noq4oq4"q6{o]3' as a result. When I decrypt that I get my original string back. But if I send the encrypted string in a POST var, this is what I get: '6noq4oq4\"q6{o]3'; So the " gets escaped and decrypt produces undesired results. I don't ...

How to Avoid or Trap a Syntax Query Error
I can't seem to find a workaround of Query Syntax Error. Actually, the query performs just fine, except when the last record on a related subform is deleted, then it generates a Runtime Error 3075 - Syntax error (missing operator) in query expression 'IDRef = '-- of course, because there are no more records left with the same IDRef number. And Set rst = dbs.OpenRecordset(strSQL) is highlighted in the Function module. The Function module below pulls the IDRef numbers and amounts from a Totals Query. There is sfrmAddCost subform on a frmMain and when adding or editing the subform re...

Query PACS for dose info
Hi all, How can I query my GE PACS for dose information. I know I can Q/R one image at a time and examine the dose tag but really I would like to query en mass - for example the dose in CT images with procedure description = xyz Thanks, Devon > How can I query my GE PACS for dose information. I know I can Q/R one > image at a time and examine the dose tag but really I would like to > query en mass - for example the dose in CT images with procedure > description = xyz if you are lucky you may have success with relational-queries if the pacs supoprts this and...

Relationships as Queries
So, I posted a semi complicated request yesterday and didn't get a response, so I decided to simplify my problem, and realized there must be a critical thing I am missing here. Can someone tell me where my logic has gone wrong here? These are my tables, fields, and records. Table: Colors Fields: Color ; Type Records: (Color) ; (Type) Red ; Warm Orange ; Warm Yellow ; Warm Green ; Cold Blue ; Cold Purple ; Cold Table: ColorTypes Fields: Warm ; Cold (both global, with text values as advertised by the name) I create two table occurences of Colors, one called WarmColors and one called C...

Parameter Query Prompts
I have a paramter query that wants either of 2 date fields in a table to be before a certain date. Select * from tblExample where Date1 < [dtCutoff] or Date2 < [dtCutoff] When I open this query, it prompts me twice for dtCutoff. I've verified I'm using the same spelling and capitalization. Is there a way to make it only prompt once? On Sun, 23 Jan 2005 17:06:46 GMT, HateSpam wrote: > I have a paramter query that wants either of 2 date fields in a table to be before a certain date. > > Select * from tblExample where Date1 < [dtCutoff] or Date2 < [dtCutoff] &...

xpath query query
Hi Folks, I wonder if anyone can help me with the following (perhaps trivial) problem: <xml> <node name="a" type="a"/> <node name="b" type=""/> <node name="c"/> <node name="d" type="b"/> </xml> we're using a command line xpath script to pluck values from configuration files, e.g. to get the list of node names: xpath test.xml '/xml/node/@name' Returns the list of names in the file, easy. a b c d Because of the way our other command line tools work, we're r...

URL.openStream in an applet causes NBNS name query
Hi, within an applet I do an url.openStream() and that works, i mean I get the correct response. But immediately after calling the method a NBNS name query is sent to the remote server. That seems to be a NetBIOS request at post 137 (according to ethereal) , but I don't want to do anything with netbios or something. Because the remote port 137 is closed (and that is ok) the request is refused (with port unreachable) after the timout and the client tries it about 10 times. After that i get the response of my original request. Although my request with openStream() works it takes about 10 s...

std::string out of a BSTR
Hi, How can I get an std::string (not std::wstring) out of a BSTR? I need to convert a BSTR to single byte encoding. Thanks You can convert a BSTR to a char* with WideCharToMultiByte and initialize the std::string from there. Just keep in mind that in many environments (including VB) a NULL BSTR and an zero length BSTR are equivalent. If you don't mind using the COM "helpers" in VC, you can also use _bstr_t which has a char* operator that does the conversion for you (typed in email, so not checked): std::string bstr2std(_bstr_t b) { char* c = b; if...