How to convert char(1) to int32 datatype in pl/sql
Hello,
I am trying to convert char(1) to an integer data type to be put into an int32 variable in C#. I tried several options such as TO_NUMBER ,CAST(.. AS INTEGER), and CAST(.. AS SMALLINT) but they all return int64.
Is there a way to ensure the casting into a datatype that is compatible with int32 ?
Thanks
Oracle's SQL Datatypes are limited to NUMBER, BINARY_FLOAT and BINARY_DOUBLE.
There's a few others through PL/SQL including BINARY_INTEGER.
If you look in USER_ARGUMENTS you can see it is defined slightly differently.
Don't know whether / how .Net infers datatypes, but it is worth a shot.
create or replace function v (p number) return binary_integer is
begin
return p;
end;
/
Similar Messages
-
How to convert char to curr ?
Hi gurus.
Forgive me for the silly question.
I have a problem with data conversion from char to curr with 2 decimal places.
This is the scenario, I have a Z transaction which receives an excel file containing data from invoices and when the field contains a value such as 35,0 the program records the value 3.50 in the destination variable. But when the value is 35,45, it works.
Here is the piece of code:
WHEN '0007 '.
TRANSLATE USING ITAB-VALUE. " '.
ITAB-VALUE USING TRANSLATE',.'.
CONDENSE ITAB-VALUE NO-GAPS.
WA_OPER_MENORES-VL_BRUTO = ITAB-VALUE.
If I format the column in the excel file for numeric value with 2 decimal places also works, because when the value is formatted 35,0 change to 35,00. But I can not tell all the users hey formatt your files before upload to SAP.
To test I generate a simple report that reads the excel file and makes the conversion of the columns, like the code above, so I had no problems. I think there should be some configuration that has been changed in the transaction, but I'm new in ABAP, I come from "Java World" and I have no idea that could be.
I could just use a quick and dirty solution, adding a zero at the end of the column, when there is the 2 decimal places, but I prefer a clean solution.
Guys, is there any function module or class that does that kind of data conversion? If not, you could tell me what is the best practice to solve this problem?
thank you very much,
Ronaldo S. VieiraFollow this example to convert Char to Curr and Vice-Versa
DATA iamnt(17) TYPE c VALUE '243567.00'.
DATA eamnt TYPE p DECIMALS 2.
DATA oamnt(17) TYPE c.
MOVE iamnt TO eamnt.
WRITE eamnt TO oamnt.
WRITE oamnt. -
How to Converting Char to Date?
Hi
while i converting the char to date i am getting the below error, can some tell me how to resolve the issue.
Datetime value 01/01/2011 from 01/01/2011 does not match the specified format. (HY000)
SQL Issued: SELECT 0 s_0, CAST(CONCAT('01/01/',cast(year(current_date)as char)) as DATE) s_1 FROM ''example reports"Can you check whats your default date format. Just run the report with Current_date and look at whats the format. Ensure you dont override the default date format by going into column properties.
Try applying the same format when you use the cast as date function.
Also, you can refer to this link. http://gerardnico.com/wiki/dat/obiee/cast_as_date_
Thanks -
How to convert file format using bfile datatype
<pre>
Hi all,
Assume, i has a table BFILE_IMAGE and it table structure is similar like:
SQL> desc bfile_image;
Name Null? Type
IMAGE_ID NUMBER
FILE_NAME VARCHAR2(30)
IMAGE BINARY FILE LOB
SQL>
Is that impossible if we can use process() function with bfile datatype? similar like:
ordsys.ordimage.process(image,'fileFormat=JPEG contentFormat=24BITRGB');
The line above is work with blob datatype but doesn't with bfile datatype. Can you please give me some idea how to deal with it.
Thanks,
Kevina BFILE is content stored outside the Oracle database. It is a read-only object.
process() is an in-place modification of the image. This is only possible with BLOB stored content.
If you are using BFILE you could use the processCopy() method to create a new copy of the BFILE stored image that has been processed according to your command. -
How to convert a varchar to integer datatype in obiee Answers?
Hi Gurus,
I tried using cast to convert a varchar to integer type eg.
cast (column as integer) in fx in answers but its not working.
Can we use to_number function in answers?
Also do we have any other way of changing the datatype of a column rather than changing it in
Physical layer of the rpd.
Thanks
Ashish GuptaAlways first choice should be BI instead of porting a function on DB side.
As Lakshmipathi said do that.
It would be always nice to share what you see instead of "Not working"
have fun -
Data conversion - How to convert char to decimal variant?
Hi expert,
In the example below, I want to convert the variable l_var1 to l_result
data l_var1(16) type c.
data l_preis(11) TYPE p DECIMALS 2.
data l_result(11) TYPE p DECIMALS 2.
l_preis = 10981.
write l_preis to l_var1.
after the write statement, l_var1 = 10,981.00. currently i want to move l_var1 to l_result. Is there anyone who knows how to do it? Thank you very much.Hi Liu,
I want to know the exact requirement. Instead of what you are trying to do , you can do the following way.
DATA l_var1(16) TYPE c.
*data l_preis(11) TYPE p DECIMALS 2.
DATA l_result(11) TYPE p DECIMALS 2.
l_var1 = 10981.
MOVE l_var1 TO l_result.
WRITE l_result.
<li> MOVE statement gives desired result. It gives rounding values.
Thanks
Venkat.O -
How to convert char array to string
sirs,
i have written a method in java which will return a randomly generated string of a fixed length. i am creating one one character and inserting it into char array.
at last i am converting it to string
like this
String newpass= pass.toString();// pass is a char array
but problem is that the string is having different value what i hav generated.
if i am doing like this..
String newpass= new String(pass);// pass is a char array
here newpass is having correct value but having some error
error in the sense when i print
System.out.println(newpass+"some text");
"some text" is not printing
can you suggest the better way/*this is my method */
private String generateString(int len){
char pass[] = new char[10];
int cnt=0;
int temp=0;
Random randomGenerator = new Random();
for (int idx = 0; idx < 1000; ++idx)
temp = randomGenerator.nextInt(1000)%128;
if((temp>=65 && temp<=90)||(temp>=97 && temp<=122)||(temp>=48 && temp<=57))
pass[cnt]=(char)temp;
cnt++;
if(cnt>=len) break;
String newpass= pass.toString();
String newpass1= new String(pass);
System.out.println("passed pass"+newpass+"as"+newpass1+"sa");
return newpass;
here newpass and newpass1 are having separate values
why ??
Edited by: Shovan on Jun 4, 2008 2:21 AM -
Source:Essbase, how to convert char in date format
Hello
Version OBI EE:10.1.3.4.1.090414.1900
Source:Essbase
We have date in format VARCHAR (01.01.2008). I want to have date in format DATE.
I transform our date on Business Level in DATE (yyyy-mm-dd)
CAST ( SUBSTRING(Copeck."Time"."Gen5,Time" FROM 7 FOR 4) || '-' || SUBSTRING(Copeck."Time"."Gen5,Time" FROM 4 FOR 2) || '-' || SUBSTRING(Copeck."Time"."Gen5,Time" FROM 1 FOR 2) AS DATE )
And in Answers I can see our DATE in format DATE,
but when I want to use filter on this field i get mistake
HY000. Код: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] meaning date/time 2008-01-01 nonqualifying given format
Состояние: HY000. Код: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] Возникла общая ошибка. [nQSError: 46046] Значение дата/время 2008-01-01 не соответствует заданному формату. (HY000)
Сформированный SQL: SELECT Time."Дата начала4" saw_0 FROM Copeck WHERE Time."Дата начала4" = date '2008-01-01' ORDER BY saw_0
When i use
CAST ( SUBSTRING(Copeck."Time"."Gen5,Time" FROM 1 FOR 2) || SUBSTRING(Copeck."Time"."Gen5,Time" FROM 4 FOR 2) || SUBSTRING(Copeck."Time"."Gen5,Time" FROM 7 FOR 4) AS DATE ) - ddmmyyyy
I can't see our DATE in format DATE in Answers, because I immediately get mistake
When I use usual database, i don't have this mistake, may be it depends on Source date?I understand the converions for formatting dates. Thank you for this posting, it helped a lot. Now I need to take this one step further and that is modifying a date that comes the XML Datasource in the format I do not want.
Start Date is the name of the field. It is in XML and my RTF as 2009/10/03 and I want 10/03/2009 or 03-Oct-2009.
Any help on this is most appreciated.
Thanks
G -
How to convert a boolean expression into a number in SQL (not PL/SQL)
I have a boolean expression
FIELD IN (SELECT FIELD FROM TABLE)
which I would like to convert into a number, preferably into 0 for true and into 1 for false. The reason being that I want to sum the values in a HAVING clause.
I have tried with DECODE, SIGN, TO_NUMBER, but all fail with an error message to the order of wrong type of argument.
Does anyone have an idea?
/poul-jorgenHi, you can do it with case if you have Oracle 9i
Regards
Laurent
select case when dummy in ('X') then 1 else 0 end from dual; -
Converting Char type structure to Hex type structure
Hello ,
In unicode system how to convert char type structure to hex type structure . I am having structures as follows :
DATA: BEGIN OF HEXBYTE,
X TYPE X,
END OF HEXBYTE.
DATA: BEGIN OF CHARBYTE,
C TYPE C,
END OF CHARBYTE.
HEXBYTE-X = CHARFIELD.
CHARBYTE = HEXBYTE.
But error coming is Charbyte and HexByte are not compatible . Plz suggest!!
Thanks ,
KeithHi,
These function modules are:
NLS_STRING_CONVERT_TO_SYS (hex to char)
NLS_SRING_CONVERT_FROM_SYS (char to hex)
Regards,
Nikhil -
How to convert data from rows into columns
Hi,
I have a sql table and the data looks like this
GLYEAR GLMN01 GLMN02 GLMN03 GLMN04
2007 -109712.40 6909.15 4758.72 56.88
2007 -13411.32 19132.9 -5585.07 4362.64
Where GLyear reprsents Year and GLMN01 is February, GLMN02 is March and so on,
Now i want my output to be something like this which i want to insert into another table
GLYear GLMonth GLAmount
2007 February -109712.40
2007 March 6909.15
2007 April 56.88
My new table has 3 columns, GLYear,GLMonth,GLAmount.
Can someone please help me with the select statement on how to do this, i can work with the inserts.
Thanks.I want you to check these form tread they have the same discussion as you. They will definitely solve your problem
http://blog.jontav.com/post/8344518585/convert-rows-to-columns-columns-to-rows-in-sql-server
http://dba.stackexchange.com/questions/19057/convert-rows-to-columns-using-pivot-in-sql-server-when-columns-are-string-data
http://stackoverflow.com/questions/18612326/how-to-convert-multiple-row-data-into-column-data-in-sql-server
I hope this helps you in solving your problem.
Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer -
How to convert DATE variable to CHAR variable
dear all,
How to convert DATE variable to CHAR variable
thanqDepending on your final goal here are 2 options.
DATA: datein TYPE d.
DATA: dateout(10) TYPE c.
DATA: dateout2(8) TYPE c.
datein = sy-datum.
WRITE datein TO dateout MM/DD/YYYY.
dateout2 = datein.
WRITE:/ datein, dateout, dateout2.
and the output
05022008 05/02/2008 20080502 -
Our application uses barcode scanner.
when scanning a barcode and convert Keyboard.key (as ushort with value 16, it represents char ':') by using
1)(char)(Keyboard.key)
2) or Convert.ToChar(Keyboard.key),
both way convert into symbol '+'.
How to convert into ':'?
What is a correct way to convert Keyboard.key as ushort into correct char? Thx!
JaneCHi Dan Nemec,
It is normal '+'. It is special '+' symbol.
We search a little bit and find out Unicode ':' is 3A and value is not 16.
So during the process barcode scanner, the value has been changed in some way.
We are trying to find out where the value has been changed.
JaneC -
How to convert epoch time to datetime in sql*loader Oracle
Hello,
I wan't to question how to convert epoch time to datetime in sql*loader Oracle. I try this script for convert epoch time to datetime in sql*loader, but error:
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
This is my loader:
LOAD DATA INFILE 'C:\Documents and Settings\Administrator\My Documents\XL_EXTRACT_211\load.csv'
into table TEMP_TEST_LANGY append
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
DATADATA CHAR "TO_DATE('01-JAN-1970','DD-MON-YYYY')+:datadata/86400"
This is my csv file:
79314313.7066667
79314336.2933333
79314214.3466667
This is my table:
CREATE TABLE TEMP_TEST_LANGY
DATADATA DATE
Thanks
Edited by: xoops on Sep 21, 2011 8:56 AM
Edited by: xoops on Sep 21, 2011 8:58 AMthanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
This is my error log:
Column Name Position Len Term Encl Datatype
DATADATA FIRST * , CHARACTER
SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Edited by: xoops on Sep 21, 2011 12:33 PM -
How to convert special characters in ABAP to XML?
Hi All.
We have a scenario where from XI (exchange Infrastructure), a BAPI is called which returns an XML. From that XML, a PDF is generated.
Now, if the XML contains any special characters, it will fail.
So if any CHinese char or >, # etc signs are there, it fails.
Can you please tell me how to convert my string in ABAP to a proper XML?
I am new to it and I was trying the following code
DATA: today TYPE string,
result TYPE string.
today = 'This is testing'.
CALL TRANSFORMATION ID
SOURCE today = today
RESULT XML result.
IF sy-subrc = 0.
WRITE result.
ENDIF.
But it does not return me anything.
Thanks in adv.hi
good
go through these links,hope these would help you to solve your problem
http://www.sap-press.de/download/dateien/792/sappress_abapreference_2edition.pdf
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
thanks
mrutyun^
Maybe you are looking for
-
Could not find "ADF Data Controls" in ADF tutorial 10.1.3.1.0 chapter 2
Hi I am currently learning Oracle ADF followed by 10.1.3.1.0 tutorial. ( September 2006 Revision ), I installed Oracle Jdeveloper 10.1.3.2.0 on my pc with remote 10.2.0.2 database connection. In the manual page 2-17, the final step of that chapter, i
-
''locking - please continue in your original support thread - here - https://support.mozilla.com/en-US/questions/835625'' I sent you a question yesterday and you sent me an email saying you couldn't activate my account because I either didn't click o
-
Cascading List of Values & Query Panel
Hello all! ADF BC JDev 11 I should use Cascading List of Values in Search Query Panel. I build CLOV like in this sample http://www.oracle.com/technology/obe/obe11jdev/11/adfbc_new_features/adfbc.html . But when i use it in Search Query Panel it does
-
Hi all, Is there a way to upload a large file. The problem: 1 file with fixed length records (59 bytes wide) Over 17million lines available (actually a download from an extreme old system), making a total of almost 1Gb. I have a database table that e
-
Addressbook: sequence of phone numbers / emails
Most of my contacts have e.g a home, work and mobile phone number. I would like to determine the order of theses, since whene I update one of them, the order changes quite often. Same with emails: if it changes and the contact is in a group, and if I