SQL & PL/SQL :: Display A Value In Between Single Quotes?

Nov 18, 2011

how to write a select query to display a number column value in between single quotes. Ex:i have a emp table in that sal column is a number type.

Ex:
select sal from emp;
sal
----
1234
231
3456
3211
23445I want to display the same above result in b/w single quotes.

ex:
sal
----
'1234'
'231'
'3456'
'3211'
'23445'
for this i need to write a query,

View 5 Replies


ADVERTISEMENT

PL/SQL :: How To Replace 2 Single Quotes To Single Quote

Nov 21, 2012

I have an script.sql that receives as a parameter an string.

example:

@C:/myscript.sql "o'connor"

user_account_value varchar2(120) := '&1';

EXECUTE IMMEDIATE "Select * from Table where column = :1 "  USING user_account_value I am not sure how to deal with string that contains single quotes.

If the parameter were passed as : "o''connor" this will work
If the parameter is pass as: "o'connor" this will not work.

so my question is what options do I have to deal with dynamic queries and single quotes.

I tried replacing replace(myParameter,'''',''''''); but not working well.

View 11 Replies View Related

SQL & PL/SQL :: Inserting Single Quotes

Dec 4, 2012

I have a string: 'VOLT,AGE'..

How can I convert this string to: 'VOLT','AGE' using REGEXP_REPLACE...

I am having trouble escaping the single quotes in my query

View 6 Replies View Related

SQL & PL/SQL :: Concatenate A Comma But Not Single Quotes

Oct 8, 2010

In table_A , the primary key is Col_A which is of data type number.I want to concatenate it with ' '

Col_A
______

123
124

select '|| col_A ||'||','
from
Table_A;

The output should be
'123',
'124'

I can concatenate a comma but not single quotes.

View 3 Replies View Related

PL/SQL :: SYSDATE In DDMMYYYY Inside Single Quotes

Dec 4, 2012

I have a requirement like:

Create Table A
( a number,
CreationDate DATE)
PARTITION BY RANGE (CreationDate)
(
Partition p_03122012 VALUES LESS THAN (TIMESTAMP' 2012-12-04 00:00:00'),

[Code]...

NOTE: Partition are named as p_ddmmyyyy where ddmmyyyy is date.

select * from dba_tab_partitions where table_name = 'A'

Now my requirement is :

select * from dba_tab_partitions where table_name = 'A' and partition_name > 'p_ddmmyyyy' (Here I want ddmmyyyy to be from sysdate i.e. date we get from - Select to_char(sysdate,'ddmmyyyy') from dual
i.e. for today it becomes
select * from dba_tab_partitions where table_name = 'A' and partition_name > 'P_04122012'

So it returns me two rows.

How can I do it in single quotes.

View 6 Replies View Related

SQL & PL/SQL :: Query On Single Column To Display As Rows

Aug 5, 2010

I has a table of structure of varchar2 datatype.

NO
----------
1-2
3-4
5-6

desired output is:

SQL>1
2
3
4
5
6

The table has single column & the values may differ,that is, they may have 1-2-3-...-n in a single row, but the desired output is to be in the rows as shown above.

I tried concepts of SQL up to my knowledge, but I failed. The query to be done only in SQL.complete this query.

View 10 Replies View Related

Fetch Records In Single Select Query And Display

Mar 15, 2011

I have 3 tables, Emp(Emp_id,emp_name),dept(dept_no,dept_name),emp_dept(emp_id,dept_no). Emp tabl ehas some 20 employes id who belongs to different departments.There are few employee who belongs to multiple departments as well. I want to fetch records of emp_id, emp_name, dept_no in the following format.

Name id dept_no
Ram 101 10
20
30
Ani 201 10
20

View 1 Replies View Related

Forms :: Display Report With Parameter Using Single Button

Jul 14, 2008

From my form with a single button i need to display a report with a paramter. Report is displaying fine but the parameter is not getting passed. I did the following behined my button i add this

DECLARE
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
plid ParamList;
vParamValue number := 20;

[code]...

If i remove the where condition the whole table data start appearing in the report but adding where condition is not accepting 20 as i send from the FORM Button. And the report with blank data appeared with column headings.

View 5 Replies View Related

Reports & Discoverer :: Formatting - Display Value Of Field In Single Line

Oct 20, 2010

I have developed one report but need one formatting suggestion. There is one field called "DESCRIPTION", I want the value of this field to be displayed in a single line. Now the big values are wrapped into multiple line.

Now,

DISPLAY
----------------
This is a Oracle
Report.

I want,
DISPLAY
------------------------
This is a Oracle Report.

Maximum size of "DISPLAY" field is VARCHAR2(240).

View 3 Replies View Related

SQL & PL/SQL :: Display Office Address / House Address And Emp ID In Single Query?

Feb 23, 2013

I have two tables emp , emp address as below

emp table :
emp_id emp_name,
1 rajesh
2 suresh

emp address table :

emp id emp_addresstype emp address
1 O kukatpally
1 H Hitech
2 O Kolkata
2 H hydar nagar

I need the query to display the Office address & House address & emp id in single query

ex: 1,Kukatally,hitech
2,kolkata,hydarnagr

View 3 Replies View Related

SQL & PL/SQL :: Using Apostrophe / Quotes In A String

Feb 9, 2011

Here is a sample function which takes in a string of CSV fields and prints the third field :

create or replace function restr(istr varchar2) return INTEGER
is
var_1 varchar2(30);
begin
dbms_output.put_line('input:'||istr);
select regexp_substr(',' || istr,1,3,null,1) into var_1 from dual;

[Code]..

When I pass an input string as :

JOHN,MARY,O'DONNEL,O'CONNELLY,MARK

with quotes/apostrophe in it to the function then it prints the input string in the first dbms_output but errors out at the select with ORA-01760.

how we can use the quote/apostrophe character here ?

View 6 Replies View Related

PL/SQL :: Embedding Quotes In Strings?

Aug 16, 2013

In the code segment below (hope it appears right) I can understand the use of single quotes in the first two examples but in the third example below I had to use double quotes around the word - Today's - and I not sure I understand why?! I'm aware of the rules ...If you want a single quote to appear in the middle of a string add another single quote to it.If you want a single quote to appear at the beginning or end of a string add 2 single quotes to it.If you want a single quote to appear on its own add 3 single quotes to it. 

SQL> select 'This isn''t' from dual;
'THISISN''
----------
This isn't
SQL> select to_number('34@456#789', '999G999D999', 'nls_numeric_characters=''#@'' ') from dual;
TO_NUMBER('34@456#789','999G999D999','NLS_NUMERIC_CHARACTERS=''#@''')
---------------------------------------------------------------------
                                                            34456.789
SQL> select to_char(sysdate, 'fm"Today''s" ddth Month YYYY') from dual;
TO_CHAR(SYSDATE,'FM"TODAY''S"DDTHMONTHYYYY')
------------------------------------------------------
Today's 16th August 2013

View 12 Replies View Related

SQL & PL/SQL :: Show Value Of Variable In Double Quotes?

Dec 4, 2011

declare
v_a varchar2(2000) := 'abcd';
v_e varchar2(2000) := '6666';
v_d varchar2(2000) := 'example';
v_final varchar2(4000);
begin
v_final := '"v_a"'||'''|'''||'"v_e"'||'''|'''||'"v_d"';

-- v_final := '"v_a"';

dbms_output.put_line('v_final: '||v_final);

end;
/

above gives me :

v_final: "v_a"'|'"v_e"'|'"v_d"

so it is printing the variable names, But I want to see values, like this: "abcd"|"6666"|"example"

View 6 Replies View Related

How Many Quotes To Use In Dynamic Query Using IN Clause With String

Nov 23, 2011

I have a dynamic query which has this clause in it: WHERE [COLUMN NAME] IN (' || theString || ')

My problem is that theString is being passed in through a C# call and the variable is a bunch of strings concatenated together and separated by a comma. Ex: theString = "'val1','val2'"

How many quotes are supposed to go around val1 and val2?

I've tried the following and none work:
'val1','val2'
''val1','val2''
''val1'',''val2''
'''val1'',''val2'''
''''val1'',''val2''''

When I run the procedure in Oracle it works with '''val1'',''val2'''

View 1 Replies View Related

SQL & PL/SQL :: Adding Quotes Around Field Only If Comma Exists Within

Mar 25, 2010

I searched the forum but could not find an answer. I am creating an extract via SPOOL that will send the output to a CSV file. I am comfortable concatenating commas in between the fields, the problem lies in text fields such as last_name which may contain a comma. The requirements of my client state to put double quotes around text fields ONLY if they contain a comma (so as not to throw off the CSV file obviously).

The only thing I could think of was a nested DECODE checked every character of every text field for a , and if it finds one to put " and if not to put nothing. This would get very tedious to program it as there are many text fields and they can be very long. I may even run out of nested DECODE statements (I forget what the limit is now).

View 9 Replies View Related

Server Utilities :: Loading String Has Double Quotes In It?

Aug 22, 2013

I am loading .csv file into Oracle using sql loader file has strings, and numberics, Strings are surrounded by double quotes(") and field terminated by comma(,)

load data
BADFILE '/var/opt/app/bad/filename'
DISCARDFILE '/var/opt/app/discard/filename'
append into table source_file
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS

Some time String fields may have double quotes in it, at that time it is rejecting the records. how to handle those records to load into table.

View 3 Replies View Related

Server Utilities :: Sql Loader / How To Ignore Error Due To Quotes

May 5, 2010

I have control file written like

LOAD DATA
APPEND
INTO TABLE MYTABLE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS

but i have data in csv file like

660501,1,"0187591","12"PEGHOOKW/SA",,"04/03/2002",

Since there is an extra double quote (denoting inch) in the third column, im getting an error. Is there any way to avoid this error without modifying the csv file.

View 10 Replies View Related

SQL & PL/SQL :: Remove Spaces By Excluding Double Quotes From A String

Oct 29, 2012

I want to remove more than one space from a string by excluding double quotes.

For example:

I/P: Item .getChildByType(" Agreement").getParent( ) .hasChildByType("Agreement ")

O/P : Item.getChildByType(" Agreement").getParent().hasChildByType("Agreement ")

View 17 Replies View Related

SQL & PL/SQL :: Double Quotes In Column Name Can Be Replaced With Alternate Character?

Feb 14, 2012

Any way to replace the Double Quotes used to enclose column names with an alternative character. This is the SQL I have now that Works!

select (case when CUST is null then "/BIC/Z_SUPPLNT" else NM1 end) CMPNTSUPSRCE
from TBL1, TBL2
where "/BIC/Z_MAJVEND"=CUST(+) and Material = '1ABCD456'
order by Material

But would like to do something along these lines below but keep getting error "ORA-00936: missing expression".

select (case when CUST is null then chr(34)||/BIC/Z_SUPPLNT||chr(34) else NM1 end) CMPNTSUPSRCE
from TBL1, TBL2
where chr(34)||/BIC/Z_MAJVEND||chr(34)=CUST(+) and Material = '1ABCD456'
order by Material

View -1 Replies View Related

Server Utilities :: SQL Loader Loads All Fields With Double Quotes Into Staging Table

Aug 25, 2010

I am having a similar problem like above ONLY in UNIX box where my datafile is delimited by "|". The last field is ITM_CMNT declared as VARCHAR2(60) in Oracle. When I have exactly 60bytes in the last field it rejects the record saying actual 61 and max allowed is 60. If i reduce it to < 60bytes then it is stored as a value enclosed with double quotes. The enclosing double quote is on the next line.

"PROC,RAM,FLPY,HD,ACT MTX CLR DSP,D/PCMCIA,TRKBAL,LIT ION BA"

Expected: the one below is exactly 60bytes.

PROC,RAM,FLPY,HD,ACT MTX CLR DSP,D/PCMCIA,TRKBAL,LIT ION BAT
LOAD DATA
INFILE *
INTO TABLE TMPTLI_LAWSON_ITM_MST
TRUNCATE
FIELDS TERMINATED BY "|"
(ITM_NO, HAZ_MAT_CD, ITM_SHRT_DS, ITM_SON "TRIM(:ITM_SON)", ADDED_DT DATE "YYYY-MM-DD",
AVL_CD , ITM_CST_AMT, ITM_SLL_AMT,
EXCHG_PRC_AMT , ITM_UOM "TRIM(:ITM_UOM)",
PCK_QTY INTEGER EXTERNAL, SPC_HNDL_CD "TRIM(:SPC_HNDL_CD)", EFF_DT DATE "YYYY-MM-DD",
ITM_CMNT "TRIM(:ITM_CMNT)")

View 4 Replies View Related

Single Instance Non-Grid To Single Instance Grid Database

Aug 27, 2012

I'm trying to test moving a single instance 11202 database to single instance w/ grid infra.

Here is what I've done:

1. Install a database (11202), single instance and create a database
2. Install Grid Software only (user: grid)
3. start the cluster
4. "srvctl add database -d orclsidb -o $ORACLE_HOME" to register the database with grid.
4.1> I was able to start/stop the database with srvctl command here onwards
5. configure disks using asmlib and start the asm
6. "srvctl add asm" to register asm with grid.
7. PROBLEM ... when I try to "backup as copy database format '+ASM_DATA_DG';" from oracle user it errors out as below:

RMAN> backup as copy database format '+ASM_DATA_DG';

Starting backup at 24-AUG-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00011 name=/fs0/oracle/oradata/orclsidb/sjc883p_indx_large_01.dbf
RMAN-00571:

===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 08/24/2012 08:53:29
ORA-19504: failed to create file "+ASM_DATA_DG"
ORA-12547: TNS:lost contact
ORA-15001: diskgroup "ASM_DATA_DG" does not exist or is not mounted
ORA-15055: unable to connect to ASM instance
ORA-12547: TNS:lost contactConsidering "TNS: lost contact" I tried to see if grid listener is aware of ASM instance:

[Code]....

All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=usracdb03.rwcats.com)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                22-AUG-2012 06:08:53
Uptime                    2 days 2 hr. 50 min. 48 sec
Trace Level               off

[Code]....

View 10 Replies View Related

PL/SQL :: Display One Row Only

Apr 16, 2013

This query

SELECT
SCRATTR_ATTR_CODE
from scrattr_TEST,scbcrse_TEST
where
SUBSTR(scbcrse_subj_code,1,3)  = SUBSTR(scrattr_subj_code,1,3)
and SUBSTR(scbcrse_crse_numb,1,4)  = SUBSTR(scrattr_crse_numb,1,4)Returns this

SCRATTR_ATTR_CODE
A
INS
MCSR

How I can make to return someting like A INS MCSR in one row there is a row for every code

hERE is some code to create the tables and insert the data

CREATE TABLE SCRATTR_test
(
  SCRATTR_SUBJ_CODE      VARCHAR2(4 CHAR)       NOT NULL,
  SCRATTR_CRSE_NUMB      VARCHAR2(5 CHAR)       NOT NULL,
  SCRATTR_EFF_TERM       VARCHAR2(6 CHAR)       NOT NULL,
  SCRATTR_ATTR_CODE      VARCHAR2(4 CHAR)
 
[Code]....

View 1 Replies View Related

SQL & PL/SQL :: All Rows Value To Single Row

Jul 15, 2011

i want to all rows value into single rows.

for example;

Input data:
Sec_SSC_ID Column_nameAs of dateOld valu New Value
IBM Mat_dt 10/10/20101/1/2001 1/1/2002
IBM Bid Market 10/10/201075 85
IBM asset_nm 1/1/2011International IBM
MSFT asset_nm 1/2/2011Microsoft Intel
MSFT Bid Market price 1/1/201189 90

Output data

I have attached sample output file with it.

how to get this via sql?

View 8 Replies View Related

SQL & PL/SQL :: Getting All Data In A Single Row?

Jun 16, 2013

The query I do paste executes and gives the data needed. However, I do need all of these data in a one row.

SELECT
DECODE(BREINV1.NAMEKEY, NULL,'0','1') "BRE_INV1",
DECODE(BREINV1.NAMEKEY, NULL,' ',BREINV1.SEQUENCE) "BRE_NUMINV1",
DECODE(BREINV1.NAMEKEY, NULL, ' ', DECODE(BREINV1.SEQUENCE,NULL,NULL,RTRIM(ADDINV1.FORMATTEDADDRESS,CHR(0))||CHR(13) || CHR(10) ||'Citizen of ' ||SUBSTR(PAY1.COUNTRYDESCRIPTION,1,30))) "BRE_NOMINV1",

[code]....

What I get after executing it is a data with 4 columns and a number of rows unknown.

What I do want is to get all of these data in a one row with columns name sequence increasing 1 by 1.

Example(BRE_INV2, BRE_NUMINV2, BRE_PRENOMINV2 ...)

View 8 Replies View Related

SQL & PL/SQL :: From Columns To A Single Row

Sep 22, 2011

I need to make the following transposition:

from this:

CUST_IDPLAN_IDNOREM_M4M ADD_M4M

6871 1231Yes Yes
68711232Yes NULL

into this:

CUST_ID PLAN_ID REM_M4M1 REM_M4M2 ADD_M4M1 ADD_M4M2

6871 123 Yes Yes Yes NULL

View 18 Replies View Related

Single Job For Whole Assembly

Aug 14, 2012

Business should be able to issue a job whereby the sub assemblies do not have a different job number, however the job itself maintains the indentation (BOM levels). What we are looking to do is to issue one job for a full build of a product, which would be built in one go anyway.

View 4 Replies View Related

PL/SQL :: Returning A Single Row

Jun 5, 2013

I have a table which lists previous jobs, whcih has monthto,yearto, monthfrom and year from fields. I am trying to find the most recent job (of which they might be multiple ending on the same month) Initially, i did the following:

ran a sub query to find the most recent (employee id, max (yearto * 12 + monthto), then another query where I got a list of the most recent jobs, and returned the first one using rownum = 1 (note this may be inconsistent between runs as thee rownum is calculcated before nay ordering clause. This worked, but i figured using the first function might be better as it gives an order

select employee_id from
(select employee_id
,max(NVL(yearto,0) *12 + NVL(monthto,1)) KEEP (DENSE_RANK FIRST ORDER BY emloyer) as latest
from employees
group by employee_id;

but this seems to return more than one entrty:

table date below:
drop table employee_list;
drop table employee_historic;
[code]...

What is the best way to return a single row, if the primary key is not available / applicable.

View 9 Replies View Related

How To Display The Second MAX Value In A Table

Jul 31, 2007

a sample query to display second MAX value from the oracle database

View 1 Replies View Related

SQL & PL/SQL :: Display Zero If Negative Value

Jan 9, 2012

I am doing a Gross Profit percentage. I want to display zero if the GP% is have negative value.

for example

If GP% shows -75 I want to display as 0.

trunc((sum(total)-(sum(DECODE(po_pur,'',0,PO_PUR))+sum(DECODE(pl_pur,'',0,PL_PUR))+SUM(parts))) / SUM(DECODE(TOTAL,0,1,TOTAL))*100,2) "GP%"

View 2 Replies View Related

SQL & PL/SQL :: Display In Two Different Columns

Feb 1, 2013

Below is returning rows in single column.I need to display in two different columns

SELECT * FROM TABLE(PLUSER.SPLIT('a,b,c'))
union all
SELECT * FROM TABLE(PLUSER.SPLIT('1,2,3'))

this returning result like
a
b
c
1
2
3

but need abc in one column and 1,2 3 in one column
a 1
b 2
c 3

i was tried like

select * from TABLE(PLUSER.SPLIT('1,2,3')),(select * from TABLE(PLUSER.SPLIT('a,b,c')));

but it's giving cartesion result like below
1a
1b
1c
2a
2b
2c
3a
3b
3c

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved