Insert commas in a string
Hello world
I have a problem with a function that inserts commas in a string... and then I want a textfield to account for this string. The function is as follows:
var count:Number = 0; var q2_Final:String; var tempString:String = ""; var q2_UserInput:String; var q2_preCalc:Number; var q2_preCalc = 12345678*1000; q2_UserInput = String(q2_preCalc); for (var i:Number = q2_UserInput.length-1; i>=0; i--) { count++; tempString+=q2_UserInput.charAt(i); if ((count%3 == 0) && (i - 1 >= 0)) { tempString+=","; } } for (var k:Number = tempString.length; k>=0; k--) { q2_Final+= tempString.charAt(k); } q2TextAns.text="US$ "+ q2_Final;
The text which is showning the text field 'q2TextAns' when I run program is ' US$ null12, 345, 678, 000 ".
Why I get the words "null" in front of my number? No idea on how to NOT to show the words "null".
Thank you for your time,
Rafa.
because you are not initializing q2_Final. use:
var count:Number = 0; var q2_Final:String=""; var tempString:String = ""; var q2_UserInput:String; var q2_preCalc:Number; var q2_preCalc = 12345678*1000; q2_UserInput = String(q2_preCalc); for (var i:Number = q2_UserInput.length-1; i>=0; i--) { count++; tempString+=q2_UserInput.charAt(i); if ((count%3 == 0) && (i - 1 >= 0)) { tempString+=","; } } for (var k:Number = tempString.length; k>=0; k--) { q2_Final+= tempString.charAt(k); } q2TextAns.text="US$ "+ q2_Final;
Tags: Adobe Animate
Similar Questions
-
How can I insert commas in a string to a number?
Here's the process I use to
generates a numeric string in an Acrobat form:
var A = this.getField("fieldname").value * 1000000000
var B = this.getField("fieldname").value * 1000000000
var C = this.getField("fieldname").value * 1000000000
var D = this.getField("fieldname").value * 1000000000
var E = this.getField("fieldname").value * 1000000000
var F = this.getField("fieldname").value * 1000000
var G = this.getField("fieldname").value * 1000000
var H = this.getField("fieldname").value * 1000000
var I = this.getField("fieldname").value * 1000000
var J = this.getField("fieldname").value * 1000000
var K = this.getField("fieldname").value * 1000
var L = this.getField("fieldname").value * 1000
var M = this.getField("fieldname").value * 1000
var N = this.getField("fieldname").value * 1000
var O = this.getField("fieldname").value * 1000
var str = A - B - C - D - E + F - G - H - I - J + K - L - M - N - OFor example, the resulting string is: How can I insert commas so the chain will read from 237036054000: 237,036,054,000?
The number string is not always the same length so I need to add commas to the right. For example, the number may be: 7,234,887,000 or 124,345,000. The only constant is that the numbers will end in "000" as there are no hundreds in the sequence, I work with.
I have to add commas to the strobila, so I can break the string up in the same type of components that I started with. I already part, but I need to insert commas as a separator for the second half of work.
Thanks much for any help you can offer.
Steve
What is a custom calculation script? If so, do you have to checked to make sure that the field calculation order is correct?
-
Replacement of several commas in a string
Hello
Hello
I have a string similar to the following.
1, Accenture, EDS, Sun, training partner
2, United States
3.Canada,
I want to have the chain as follows as a result of the query.
1 Accenture, EDS, Sun, workout partner
2. the United States
3 Canada
Help is appreciated.
_PS
Here is the script to create the table and insert the script.
create table time
(val varchar2 (1000));
insert into time values (' ', Accenture, ed., Sun, workout partner ");
insert into time values ('United States,');
insert into time values ("Canada");
insert into time values (', Canada ');
commit;Please provide your db version to see if the solutions of regexp_ apply too ;)
-
Table 2D cluster table how insert table 2d of strings in an array of cluster?
I have a cluster with 4 channel 3 elements of the string constants and 1 is a list box drop-down chain.
I can save the Bay of cluster to deposit without any problem.
Now, I want to read the file is saved in the Bay of cluster.
How can I insert a table 2d of strings into an array of cluster?
rcard53762 wrote:
I have a cluster with 4 channel 3 elements of the string constants and 1 is a list box drop-down chain.
I can save the Bay of cluster to deposit without any problem.
Now, I want to read the file is saved in the Bay of cluster.
How can I insert a table 2d of strings into an array of cluster?
It would be useful to have an example of what real cluster Bay look like the typical data. One way to do is by saving the content of the table cluster in a configuration file (.ini extension) and then use the OpenG screws of the Variant Configuration file to store and retrieve data from the configuration file. You can get these screws in the VI package manager.
Here is an example. The generated configuration file is also attached.
Ben64
-
DRM function to replace the comma in a string
Hello
I'm new to the DRM. I have a requirement to replace insérent in a string with the semicolon (-). Is it all built in function to achieve.
For example -.
input string is s1, s2, s3
Output string should be s1, s2, s3.
I tried to use the ReplaceStr function. This works well for replacing any other, but for the comma, it does not work.
Appreciate your help.
It works for me with the formula below to do a global search of replacement that uses properties to store the string the comma (s) must withdraw and a global property to contain the decimal point itself:
ReplaceStr (PropValue (Custom.String), (Custom.Comma) PropValue,, T)
You've been do not add commas directly in the formula contained in the definition of the property you have? That would by way too many parameters in the function when the formula is analyzed for you would end up with something like ' DRM-25620: number of parameters for the function "ReplaceStr" invalid. " 4 expected, found 5. »
Concerning
Craig
-
How to remove several commas in a string
Hello friends,
I have a string like "Myriam, pqrstu, prquste.
Need to convert to a seperated string comma as "pqrstu, Fund, Myriam, prquste.
I used RTRIM ('Myriam, pqrstu, Fund, prquste, ',' '), but commas between the chain is not deleted but only on the right side of the string
Select RTRIM ('Myriam, pqrstu, Fund, prquste,', ') twice;
I hold in a single select statement.
Please advice.
Thank you/KumarIn the query, you answered, there is still a comma at the end of the chain...
Yes, because you wrote:
Need to convert to a seperated string comma as "pqrstu, Fund, Myriam, prquste.
in your original question. There is comma at the end, so my example.
However, you already fixed it ;)
Don't forget that my example will not work for more than 2 of the comma.
You may need to resort to the solution of Frank, but there is a risk of a loss of performance, based on the amount of data and your hardware. -
Cannot insert data of type string/xml in table
I am able to read the xml through utl_file. String, but I am not able to the same insert into the table through DBMS_XMLSTORE
CDSL_UPLOAD is the download directory
CDSL is the username
PL, let myself be guided if something wrong with the following script
SCRIPT OF THE TRIAL. XML FILE
<? XML version = "1.0"? >
< metadata >
-zip codes >
-< mappings Record = "4" >
CA < STATE_ABBREVIATION > < / STATE_ABBREVIATION >
< ZIPCODE > 94301 < / code >
< / maps >
-< mappings Record = "5" >
< STATE_ABBREVIATION > CO < / STATE_ABBREVIATION >
< ZIPCODE > 80323 < / code >
< ZIP_CODE_EXTN > 9277 < / ZIP_CODE_EXTN >
< / maps >
< / zip codes >
< / metadata >
CREATE TABLE TRIALZIPCODES
(
STATE_ABBR VARCHAR2 (20) NOT NULL
NUMBER ZIP_CODE (10, 0) NOT NULL
, ZIP_CODE_EXT VARCHAR2 (20)
);
create or replace PROCEDURE first INSTANCE AS
BEGIN
DECLARE
-declaring attributes
charString varchar2 (80);
finalStr varchar2 (4000): = null;
whole rowsp;
v_FileHandle UTL_FILE. TYPE_DE_FICHIER;
l_context_handle dbms_xmlgen.ctxHandle;
insCtx DBMS_XMLStore.ctxType;
DNAME varchar2 (20);
Start
dnom: = "CDSL_UPLOAD";
-DBMS_XMLGEN.setRowTag (ctx IN ctxHandle, rowTag IN VARCHAR2);
-DBMS_XMLGEN.setRowSetTag (ctx IN ctxHandle, rowSetTag IN VARCHAR2);
-the name of the table specified in our DTD
DBMS_XMLGEN. SETROWSETTAG ("l_context_handle,'s postal Code");
-the name of the data set as shown in our DTD
DBMS_xmlgen.setRowTag (l_context_handle, 'mappings');
-to get the result on the screen
dbms_output. Enable (1000000);
-Open the XML document in read-only mode
v_FileHandle: = utl_file.fopen (dname, 'trial.xml', 'r');
loop
BEGIN
UTL_FILE.get_line (v_FileHandle, charString);
exception
When no_data_found then
UTL_FILE.fclose (v_FileHandle);
"exit";
END;
dbms_output.put_line (charstring);
If finalStr is not null then
finalStr: = finalStr | charString;
on the other
finalStr: = charString.
end if;
end loop;
-for the insertion of XML data in the table
insCtx: = DBMS_XMLSTORE. NEWCONTEXT('CDSL.) TRIALZIPCODES');
insCtx: = DBMS_XMLSTORE. INSERTXML (insCtx, finalStr); --ALSO FAILED HERE
dbms_output.put_line ('INSERT FACT' |) To_char (rowsp));
DBMS_XMLStore.closeContext (insCtx);
END;
TRIAL END;
Procedure returns the following error
ORA-031011 XML parsing failed
ORA-19202 error has occurred in the processing of xml
LPX-00222 error returned to the SAX callback function
ORA-06512 at SYS. XMLSTORE 70 line
ORA-06512 CDSL. FIRST line 47
ORA-06512 line 2
PL I want to know what is the problem with the above script
Thank you
VishalIndeed a few questions:
(1) I don't see what possible use of this part:
-- DBMS_XMLGEN.setRowTag ( ctx IN ctxHandle, rowTag IN VARCHAR2); -- DBMS_XMLGEN.setRowSetTag ( ctx IN ctxHandle, rowSetTag IN VARCHAR2); -- the name of the table as specified in our DTD DBMS_XMLGEN.SETROWSETTAG(l_context_handle,'zipcode s'); -- the name of the data set as specified in our DTD DBMS_xmlgen.setRowTag(l_context_handle,'mappings') ;
(2) not really a problem, but do not use UTL_FILE to read XML files. Oracle already provides the practice of methods or procedures to read XML efficiently with an call (see examples below).
(3) in order to use the DBMS_XMLSTORE, the names of XML elements must match the columns in the table exactly, which is not the case here. If you cannot change the structure of the XML or the structure of the table to get an exact match, you can pre-process the file (with XSLT, for example).
So, below is an example of using DBMS_XMLSTORE and an alternative with XMLTable that offers more flexibility:
SQL> CREATE TABLE TRIALZIPCODES ( 2 STATE_ABBREVIATION VARCHAR2(20) NOT NULL 3 , ZIPCODE NUMBER(10, 0) NOT NULL 4 , ZIP_CODE_EXTN VARCHAR2(20) 5 ); Table created SQL> set serveroutput on SQL> DECLARE 2 3 xmldoc clob; 4 insCtx DBMS_XMLStore.ctxType; 5 dname varchar2(20) := 'TEST_DIR'; 6 numrows number; 7 8 BEGIN 9 10 xmldoc := dbms_xslprocessor.read2clob(dname, 'trial.xml'); 11 12 insCtx := DBMS_XMLStore.newContext('TRIALZIPCODES'); 13 DBMS_XMLStore.setRowTag(insCtx, 'mappings'); 14 numrows := DBMS_XMLStore.insertXML(insCtx, xmldoc); 15 16 dbms_output.put_line('INSERT DONE '||TO_CHAR(numrows)); 17 18 DBMS_XMLStore.closeContext(insCtx); 19 20 END; 21 / INSERT DONE 2 PL/SQL procedure successfully completed SQL> select * from trialzipcodes; STATE_ABBREVIATION ZIPCODE ZIP_CODE_EXTN -------------------- ----------- -------------------- CA 94301 CO 80323 9277
Or,
SQL> select * 2 from xmltable('/metadata/Zipcodes/mappings' 3 passing xmltype(bfilename('TEST_DIR', 'trial.xml'), nls_charset_id('AL32UTF8')) 4 columns state_abbr varchar2(20) path 'STATE_ABBREVIATION' 5 , zip_code number(10) path 'ZIPCODE' 6 , zip_code_ext varchar2(20) path 'ZIP_CODE_EXTN' 7 ) 8 ; STATE_ABBR ZIP_CODE ZIP_CODE_EXT -------------------- ----------- -------------------- CA 94301 CO 80323 9277
-
Extract values separated by commas in xquery string
Hello
We get a string with values separated by comma Ex: a, b, c.
Our requirement is to mark the string and transform values to an XML using xquery.
I'm new to xquery. Can someone help me on this please.
Thank you
ChauvinHi Jacky,.
You can use the function "mark".
For example:let $str := "a,b,c" return
{ for $i in tokenize($str,",") return - { $i }
}will return:
- a
- b
- c
-
the input of the procedure parameter is "comma separated', i.e. * 'usa, England, Sweden, Cyprus' *.» now I need to separate these values and insert in the table containing the primary key.
Suppose I have a table like t
the output should be
Select * from t;
country ID
------------------
1. United States
2 England
Sweden 3
4 Cyprus
ID is the primary column
one way to do this
and then I show anoyomous blockCREATE OR REPLACE type MCP_ADV_TRANS_TYPE AS OBJECT ( subcategory_id varchar2(150) ) / CREATE OR REPLACE TYPE MCP_ADV_TRANS_TAB_TYPE AS TABLE OF MCP_ADV_TRANS_TYPE;
is there a better way to do it?declare v_eno mcp_adv_trans_tab_type := mcp_adv_trans_tab_type (); i NUMBER := 1; v_nos VARCHAR2 (1000):= 'usa,england,sweden,cyprus'; --v_nos varchar2(100) begin LOOP IF (INSTR (v_nos, ',') = 0) THEN v_eno.EXTEND (); v_eno (i) := mcp_adv_trans_type (v_nos); EXIT; ELSE v_eno.EXTEND (); v_eno (i) := mcp_adv_trans_type (SUBSTR (v_nos, 1, NVL (INSTR (v_nos, ',') - 1, LENGTH (v_nos) ) ) ); v_nos := SUBSTR (v_nos, INSTR (v_nos, ',') + 1); END IF; i := i + 1; END LOOP; FOR rec IN (SELECT subcategory_id FROM TABLE (CAST (v_eno AS mcp_adv_trans_tab_type))) LOOP insert into t values (VISA_COUNTRY_SEQ.nextval,rec.subcategory_id); -- NULL; END LOOP; end;
SQL> create table test 2 (id number 3 ,country varchar2(50) 4 ); Table created. SQL> var countries varchar2(50) SQL> SQL> begin 2 :countries := 'usa,england,sweden,cyprus'; 3 end; 4 / PL/SQL procedure successfully completed. SQL> SQL> insert into test 2 select rownum 3 , REGEXP_SUBSTR (ctr,'[^,]+',1,rownum) 4 from (select :countries ctr from dual) 5 connect by level <= length (ctr) - length (replace (ctr, ',')) + 1 6 ; 4 rows created. SQL> select * 2 from test 3 / ID COUNTRY ---------- -------------------------------------------------- 1 usa 2 england 3 sweden 4 cyprus SQL>
-
I have a company name which can contain commas in one or more positions. I need to replace the comma with a space.
Example:
DOM, s travel and Dom, s Express
Need to read
S travel and DOM. DOM s Express
Thank you
Paul
> I need to replace the comma with a space.
-
I tried ot add comma after 3 digits to my result value.
but the first result is good, and 2nd hour is changed (not good result value)
my code:
var reg:RegExp = /\d\d\d$/g; var a:Array = new Array(); var res:String =''; var dnSpeeds:String; dnSpeeds = e.params.bandWidth; downSpeeds.text = dnSpeeds + " Kbps"; downTest(); while (dnSpeeds.length > 3){ a.push(','+dnSpeeds.match(reg)); dnSpeeds = dnSpeeds.replace(reg,''); } for (var i:int = a.length; i > 0; i--){ res = res+a[i-1]; } res = dnSpeeds+res; trace(res); function downTest() { if (Number(dnSpeeds) >= 512) { Pass.visible = true; Fail.visible = false; } else{ Pass.visible = false; Fail.visible = true; } }
Search for 'number formatting flash as3' to find the formatting that does what you want. for example,.
http://StackOverflow.com/questions/721304/Insert-commas-into-number-string
-
Insert into the table with the help of the string
Hi all
I have a string with commas.
Is it possible to insert the values of string directly in the table in each column.
For ex:
v_str = "10,20,30,40";
insert into v_tab (col1, col2, col3, col4) values (10,20,30,40);
I would like to pass v_str instead of numbers in the insert statement.
Thank you
I try with this simple block
How can achieve us ifDECLARE v_char VARCHAR2(1000) := '10,20'; v_query VARCHAR2(3000); BEGIN v_query := 'INSERT INTO week_bkgs(week_num, product_bkg) VALUES (:x)'; EXECUTE IMMEDIATE v_query USING v_char; END; /
the column a. data types are the NUMBER
b column data types are VARCHAR2
Published by: polasa on October 30, 2008 21:20Try this
SQL> set lines 100 SQL> desc student; Name Null? Type ----------------------------------------------------- -------- ------------------------------------ NAME VARCHAR2(100) STUDENT_NUMBER NUMBER(10) SQL> declare 2 str_v varchar2(100) :='''abc'',1'; 3 begin 4 execute immediate 'insert into student values ('|| str_v ||')'; 5 end; 6 / PL/SQL procedure successfully completed. SQL> select * from student where student_number=1 2 ; NAME STUDENT_NUMBER -------------------- -------------- abc 1 SQL>
-
replace the comma with point to a string
Hello
I tried to replace the comma in the chain attached to a point, but I can't make it work. What I am doing wrong?
Calle cordially
You have a space after the comma in your string constant.
-
Concatenation of strings to form an INSERT INTO statement
I am trying to build an insert statement by concatenating strings. Basically, that's what I do:
< cfset string1 = "INSERT INTO #tablename # (" > ").
< cfset string1 = string1 & #colname # >
< cfset string1 = string1 & ")" > "
< cfset string2 = "VALUES ('" > ").
< cfset string2 = string1 & #coldata # >
< cfset string2 = string1 & "')" > "
< cfquery = "insert" datasource name = "db" >
# String1 string2 # #.
< / cfquery >
-----------------------------------------
Also, if I change the < cfquery > tags to < cfoutput > I get a valid INSERT statement:
INSERT INTO Habitat (AREA, ARTID, BIOTOP) VALUES (43, 37, ' text')
But when I have the tag < cfquery > I get this error:
Syntax error (missing operator) in query expression "' text"'.
I tried to change the (' #coldata # ') to ("#coldata") and also tried ("#coldata #") and ("' #coldata # '"), but I get errors all the time...
So. How can I do this?
I'm not asking why you do this :)
but you will need to use preserveSingleQuotes(). probably right around string2, but may not be wrong to just wrap the whole.
#preserveSingleQuotes (string1 & string2) #.
-
Insert the record with the decimal string?
I want to insert a record with commas, as the below:
Is there a way we can insert commas in the table?INSERT INTO TABLEA(CITY) VALUES('ALBANY,NEWYORK,TROY')
This statement has been inserted
What is your question.
SQL> INSERT INTO TABLEA(CITY) VALUES('ALBANY,NEWYORK,TROY') ; 1 row created.
Maybe you are looking for
-
I can not access the same menu bar after reading your instructions.
I just download Thunderbird on my second computer. The instructions say to new users to access the menu bar, you need to right-click on an empty spot on the screen. I tried, but it does not work for me. Someone help please.
-
G6-1b79dx Notebook PC Pavilion
My g6-1b79dx Notebook PC Pavilion touchpad does not work. Can you please give me the link that I can download the driver? Best, Noom
-
HP ENVY 15 Notebook PC J6P01UA: Viewer guides hp force display of user's guides in word
At the opening on the user guide HP for the first time on a new HP laptop, I was presented with an option to view the user guide in Word or PDF and maybe other choices. I have happpen to choose the WORD. Big mistake. It was unknowingly a permanent
-
Cannot change font size Windows Mail
Title: SISE FONTS WINDOWS mail is NOT MODIFIABLE IT COST 12 WINDOWS MAIL HAS WORKED UNTIL 2 DAYS AGO. I WANT SOME LARGE FONTS. HE CHANGED IN OPTIONS. BUT THIS GOES BACK TO 12 WHEN I COMPOSE EMAIL
-
Hard drive failure: targeted read Test failed, SMART short self test FAILED
Suddenly, I get this popup to My Dell saying that my computer has failed two important tests and the hard disk failure is imminent. It scared me so much I almost fell of my computer Chair, so I came here to help... my computer is a Dell Inspiron 15R