How to put single quotes around selected data
Is there a way to return selected column value with single quotes around it?
Example I have a table:
select name from test_table;
returns: George Clooney
I want it to return 'George Clooney'
I tried: select '''||name||''' from test_table;
returns: '||name||'
...or
SCOTT@demo102> select chr(39)||ename||chr(39) from emp;
CHR(39)||ENA
'SMITH'
'ALLEN'
'WARD'
'JONES'
'MARTIN'
'BLAKE'
'CLARK'
'SCOTT'
'KING'
'TURNER'
'ADAMS'Nicolas.
Similar Messages
-
Put single quote around input data
Hi all,
DB:10G
Have an input field (P10_item) with text value . Sometimes it can be multiple text values separated by , like T-123,T-870 . sometimes it only has 1 text value.
How do I construct a query that can take the item and convert the input value to the following example ? By using length function I can find out how many check no in the field but am lost in how to put the ' around each check no. Help
ex:
select * from payment where checkno in ('T-123','T-870')
thankswith t as
(select 'T-123,T-870' txt from dual )
select replace(regexp_replace(txt,'(.+)','''\1'''),',',''',''')from t;
'T-123','T-870'sorry I did not understand what you wanted at first.
this shoud break p_10_item into multiple entries if it has commas in it and
then you can join it to the payment table.
WITH t AS (SELECT 'T-123,T-870' p_10_item FROM DUAL),
t2
AS ( SELECT REGEXP_SUBSTR (p_10_item,
'[^\,]+',
1,
LEVEL)
checkno
FROM t
CONNECT BY LEVEL <=
LENGTH (p_10_item)
- LENGTH (REPLACE (p_10_item, ','))
+ 1)
SELECT payment.*
FROM payment, t2
WHERE t2.checkno = payment.checknoEdited by: pollywog on May 18, 2011 1:14 PM -
SQL: Need help putting single quote around string
I want to put single quotes around string in my output.
I am running the following command as a test:
select ' ' hello ' ' from dual;
My expectation is to get 'hello' (Single quote around hello)
However I am getting the following error:
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
When I do SHOW ALL at my SQL command prompt, the escape is set as follows:
escape "\" (hex 5c)
I even tried: select '\'hello\'' from dual;
I get back: select ''hello'' from dual
ERROR at line 1:
ORA-00923: FROM keyword not found where expectedHi,
user521525 wrote:
I want to put single quotes around string in my output.
I am running the following command as a test:
select ' ' hello ' ' from dual;
My expectation is to get 'hello' (Single quote around hello)You probably read that you can get a single-quote within a string literal by using two of them in a row.
That's true, but they really have to be in a row (no spaces in between), and you still need the single-quotes at the beiginning and end of the literal.
So what you want is
SELECT '''hello'''
FROM dual;Starting in Oracle 10, you can also use Q-notation, For example:
SELECT Q'['hello']'
FROM dual; -
How to put single quotes inside single quotes
Hi all,
My requriement is to put a statement
LIKP~VSTEL <> INF
in a variable LV.
For that I have written
CONCATENATE LV 'LIKP~VSTEL <> "INF" ' INTO LV.
where LIKP is a table as VSTEL is a table field.
When this LV is used inside a select query, the value for LIKP~VSTEL is "INF", but I want without the double quotes. Can any one please help me with this.
Thanks and Regards,
AvinashHi,
Iif you mean LV should hold something like LIKP~VSTEL = ' INF ', then try this
data: c_quote(4) type c value ''''.
data: l_inv type string.
CONCATENATE c_quote 'INF' c_quote into l_inv.
CONCATENATE ' LIKP~VSTEL' '=' l_inv INTO LV separated by space.
Regards,
Vikranth.
Edited by: Vikranth.Reddy on Sep 1, 2009 1:55 PM -
Single quotes around a variable
Hi,
I have values that are being passed into a variable with single quotes around.
for eg: 'test'. So the value in variable v_empname will hold the value 'test'
But then below sql statement returns null:
select empid
into v_empid
from emp where empname = v_empname
When I checked the value of the variable it's 'test' and compared as '''test'''.
How can I get around this?
Thanks for the help.
SK.Doh!
SQL> create or replace procedure get_empno (i_name in varchar2)
2 as
3 v_empno number;
4 begin
5 select empno into v_empno
6 from emp
7 where ename = i_name;
8 dbms_output.put_line('empno is '||v_empno);
9 exception
10 when no_data_found then
11 dbms_output.put_line('No such person, or did you mean '||upper(i_name)||'?');
12 end;
13 /
Procedure created.
SQL>
SQL> set serveroutput on
SQL> exec get_empno('king');
No such person, or did you mean KING?
PL/SQL procedure successfully completed.
SQL> exec get_empno('KING');
empno is 7839
PL/SQL procedure successfully completed. -
Place single quote around string
Hi,
I am wondering how I can Place single quote around string in the following. I have tried double and triple quote but it doesn't take variable name from rec.tablename.
any idea
rec.table_name ==> 'rec.table_name'
rec.column_name ==> 'rec.column_name'
v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ' || rec.table_name ;
execute immediate v_sql;
-- Insert Table Record in Sdo_User_Geom_Metadata
v_sql:= 'INSERT INTO USER_SDO_GEOM_METADATA(TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) ' ||
'VALUES (' || rec.table_name || ',' || rec.column_name || ', MDSYS.SDO_DIM_ARRAY( ' ||
'MDSYS.SDO_DIM_ELEMENT(''X'',-2147483648, 2147483647, .000005), ' ||
'MDSYS.SDO_DIM_ELEMENT(''Y'',-2147483648, 2147483647, .000005)), 2958)' ;
execute immediate v_sql;
NancyI have 2 suggestions, 2nd one being the better choice.
SQL> set serveroutput on
SQL>
SQL> declare
2 v_sql varchar2(4000);
3 table_name varchar2(4000);
4 begin
5 table_name := 'MY_TABLE';
6 v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ''' || table_name || '''';
7 dbms_output.put_line(v_sql);
8 end;
9 /
DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= 'MY_TABLE'
PL/SQL procedure successfully completed
SQL> or using DBMS_ASSERT for a more elegant solution against SQL injection:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as fsitja
SQL> set serveroutput on
SQL>
SQL> declare
2 v_sql varchar2(4000);
3 table_name varchar2(4000);
4 begin
5 table_name := dbms_assert.QUALIFIED_SQL_NAME('ALL_TABLES');
6 v_sql:= 'DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= ' || dbms_assert.ENQUOTE_NAME(table_name);
7 dbms_output.put_line(v_sql);
8 end;
9 /
DELETE USER_SDO_GEOM_METADATA WHERE TABLE_NAME= "ALL_TABLES"
PL/SQL procedure successfully completed
SQL> [Docs referencing validation checks against SQL injection|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm#LNPLS648]
Regards,
Francisco -
I loaded my ipad photos from camera and all the pictures sorted by date. I later sync my ipad with my computer and the photos were all reorganized into IMPRT folders an out of date sequence. Any idea how to put the photos back into date files other than reloading all of them from camera?
What version of iPhoto?
Select one and rotate it. Then rotate it back. Does that make it appear?
A much better work flow is the keep the photos after importing. Check the success the import, wait for at least one successful backup cycle then use you camera's format command to reformat the card
LN -
Putting Single Quote in any field
Hi All,
What is the purpose of putting ' ' (Single Quote) in any of the field?
Example:
Object:F_BKPF_BUK
Field:
ACTVT:01
BUKRS:' ' -
> What does this imply?Hi,
what do you mean by 'single quote'? If you mean 'blank', this has the same meaning as an empty value in the field. So if the application checks for any value, but not for an empty field, the check will fail.
Regarding the docu: you can access it through some different ways, for instance in SE38->display source code of any report->press the blue 'I' infobutton->enter ABAP key-word authority-check, select authority-check->abap statement, enjoy the documentation.
b.rgds, Bernhard
Edited by: Bernhard Hochreiter on Sep 15, 2008 3:31 PM -
How to put a check with the date
Hi,
I have created a ztable with 3 fields .
clientcode(3),
date,--date geneated
version--- fileversion
i need to update this table everytime i execute the data. Every time version shd get incremented when i execute the program. When i excute the program next day version shd be updated by '1'.
i wrote the code for version updated i'm not getting the logic how to put a check with the date.
SELECT *
FROM zfi_enetflver
INTO TABLE gt_flver.
SORT gt_flver DESCENDING.
CLEAR: gv_dt, v_file.
CONCATENATE sy-datum6(2) sy-datum4(2) INTO gv_dt.
READ TABLE gt_flver WITH KEY client_code = gv_clcd.
IF sy-subrc = 0.
idx = sy-tabix.
IF gt_flver-zdate = ' '.
gt_flver-zdate = sy-datum.
ENDIF.
IF gt_flver-version = ' '.
gt_flver-version = '001'.
gv_filever = gt_flver-version.
MODIFY gt_flver INDEX idx TRANSPORTING zdate version.
MODIFY zfi_enetflver FROM TABLE gt_flver. "TRANSPORTING version.
CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
ELSE.
gt_flver-version = gt_flver-version + 1.
gv_filever = gt_flver-version.
MODIFY gt_flver INDEX idx TRANSPORTING version.
MODIFY zfi_enetflver FROM TABLE gt_flver .
CONCATENATE 'E:\' 'ENET\' gv_clcd gv_dt '.' gt_flver-version INTO v_file.
ENDIF.
ENDIF.
clientcode is the key field in ztable do i need to make date field key ??
please help me with the logicYou need to implement below logic:
1. check if field_date = sy-datum. in this case do nothing.
2. else . move sy-datum to field_date .
3. modify your internal table with field_date .
4. populate final table to database table .
hope you get it. -
How to put OR clause in SELECT statement
Hi
How to put OR clause in SELECT statement to return number_first/number_last to match records from another table's column.
<pre>
SELECT
a.id ,
flat_number ||' '|| a.number_first||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
</pre>
Thsi will return this as exact match.
ADDRESS 1
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
ADDRESS2
12 TAMAN TENANG A ORCHARD 3142
10 RAMA YISHUN 2095
However this only matches number_first.
How can I get the query work that it will match both number_first and number_last (table b)in address 1 to match street_no in address2 ( table b).My oracle version is 10GR/2.Hi, I have a hard time understanding your request, and below is what I thought you want:
SELECT
a.id ,
flat_number ||' '|| (decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last)||' '||a.street_name||' '||a.suburb address1,
apt_no ||' '|| street_no||' '||b.street_name||' '||b.suburb address2
from
a ,
b
where b.street_name = a.street_name
AND b.SUBURB = a.SUBURB
AND b.STATE = a.STATE
AND (B.street_no=a.number_first OR b.street_no=a.number_last);Not tested.
Also, since your B.street_no will be either a.number_first OR a.number_last, you could replace
(decode(b.street_no, a.number_first, a.number_first, a.number_last, a.number_last) with just b.street_no.
Edited by: PhoenixBai on Aug 26, 2010 11:33 AM -
how to put continuos (desired format) of dates in numbers spreadsheet and how to do it? please reply asap i need it..
This is the definition for "continuo" from Apple's dictionary:
continuo |kənˈtinyəˌwō | (also basso continuo) noun (pl. continuos) (in baroque music) an accompanying part that includes a bass line and harmonies, typically played on a keyboard instrument and with other instruments such as cello or bass viol.
Presumably you mean something else. Your chances of getting replies that can help you will improve with a clearly stated question.
SG -
How to concatenate single quote with any field like 'VBAK'
Hi,
How to concatenate single quote with any fields.
say for example I have table name as MARA, I have to pass that table name to other fields with single quote , like I have to pass that as
tab name = 'MARA'.
but how to do this,
below statement will not work
concatenate ''' 'MARA' ''' into string.. it's giving syntax error...
Regards,
Mrunalgv_name = 'MARA'.
gc_quote = '''.
CONCATENATE gc_quote gv_name gc_quote INTO value.
Pushpraj -
How to handle single quote between two single quotes in ABAP?
Dear SAP Gurus
I have a question regarding handling a string data.
Say I have a string ABCD'\&%$!!ABC'AAA123. Please notice that there are single quotes in my string.
I am writing a parser code in ABAP and getting into problem with if statement to check if the character read is a single quote.
When I type the following with a singleQuote between 2 singleQuoes as below, it gives error.
If CHAR = '''.
ENDIF.
How do I handle that? I searched for escape sequence and couldn't get any useful info.
Any feedback will be highly appreciated.
Thanks
RamOr just use string literals
if char = `'`. "note that ` is the "backquotation" mark not a regular quotation mark '
Regards
Marcin -
How to insert single quote in to the table
Pl help me out in how to insert the single quote ie ' into the table. If there is no other way, i will go for some other alternative
Regards,
BasavarajuSQL> desc varchar2_test
Name Null? Type
TEXT VARCHAR2(4000)
SQL> insert into varchar2_test values ('''ABCDEFGHIJ''');
1 row created.
SQL> select * from varchar2_test;
TEXT
'ABCDEFGHIJ'Thanks,
BB -
How to replace single quote with double quote
hai all,
i have a problem,
i am trying insert a string containing single quote into ms-access database.
it is giving error.
how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
insert into database.
in java.lang.String
replace () will not work to replace quote with double quote.
any otherway to solve this problem.
please mail me to [email protected]
thank you
sambareddy
inidajava.lang.String.replace () will not work to replace quote with double quote.Really?
String x = ...
x.replace( "'", "\"" );
Maybe you are looking for
-
Ipod is not recognized by iTunes and will not sync
When trying to sync my ipod up with iTunes, it is not recognized as a device by iTunes and cannot be synced up. Any ideas? Thanks.
-
Proxy output not displayed in the output XML
Hi, I have created a web service and is calling the service using SOAP UI tool. To do it i have created an RFC Fm and inported to SAP PI and activated it with the input and output parameters that i need. When i am calling the service through the SOAP
-
Material ledger tick in material master
hi i have created material master Number ABC. Make changes in material type and activated material ledger. Now ML tick is on all new material master being created its fine. Question is how I can activate the ML tick on material number ABC which creat
-
[Solved] iwlwifi very unstable after 3.4 upgrade (Centrino 1030 BGN)
Since the 3.4 kernel upgrade my wireless (iwlwifi, Intel Centrino-N 1030) has been extremely unstable and essentially unusable. There have been reports of problems on Intel 6x00 wifi cards, but I've not seen any on the 1030. I've tested this on 3.4.2
-
The action drop down does not function in an interactive report. It works on an existing page in the application. The page in question is branched to from a another page. When I copy the page that works and branch to it, the action drop down does not