Sql formatting linesize
Hi, Need help,
I am spooling data from a database table (db-UTF-8) to a flat file.
I am setting line size as 170. But if data in table column is of length less than 170, it still shows trailing spaces.
I there any way I can remove those spaces (set by Linesize) without using TRIMSPOOL function. This is because table data has spaces also at the end of many lines.
For ex. if table row data is of length 150 with spaces at the end. I want to show file data with 150 characters only.
Not 170 as set in linesize
SET LINESIZE 170
spool &data_file_full_path
select data
from <table_a>
where file_id = 1001
order by line_number;
spool off
Hi,
TRIMSPOOL controls whether or not SQL*Plus adds spaces after the last column of your data.
Use RTRIM to remove trailing spaces from the last column of your data, like this:
SET TRIMSPOOL ON
spool &data_file_full_path
select RTRIM (data) AS data
from <table_a>
where file_id = 1001
order by l ine_number;
spool off
Similar Messages
-
':' in SQL Format causes analysis auth failure
Hi,
When running a SEM-BPS planning folder it fails due to analysis authorisation errors. On doing a trace it fails as the SQL Format has PLANT = ':' and SALESORG = ':'. These values are not within the analysis auths set-up.
Talking to the SEM-BPS person here they don't know how those got into the query.
Any ideas how we can get round this?
Thanks,
Nick.hello,
does oracle showing any errors in user_scheduler_job_run_details for this job ? I would advise try inserting some debug statement to identify where exactly its stuck. Also please check sample configurations syntax for user_scheduler_jobs.
Cheers
Sush -
Why this strange behaviour in sql*plus linesize?
Friends,
when i set the linesize above 200 the result is going out of my 17inch monitor. but when i set the linesize to 100 its displaying correctly. This linesize i tested with the "desc tablename"
here is the output....
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 12 11:40:54 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show linesize
linesize 80
SQL> desc emp
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> set linesize 200
SQL> desc emp
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)how to solve this?
Thanksmay be the sqlplus 8 makes the difference.....
SQL*Plus: Release 8.0.5.0.0 - Production on Thu Jul 12 13:46:4 2007
(c) Copyright 1998 Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> select * from cat;
TABLE_NAME TABLE_TYPE
BOOKS TABLE
DBO TABLE
IPMAST TABLE
ISPMST TABLE
SQL> desc books
Name Null? Type
BKID NUMBER(38)
BKNAME VARCHAR2(10)
SQL> show linesize
linesize 100
SQL> set linesize 700
SQL> desc books
Name Null? Type
BKID NUMBER(38)
BKNAME VARCHAR2(10) -
Convert smalldatetime type SQL format to Date in OBIEE
I have a SQL database which holds date in the smalldatetime type SQL format. I want to read this date in the OBIEE. How I can achieve this. I didn't find any direct CAST for this OBIEE Answers.
thanks,
Nareshsorry to confuse here. I would reframe my question as following
Hi,
I have a data in SQL Database which is in ‘float’ format. The data is being stored for TimeStamp such that casting it for ‘smalldatetime’ gives the exact timestamp in SQL Server.
For example I have dates (dTime) column and the converted columns when did casting for smalldatetime gives following result (in SQL Server)
dTime (Float) ########################## small_date_time (CAST dTime AS smalldatetime)
40322.271099537 ########################## May 26 2010 6:30AM
40322.275706018503 ########################## May 26 2010 6:37AM
40415.121770833299 ########################## Aug 27 2010 2:55AM
Now problem is I have this (dTime) column coming as Double in OBIEE and when I’m trying to convert this to TIMESTAMP/DATE it gives error.
To Simplify I tried following query in Answers directly.
CAST(CAST('40322.271099537' AS CHAR) AS TIMESTAMP)
and the error shown is below
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 46046] Datetime value 40322.271099537 does not match the specified format. (HY000)
Do we have a way to get the format right by using cast or any other function.
Edited by: naresh kumar on Oct 20, 2010 2:25 AM
Edited by: naresh kumar on Oct 20, 2010 2:26 AM -
XML SQL format for Prepared statements in batch mode
Hi
I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
so i need to execute the prepared statements in one batch. Is the XML SQL format for prepared statements below correct ?to<root>
<stmt>
<Customers action="SQL_DML">
<access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
</access>
<key>
<NAME>IBM</NAME>
<ADDRESS>Street 3 </ADDRESS>
<KEYFIELD>CO</KEYFIELD>
</key>
<key>
<NAME>PWC</NAME>
<ADDRESS>Street 4 </ADDRESS>
<KEYFIELD>NO</KEYFIELD>
</key>
</Customers>
</stmt>
</root>
Please adviseHello Experts
Please throw some light on the above question.
Thanks in advance. -
Authorization log / Hierarchy node in SQL format
Hi!
I execute rsudo on a restricted user and the authorization log tells me that this fails because the user is not authorized for "Content(in SQL format): Node 5 8 0 31 E"
Now how do I translate this sql format into something I can read? I've looked through the hierachy tables for the relevant characteristic but I can only identify 31 as the hierarchy sid and E as the version.Vice -
We had to do basically the same thing for 0CRM_TR hierarchy, but our steps were a little different since we are on BI 7.0 - 2004S.
We also had to limit the users visibility to data from certain nodes and below on the hierarchy.
1st, we made the 0CRM_TR object auth releveant.
2nd, we created an analysis authorization for the object via transaction code RSECADMIN. In the transaction we had to specify the Hierarchy variable name that would be used in Queries. We then selected the node (GUID) where we wanted the authorizaion to take place. We set the Type Auth to 1(subtree and below) and Hierarchy Validity Area as 2(Name Identical). We set it to 2 since the Hierarchy would always be loaded in the same name. -
How can i make sql formated report
sql formated report..
empno month sal
10080 500
1000
2000
10020 100
50
will you please give the way...Hi, for make a formated report you will must configure the SQL Plus enviroment, you can review the next link for set the values according at your requirements.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12040.htm#SQPUG083
Luck.
Regards. -
How to generate .SQL format file from oracle database?
How to generate .SQL format file from oracle database?
I have a database of Oracle 8.1.6,now want to generate script file (including table structure,index,etc.) from it,What should I do?
Thanks.Your question pertains to the Database Export/Import. This forum exclusively focusses on the export/import utilities that come along with "Oracle Portal" which is a web-based tool. Could you please post your question under the RDBMS export/import or migration forum.
-
how to convert a date in string format to sql date format?
thanx in advanceUse java.text.SimpleDateFormat to parse the String into a java.util.Date.
Create a java.sql.Date from the java.util.Date.
Use a PreparedStatement and its setDate() method to set the date in the SQL. The JDBC driver will take care of putting that java.sql.Date object into the correct format for your DB. -
PL/SQL formatting with JDeveloper 10g?
Cant it be true? Is there no freeware tool for formatting
PL/SQL?
I looked here
http://www.oracle.com/technology/products/jdev/htdocs/partners/index.html
but the formatting tools are for Java not PL/SQL....Cant it be true? Is there no freeware tool for
formatting
PL/SQL?
I looked here
http://www.oracle.com/technology/products/jdev/htdocs/
partners/index.html
but the formatting tools are for Java not PL/SQL....For now, you would be correct. Google for "Oracle Raptor"
- Rob -
SQL Format Question (sorry about the previous post)
I'm trying to create a query that will produce the following output:
DNAME ENAME
ACCOUNTING CLARK, KING, MILLER
RESEARCH SMITH, ADAMS, FORD, SCOTT, JONES
SALES ALLEN, BLAKE, MARTIN, JAMES, TURNER, WARD
As opposed to this basic query:
SQL> get test.sql
1 break on dname
2 select dname, ename
3 from dept, emp
4 where emp.deptno=dept.deptno
5* order by dname
SQL> start test.sql
DNAME ENAME
ACCOUNTING CLARK
KING
MILLER
RESEARCH SMITH
ADAMS
FORD
SCOTT
JONES
SALES ALLEN
BLAKE
MARTIN
JAMES
TURNER
WARD
Any suggestions on how to accomplish this?
Thanks in advance!-- Here is one way to do it in Oracle 8i:
-- First, run the script below to create
-- a concatenation funciton:
CREATE OR REPLACE FUNCTION concatenate
(p_col1 IN VARCHAR2,
p_table IN VARCHAR2,
p_col2 IN VARCHAR2 DEFAULT '1',
p_value IN VARCHAR2 DEFAULT 1,
p_delim IN VARCHAR2 DEFAULT ', ')
RETURN VARCHAR2
IS
TYPE cursor_type IS REF CURSOR;
c1 cursor_type;
v_sql VARCHAR2 (4000) := NULL;
v_temp VARCHAR2 (1000) := NULL;
v_concat VARCHAR2 (1000) := NULL;
v_delim VARCHAR2 (3) := NULL;
BEGIN
v_sql :=
' SELECT ' || p_col1
|| ' FROM ' || p_table
|| ' WHERE ' || p_col2 || ' = '''
|| p_value || ''''
|| ' ORDER BY ' || p_col1;
OPEN c1 FOR v_sql;
LOOP
FETCH c1 INTO v_temp;
EXIT WHEN c1%NOTFOUND;
v_concat := v_concat
|| v_delim
|| v_temp;
v_delim := p_delim;
END LOOP;
CLOSE c1;
RETURN v_concat;
END concatenate;
--Then to use the function in a query:
COLUMN enames FORMAT A50 word_wrapped
SELECT DISTINCT dname,
concatenate ('ename', 'emp',
'emp.deptno', emp.deptno) enames
FROM dept, emp
WHERE emp.deptno = dept.deptno
ORDER BY dname, enames
-- results:
DNAME ENAMES
ACCOUNTING CLARK, KING, MILLER
RESEARCH ADAMS, FORD, JONES, SCOTT, SMITH
SALES ALLEN, BLAKE, JAMES, MARTIN, TURNER, WARD -
I am using a java program to retrieve information from Oracle Database.
The valus is stored in a result string and printed to file. I want to pad the number with leading zeros.
sql command: SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345';
This returns the value in the format that I need: 000121345
When attempting to run this statement through java I get:
column not found error.
Does anyone know of a better way to format using java?Are you using:
String Sql="SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345';".
You should omit the ; in the string.
Try to use :
String sql="SELECT LPAD(PAS_ID,9,'0') FROM PA_COURSES WHERE PAS_ID = '121345'". You should be ok
null -
HOW do I turn off SQL Formatting for existing objects?
SQL Developer's formatting does not match mine and is driving me mad.
My version is 2.1.1.64.
I create a view, I run it in a database, I look at in in SQL Developer ...
The SQL tab shows everything every which way.
I have tried all the options.
ALL I WANT is to see the code just as I ENTERED IT ...
Instead, I get all my column names in quotes (I HATE quotes!!!!!!!)
and it aligns things, no matter how I tell it to turn off stuff.
I want to see ...
create or replace view XYZ (Col1, col1, col3 ... coln) as
select a.yadda, zeda,
(select b.yadda_desc from somewhere where b.yadda=a.yadda) as col3,
something_else, ... more things as col N
from somewhere a
where something=true;
BUT INSTEAD I SEE THIS ...
create or replace view "schema"."XYZ" ("Col1", "col1", "col3" ... "coln") as
select a.yadda, zeda,
(select b.yadda_desc
from somewhere
where b.yadda=a.yadda
) as col2, something_else,
... more things as Col N
from somewhere a
where something=true;
and it insists on wrapping the columns and subselects and function calls in some willy-nilly way.
I just want it to stop .... no quotes, no schema, wrap the text the way I entered it.
How can I get it to do that?
Please help me, please ...Hi
I'm having the exact same problem with SQL Dev 2.1.64
Don't recall this ever happening before, looked through all possible options/preferences and no luck.
I completely agree, this default formatting really gets on your nerves specially if your source is quite large and you need to preserve the code formatting in a very structured and clear way!.Anyone found out how to prevent this? im considering rolling back to one of the not so stable previous versions.
E.g... i compile it like this
SELECT DISTINCT
F.DEVICE,
SUBSTR(F.PROD_TYPE,1,6) B_TYPE,
F.INBOUND_BNR BNR_INBOUND,
F.COUNTRY_OF_ORIGIN
FROM (SELECT DISTINCT C.LOT AS LOT,
c.inbound_bnr AS inbound_bnr,
C.PROD_TYPE AS PROD_TYPE,
FROM (SELECT DISTINCT
A.TRANS_DATE AS TRANSD,
a.lot_number AS lot,
a.quantity_1 AS waf_qty,
and after compiling i get this
SELECT DISTINCT F.DEVICE DEVICE, -- ' ' DEVICE,
SUBSTR(F.PROD_TYPE,1,6) B_TYPE,
F.INBOUND_BNR BNR_INBOUND,
FROM
(SELECT DISTINCT C.LOT AS LOT,
C.WAF_QTY AS WAF_QTY,
c.die_qty AS die_qty,
FROM
(SELECT DISTINCT A.TRANS_DATE AS TRANSD,
a.lot_number AS lot,
a.quantity_1 AS waf_qty,
FROM sf_movem_move a,
(SELECT DISTINCT pred_bnr_1 AS labbnr,
PRED_BNR_1 AS INBB,
bnr AS outbb,
FAC -
Explain sql format and OpenSQL
Hi!
My problem is that if I want to use the "Enter SQL statement" functionality of st05, I have to enter my sql commands in a different format, than in my abap code.
The format in the abap code:
select * from sbook as a inner join scarr as b on acarrid = bcarrid
The format of st05:
SELECT T_00 . *
FROM "SBOOK" T_00 ,
"SCARR" T_01
WHERE ( T_01 . "MANDT" = '000' AND T_00 . "CARRID" = T_01 . "CARRID" ) AND
T_00 . "MANDT" = '000'
1, Is there a converion FM for this? How could I know the "explain format", without running st05 and executing my command?
2, Where can I find a log of SQL commands, that were actually sent to the database engine?
Actually this is not an Oracle specific problem, but I found no "general" database related forum.
thanks,
TamasHello,
Abap code is "generic", it does not depend on the database that is running below ( SQL Server, Oracle, MaxDB, DB2/6 )
But each of the mentioned databases can have a slightly different way of implementing the "SQL". The kernel will perform a transformation between the "generic" abap code and the specific database ( the database interface does it )
I do not think there is an easy way of knowing exactly how the transformation will be done as it does depend on several things, like SAP parameters.
As far as I know, the only way of knowing the exact methond to see the SQL parameters sent to the DB is to enable a trace.
From SAP an SQL trace with ST05.
From the DB, it can also be enable some tracing options.
But tracing everything can be "overkill", therefore, I would only do an ST05 trace for the specific transaction/report to be studied. -
SQL format in SQL tab for SQL developer v2.1.1.64
I have been using Toad for years, recently we moved to SQL Developer. However, can anyone tell me how to make SQL in SQL tab looks like in TOAD, I have an example as below. Thanks at advance!
in SQL Developer:
CREATE TABLE "SCHEMA"."F1005"
"FID" NUMBER(*,0) NOT NULL ENABLE,
"NUMOFPTS" NUMBER(*,0) NOT NULL ENABLE,
"ENTITY" NUMBER(*,0) NOT NULL ENABLE,
"EMINX" FLOAT(64) NOT NULL ENABLE ,
"EMINY" FLOAT(64) NOT NULL ENABLE ,
"EMAXX" FLOAT(64) NOT NULL ENABLE ,
"EMAXY" FLOAT(64) NOT NULL ENABLE ,
"EMINZ" FLOAT(64) ,
"EMAXZ" FLOAT(64) ,
"MIN_MEASURE" FLOAT(64) ,
"MAX_MEASURE" FLOAT(64) ,
"AREA" FLOAT(64) NOT NULL ENABLE ,
"LEN" FLOAT(64) NOT NULL ENABLE ,
"POINTS" LONG RAW ,
CONSTRAINT "F1005_PK" PRIMARY KEY ("FID") DISABLE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "SCHEMA_FEATURE_SML_DATA" ;
CREATE INDEX "SCHEMA"."F1005_AREA_IX2" ON "SCHEMA"."F1005"
"AREA"
PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "SCHEMA_FEATURE_SML_INDX" ;in TOAD
CREATE TABLE SCHEMA.F1005
FID INTEGER NOT NULL,
NUMOFPTS INTEGER NOT NULL,
ENTITY INTEGER NOT NULL,
EMINX FLOAT(64) NOT NULL,
EMINY FLOAT(64) NOT NULL,
EMAXX FLOAT(64) NOT NULL,
EMAXY FLOAT(64) NOT NULL,
EMINZ FLOAT(64),
EMAXZ FLOAT(64),
MIN_MEASURE FLOAT(64),
MAX_MEASURE FLOAT(64),
AREA FLOAT(64) NOT NULL,
LEN FLOAT(64) NOT NULL,
POINTS LONG RAW
TABLESPACE SCHEMA_FEATURE_SML_DATA
PCTUSED 40
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
NOLOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE INDEX SCHEMA.F1005_AREA_IX2 ON SCHEMA.F1005
(AREA)
NOLOGGING
TABLESPACE SCHEMA_FEATURE_SML_INDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
NOPARALLEL;Thanks for your reply, however, there are not any vendors call TOAD...
The actual problem are:
1. Do not show double quote (""), ie:
in SQL Developer
CREATE INDEX "SCHEMA"."F1005_AREA_IX2" ON "SCHEMA"."F1005"in TOAD
CREATE INDEX SCHEMA.F1005_AREA_IX2 ON SCHEMA.F10052. has a break after numbers, ie:
in SQL Developer
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
)in TOAD
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
)Any suggestions will be appreciated.
Thanks,
Maybe you are looking for
-
Urgent, how to refresh a form with a returned parameter?
Hi people, I am working in web application using EJB and ADF. In the main page I have a form and a "search" button. The "search" button opens a popup window that displays the same form's data in a table with selection and submit. I want to choose a r
-
Changing Mobile Hotspot password
Hi - I am having difficulty changing the default password for Mobile Hotspot. I cannot find anywhere to do this in the app, my phone, or My Verizon. Does someone know how to do this? Lisa
-
Reference point in Non Cumulative
Hello , What is reference point which is used inventory? If i compress with Marker update option enabled and if want to see the values for the previous month after compression will it give the previous month value or how it will be? Thanks in advance
-
Problem reading all data from Synchronous Socket
Hi, I have the task to implements an C# application which communicates with a SAP system via HTTP. My application should act as a HTTP Server to the SAP system. SAP sends documents (PDFs, Word-Docs, Tifs) through HTTP-Requests to my Server. Archive L
-
Mixed/multipart Request with a image file and a amr audio file
Hi people I am struggling with multipart/mixed request as i am new to java and http. I basically have to write a java code to send a request with two attachments, an audio amr file and a image file of a proprietry format. following is my code public