Converting RPAD output from VARCHAR2 to CHAR
I am trying to create a 1000-character fixed-width file using SQL*Plus. The query consists of 3 fields with a pad of 25 characters each, with the remaining 925 characters as filler using spaces. Using RPAD I can insert spaces between the three field values, but because the RPAD function uses VARCHAR2 to return the result it is not recognizing the ~945 filler spaces I need at the end of each row.
Is there a way to convert the output of RPAD to a CHAR data type in the query itself? Maybe something equivalent to the CONVERT function in t-SQL?
Query I'm using:
Select RPAD(Col1, 25, ' ') || RPAD(Col2, 25, ' ') || RPAD(Col3, 950, ' ') From Table1;
Thanks,
Matt
Hi,
Welcome to the forum!
You can ihave trailing spaces (950 of them if you want, no problem) in a VARCHAR2 column. I suspect your font-end tool is not displaying them.
The SQL*Plus commands
SET TRIM OFF
SET TRIMSPOOOL OFFshould guarantee that trailing spaces are displayed in screen- and SPOOL file output, respectively.
Also, make sure your lines are long enough:
SET LINESIZE 1000If you still have a problem, post a complete test script (including all the SQL*PLus formatting commands you use) as well as a query. (Something using dual or scottt.dept should illustrate the problem adequately).
Similar Messages
-
Does anyone know how to convert the output from the standard report to xml?
Does anyone know how to convert the output from the standard SAP report to xml?
since it a standard report which you cannot modify you can only do the following.
submit report exporting list to memory
then
list from memory and then
use the returned itab along with CALL TRNSFORMATION key word to convert to xml.
but this only going to place the whole list content (including data and formating lines,etc) into a xml element and not the actual data alone in the list . -
How to convert a column from varchar2 into timestamp(3)
Hi all,
I have a date field column with varchar2 as datatype :
date
3/13/2011 10:22 AM
3/13/2011 10:22 AM
I tried this:
select to_timestamp(date,'HH24MI') from dual;Iam getting this error:
ORA-01858: a non-numeric character was found where a numeric was expected
I want to convert date column to timestamp(3) column846773 wrote:
I want to convert date column to timestamp(3) columnTIMESTAMP is not time column. Look at it as a date with better precision - it supports franctional part of a second. Anyway, use:
select to_timestamp(date,'MM/DD/YYYY HH:MI AM') from dual;SY. -
To convert report output from A4 page to A3 page
Hi to all
I am modifying the comparative statement report (For different vendors and items) which is in A4 page.
now i want to convert it in A3 page size.
Plz tell me what's the line-size, line count and different changes i have to do .
Thanks & Regards
AnubhavHi ,
You can set a element variable . While using ' write ' , you can multiply it after 'at' . For Example :
data : i type i ,
page(2) .
if page = 'A3'
i = 10 .
else .
i = 15 .
endif .
perform mywrite using 10 'abc' .
form mywrite using i_pos s_value .
data j type i .
j = i * i_pos .
write : at j s_value .
endform. -
How to convert an output retrieved from database to an excel sheet?
Hello friends,
I am preparing an online JSP based project for our training and placement department.
In this context, I am showing an output into a JTable format to the user for the shortlisted candidates by retrieving this information from my database (MySQL).
Now I need to convert this output into the Excel Sheet so that I can perform various operations over there.
So, what are the things required to perform from my side for implementing the same.The easiest thing for you to do would be to save it as CSV (Comma Separated Values). In general, your fields would be separated by commas, and any fields that are not numbers would be surrounded with double quotes:
1,"text",...
Dates and times are semi-tricky, but excel is pretty good about accepting "YYYY/MM/DD" and "HH:MI AM" format.
Other than that, you'll be learning the internal structures of Excel or perhaps there is a third-party library that can do this for you... -
Converting a SQL Command Parameter from Date to Char
Hi,
I'm using CR XI version 11.0.0.1282. I've created a report using a SQL Command and have a parameter defined as Date. I need to convert this Date parameter to a CHAR and have created my WHERE clause as:
WHERE "CC_PAYH"."PPOST"= CHAR ('{?From Date}') AND
"CC_PAYH"."PPTYPE"<>13
I get a message saying 2008 is not a valid token which in AS400 means it doesn't like the year. Go figure.
I've tried running a similar query in AS400 and I get the desired affect. I've tried removing the parameter from the Where clause and putting it into the Select like:
CHAR ('{?From Date}') as MyTestDate
just to see the representation I would get and I get the same error.
The question I have like everyone else is; is this possible with this version of Crystal? I assume so since the same query will work in the database itself.
Thanks,
BrianHi Brain,
Can you please try the query similar to the following syntax and verify whether it helps you!
Select * from Orders where ([Order Date]) =
CStr({?Date})
Regards,
Vinay -
Does any one know how to convert from jchar to char?
Thank you,does it have to be a jchar or can you get a jstring? is it possible to convert your jchar into a jstring before you pick it up in jni? if you can get a jstring you can use the function
const char* GetStringUTFChars(jstring str, jboolean *isCopy)
you would get back a character pointer that points to a single char plus the null terminator -
Getting ¿¿¿¿¿¿ while converting Raw data to Varchar2.
Hi All,
We are fetching data from as400 database to Oracel using a dblink.
It gives us Raw data. But when we tried converting Raw data to Varchar2 at Oracle side Its returning ¿¿¿¿¿¿ instead of actual data.
We are using Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
We used following SQL:
select UTL_RAW.CAST_TO_varCHAR2(ordno) from amflib6.pomast@as400_pub
OUTPUT : ¿¿¿¿¿¿
However we also tried to run it withoout dblink as following but not getting required data.
select UTL_RAW.CAST_TO_varCHAR2('4DAC') from dual
OUTPUT : M¿
Is it something to do with installed fonts or soem thing else.. Please help us out.
Any help would be appreciated.
Thanks and Regards
InduHi,
Probably a multibyte data vs. characterset issue.
What is the outcome of:
select * from nls_database_parameters where parameter like '%CHAR%';?
Perhaps you'll find some similar problem here:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5783936214008#12758388562377
And check the [Globalisation Support Guide | http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/toc.htm] -
XML Output from Concurrent Request DBMS_XMLGEN
I am trying to create xml output for a concurrent request, using the DBMS_XMLGEN package to generate my XML?
I have gotten so far as to be able to run my procedure and see the output in TOAD using dbms_output.put_line, but I can't seem to quite get the right link to convert this to Oracle Apps output.
I have a concurrent request setup to output XML.
This calls my procedure to return to the output file.
So far, when I run from APPS, all that shows in the Output file is 'XML document must have a top level element.'
Here is the relevant code...
ctx DBMS_XMLGEN.ctxHandle; -- vars to convert SQL output to xml
xml clob;
xmlc varchar2(4000);
off integer := 1;
len integer := 4000;
i number := 0;
rc_data sys_refcursor;
begin
-- this calls simple open cursor for sql statement, returns rows
rc_data := fa10022_data(P_BOOK_TYPE_CODE
, P_STATE
, v_BEG_DATE_EFFECTIVE
, v_END_DATE_EFFECTIVE
, P_BEG_ASSET_ACCT
, P_END_ASSET_ACCT
, v_depr_per_ctr);
ctx := dbms_xmlgen.newContext(rc_data);
dbms_xmlgen.setRowsetTag(ctx, 'XXFA10022');
dbms_xmlgen.setRowTag(ctx, 'G_DATA');
xml := dbms_xmlgen.getXml(Ctx);
i := dbms_xmlgen.getNumRowsProcessed(ctx);
dbms_xmlgen.closeContext(Ctx);
apps.fnd_file.put_line(apps.fnd_file.output, xml);
I was also following this link...
http://www.appsassociates.com/products/Generation_XML_PLSQL.pdf
any suggestions?
Thanks!!
JanelThat was painful, but it helped!
Most of it is workflow code...POXMLGEN contains the pertinent coding.
I think my problem now lies with some of my data. Depending on what is returned, I sometimes receive a warning with no output. I know there are special characters in the data (ex eacute), but I can't tell if that is what is causing the issue. I do have the statement dbms_xmlgen.setConvertSpecialChars(ctx, TRUE); in my code, so not sure what else to do.
This is what is being returned in OPP log...
Caused by: oracle.xdo.parser.v2.XMLParseException: Start of root element expected. -
Split Output from Select into 2 different Cols
Hi,
I am new to oracle dev. Env Oracle 10g R2
I need a help with the following.
I have a select query that returns comma separated values.
Column LIST1 in table svp_1.
This needs to hold that data returned by the select query.
Datatype of Column LIST1 varchar2(4000)
I get the follwing error.
ORA-19011: Character string buffer too small
CREATE OR REPLACE PROCEDURE
sale_temp( pType in Char,lDate in date) as
cnt number;
v_error_code NUMBER;
v_error_msg VARCHAR2(2000);
cursor c1 is select svp
from sale
where type = pType
var1 c1%ROWTYPE;
BEGIN
UPDATE svp_1
SET LIST1 = ( SELECT LTRIM( xmlagg (xmlelement (c, RTRIM(RELATED_SVP) || ',')).extract ('//text()'), ',' ) AS RELATED_SVP from (
SELECT rtrim(BASE_SVP) BASE_SVP,
rtrim(RELATED_SVP) RELATED_SVP
from
svp_enc se
where
se.effective date<= pDate
and (se.expiration_date is null or se.expiration_date > plDate )
and se.base_svp in
( var1.svp
and se.RELATION_TYPE = '4'
)group by base_svp)
WHERE type = pType
commit;
dbms_output.put_line('UPDATE done' );
end;
end loop;
close c1;
END ;
My requirement :
In need to capture the data from the select query and update the column.
The data needs to be returned as comma separated values.
This data can also be split into 2 columns.....ie data split and updated into 2 cols ie LIST1 AND LIST2 ( can be added to existing table).
What is the best way to do this?
Is the below approach possilble?
LOOP through cursor ...check the length of data....for the select query ....check length .if > 3990 byte.....then write into 2 plsql variables.....and update 2 cols....
Is this apporach right, if so how to do that in the procedure ? Please give an example...
Are there any other approaches...?
All I need is to Split Output from Select into 2 different columns and avoid the ORA-19011: Character string buffer too small error.
Thanks in advance.Re: ORA-19011: Character string buffer too small
-
Dispalying output from a REF CURSOR
Friends,
I'm getting my self into indepth pl/sql and need some help from you to clear some basic concepts.
create table MASTER_TABLE
street_info varchar2(100),
property_type varchar2(50) ------- i.e values here would be 'HOME_TABLE' ,'COM_PROP_TABLE' etc
create table HOME_TABLE
property_id char(5),
prop_desc varchar2(100),
cost varchar2(10),
location varchar2(100)
create table COM_PROP_TABLE
property_id char(5),
prop_desc varchar2(100),
cost varchar2(10),
location varchar2(100)
I want to use a single procedure to open a weak REF CURSOR variable for the appropriate table based on the street address and display all information from that table.
Here is what I want to to - execute a stored procedure which accepts 1 'in' paramter and 1 'in out ' parameter.
IN paramter - accepts street address
IN OUT paramter - depending on address , if it is related to 'Homes' , it should display all information from the HOME Table, else it will display information from the 'Commerical Property' table.
create or replace package pack_address_info as
type v_info_type ref cursor;
end pack_address_info;
create or replace procedure schema.sp_home_info(v_add in varchar2,v_show in out v_info_type)
is
home_type constant integer :=1;
commercial_type constant integer :=2;
cursor show_data_cur is
select property_type from MASTER TABLE where street_info=v_add;
var_cursor show_data_cur%rowtype;
begin
open show_data_cur;
fetch show_data_cur into var_cursor;
close show_data_cur;
if var_cursor.property_type= HOME_TABLE
then
open v_show for
select * from HOME_TABLE where location=v_add;
elseif var_cursor.table_name = COM_PROP_TABLE
then
open v_show for
select * from COM_PROP_TABLE where location=v_add;
end if;
end schema.sp_home_info;
I can create the package and the stored proc ... but then ???? i'm stuck ;(
Now , i don't know how to display the output from the HOME TABLE or the COM_PROP_TABLE depending on what the address is entered? Is this code correct. Can you please help me modify this code so that I can achieve my objective.
This is an example from the book 'Oracle PL/SQL Programming, 4th Edition' under the 'CURSOR' section - 15.6
Thanks for the help in advance.Here is one sample ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.02
satyaki>
satyaki>
satyaki>CREATE OR REPLACE PACKAGE aaa_sat
2 AS
3 TYPE crs IS REF CURSOR RETURN emp%ROWTYPE;
4 FUNCTION fc_retcur (e_no IN NUMBER)
5 RETURN crs;
6 END aaa_sat;
7 /
Package created.
Elapsed: 00:00:01.03
satyaki>
satyaki>
satyaki>CREATE OR REPLACE PACKAGE BODY aaa_sat
2 AS
3 FUNCTION fc_retcur (e_no IN NUMBER)
4 RETURN crs
5 IS
6 l_crs crs;
7 BEGIN
8 OPEN l_crs FOR
9 SELECT * FROM emp
10 WHERE empno = e_no;
11
12 RETURN l_crs;
13 END;
14 END aaa_sat;
15 /
Package body created.
Elapsed: 00:00:00.18
satyaki>
satyaki>
satyaki>DECLARE
2 l_emp_rec emp%ROWTYPE;
3 l_crs aaa_sat.crs;
4 BEGIN
5 l_crs := aaa_sat.fc_retcur (7782);
6 LOOP
7 FETCH l_crs
8 INTO l_emp_rec;
9 EXIT WHEN l_crs%NOTFOUND;
10 DBMS_OUTPUT.put_line (l_emp_rec.ename);
11 END LOOP;
12 CLOSE l_crs;
13 END;
14 /
CLARK
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.40
satyaki>
satyaki>Got Me?
Regards.
Satyaki De. -
Convert smartform output in to PDF using CONVERT_OTF function how to do it
Hi Anil , and Hi All
I am trying to display smartforms output in java webdynpro
for that i have got the following code in sdn.
can anybody please clarify these doubts in the below code
1) What are the mandatory input and output parameters
I have to pass here in this code to my application
2) please check my previous post also in this regards please
. Please reply at the very earliest. Check the below code
Convert smartform output in to PDF using CONVERT_OTF function module and you can write pdf using parameter 'binfile' of this function in WebDynpro using the following code:
It is copied from my prg. I hope you understand it.
public void onActionGetQuote(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionGetQuote(ServerEvent)
wdThis.wdGetOppt_QwriterCustController().executeZquote_Writer_Input();
String fileName = wdContext.currentZquote_Writer_InputElement().getOrder().toString().trim() + System.currentTimeMillis() + ".pdf";
String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());
if (pdfOutput != null)
try
String pdfResoucePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);
FileOutputStream fileOutputStream = new FileOutputStream(new File(pdfResoucePath));
PrintStream ps = new PrintStream(fileOutputStream);
ps.print(pdfOutput);
ps.close();
//Display the PDF to the browser
String fileURL = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), fileName);
IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(fileURL, "Pdf Browser", false);
window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
window.removeWindowFeature(WDWindowFeature.MENU_BAR);
window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
window.open();
// To collect all the file created in the server by user
quoteFiles.add(quoteFiles.size(), pdfResoucePath);
} catch (Exception e)
throw new WDRuntimeException(e);
//@@endHi
ABAPers prepared a BAPI function module which calls Smart form , how can i execute it from java Webdynpro, so that I can display the smart form in Webdynpro. Pleas reply at the very earliest. Every answer will be rewarded.
regards
jalandhar -
Hi All,
I want to convert the output of Applescript which is in object format to string or text format, am running Applescript with Java, I need to display the output of applescript in Eclipse Java Console, since its object format the output is not properly displayed..
Pls suggest.. I used the below code
repeat with i in allContents
if class of i is button then set the end of allStaticText to contents of i
end repeat
Applscript ouptput
{button 1 of window "Player Installer" of application process "Install Player" of application "System Events", button 2 of window "Player Installer" of application process "Install Player" of application "System Events", button 3 of window "Player Installer" of application process "Install Player" of application "System Events", button "Finish" of UI element 1 of scroll area 1 of window "Player Installer" of application process "Install Player" of application "System Events"}
Java output
<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'want':'butT', 'seld':1, 'from':'obj '{ 'form':'name', 'want':'cwin', 'seld':'utxt'(" Player Installer"), 'from':'obj '{ 'form':'name', 'want':'pcap', 'seld':'utxt'("Install Player"), 'from':'null'() } } }>Here's an improved version of the previous script, where the handler now returns "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"" instead of "button \"2\" of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\"":
tell application "System Events"
get button 2 of window 1 of process "TextEdit"
my objectToText(result) --> "button 2 of window \"Untitled\" of application process \"TextEdit\" of application \"System Events\""
end tell
on objectToText(UI_element)
set theText to ""
tell application "System Events"
repeat
if exists attribute "AXParent" of UI_element then
set theParent to value of attribute "AXParent" of UI_element
set theClass to class of UI_element
if name of UI_element exists then
set theName to name of UI_element
set theText to theText & (theClass as text) & " \"" & theName & "\" of "
else
set k to 0
get UI elements of theParent whose class is theClass
repeat with thisItem in result
set k to k + 1
if contents of thisItem is UI_element then exit repeat
end repeat
set theIndex to k
set theText to theText & (theClass as text) & " " & theIndex & " of "
end if
set UI_element to theParent
else
set theClass to class of UI_element
set theName to name of UI_element
set theText to theText & (theClass as text) & " \"" & theName & "\" of application \"System Events\""
exit repeat
end if
end repeat
end tell
return theText
end objectToText
Message was edited by: Pierre L. -
GUI locks up when trying to read output from server
I have a client built in MVC fashion and have two GUI views. One view is for output from the server and input from the keyboard. The other view is for changing connection settings and starting the conection. The problem is when I make the call to connect from the connection GUI it is able to connect and set up the streams but both GUIs lock up once I start trying to output the text received from the server. The strange thing is that when I call these methods just from the Model and not via the GUI and its actionListener the whole thing works. I think it may have something to do with the loop locking up the GUI but don't how to resolve this.
public void monitorServer()
try
char inputChar = (char)fromServer.read();
while (socket.isConnected()==true && inputChar >-1 )
inputChar = (char)fromServer.read();
if ( ( (inputChar >= '0') && (inputChar <= 'z') )
||(inputChar == '\n')||(inputChar == '\r')
||(inputChar == ' ') )
String tempString = (""+inputChar);
mv.addText(tempString);
catch(IOException ioException)
JOptionPane.showMessageDialog(null,
"Error: Failed to read message. Corrupt data sent by server",
"Connection Error", JOptionPane.ERROR_MESSAGE);
mv.addText("\nMessage not read.\n");
The code above is the bot that screws it all up. mv is the other view that it is outputting the text to.
Please help! I'm gonna fail my degree. :)you need to run your server connection part in another thread.
-
I have an airport extreme which doesn't come with a straight audio jack on it like the express does. Can I get a converter to go from the dual speaker plugs to usb on the extreme?
Sorry, but no. The only Apple router with an audio output jack is the AirPort Express.
Maybe you are looking for
-
I cant seem to get in to my app store, whats wrong ?
For some reson i cant get in on my app store
-
How do I install and use Photoshop actions
I downloaded a zipped file with actions. I've left the file zipped until I learn how to install the actions in Photoshop CC. Any help will be appreciated.
-
How to specify the functions of buttons in a .jsp
Im working on struts frame work and I want to add 3 buttons to a jsp as cancel,reset ans submit. I have done it like this. submit and reset buttons are working properly but when click the cancel button it gives an error like this. Error ------ messag
-
Contacts created on iPhone4 will not update to Exchange
Exchange is set up and working for mail, calendar and contacts. All content shown on Exchange server (ie, work laptop) shows up on iPhone. Vice versa....all mail and calendar items created on iPhone show up on Exchange -- except contacts. I create co
-
Anyone managed to get ipad mini working with vga projector with apple adaptor?
I had arude shock the last week when i could no longer project anything from my ipad mini using an Apple branded vga to lightning adaptor. Help me im a teacher and desperately need to work asap.