How to find apostrophes in a VARCHAR2 column
I have a value "GOT UP LATE - DIDN'T HAVE TIME"
stored in varchar2 field of my table through Oracle forms. I want to check whether the values stored in this column have apostrophes or not (e.g. as in DIDN'T). Could any body please let me know how to do this.
Rajeev
[email protected]
You can use the INSTR function
INSTR(string, set[,start[,occurence]])
INSTR('abcdecg', 'c') would return 3 since the 1st occurence of 'c' is at position 3 in the string.
INSTR('abcdecg', 'c', 1, 2) would return 6 since the 2nd occurence of 'c' is at position 6 in the string.
INSTR('abcdecg', 'c', 4) would return 6 since the 1st occurence of 'c', starting at position 4, is at position 6 in the string.
Good luck.
Similar Messages
-
How to find the sum of a column
I need to find the sum of a column and use it in a different column. The following is the example.
Column names: Feedback(Good, Avg, Poor), Count(no of good, no of avg, no of poor) and %age(Feedback/sum(feedback))
I want to find the sum in Java class and also calculate the last column in java class.
Please tell me some way to do it.oh.. ok ..thanks for letting me know.. i will formulate the question in a proper way:
This is what my UI should look like:
Rating Count Percent
Excellent 2 20
Good 6 60
Poor 1 10
Bad 1 10
Now i have the following columns in the data base:
Meaning and feedback_rating.
So the following SQL Query:
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
will give me the result as
rating counted
Excellent 2
Good 6
Poor 1
Bad 1
Now I want a third column as percentage : Earlier we were doing this calculation in the sql query itself, so the query was like
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted,
sum(decode(bcpi.feedback_rating, null, 0, 1))/(max (select count (*) from cmp_cwb_person_info bcpi ,
hr_lookups hrl )) percent
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
Hence the third column (percent) was calculated in the sql query itself.
But now i feel that the performance of the query could be improved if we get the first two columns from the database and the calculate the third column programatically in the java code.
So this is what I want to know. How can i do that? -
How to find the new tables and columns in a schema
hi..good morning to all...
I have a schema ABC which owns some objects.
Now some days before I have made another schema XYZ which was a replica of ABC schema.
between these days some new tables, new columns in the existing tables(with or without default value), comments on the columns are being added in the new schema i.e XYZ schema.
Now I have to find the extra things which are present in the new schema. I need to find the new tables, new columns in hte existing tables, their default values and descriptions of those.
Can u plss help me how can I find it?
I am guessing that I have to write a SQL query with a minus clause but I am not able to write it and also dont know where should I execute it.
plss help. thanks in advance.And moreover, when I am executing the query to get the desired result, then it is throwing "illegal use of long datatype" error and pointing to the b.data_default area of my query..
select a.table_name, a.column_name, b.data_default, a.comments from all_col_comments a, dba_tab_columns b
where a.TABLE_NAME=b.TABLE_NAME
and a.OWNER=b.OWNER
and a.OWNER=XYZ
minus
select c.table_name, c.column_name, d.data_default, c.comments from all_col_comments c, dba_tab_columns d
where c.TABLE_NAME=d.TABLE_NAME
and c.OWNER=d.OWNER
and c.OWNER='ABC'
order by 1, 2;
plss help... -
How to find default value of a column ?
hi , alok again,
i have to find default value of a column.
Acutally i have found , column's max width, its nullability, precision, scale, type, but NOT default value.
I will have to use the default value and nullability while validating user's input.
ResultSetMetaData doesnot contain any method any such method...
Pls help,
how can i do so.
Any idea will be highly appreciated.
Thanks in adv.
AlokHi,
After you get the resultset from DatabaseMetaData.getColumns() as shown by sudha_mp you can use the following columns names to retrieve metadata information:
Each column description has the following columns:
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
COLUMN_NAME String => column name
DATA_TYPE int => SQL type from java.sql.Types
TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
BUFFER_LENGTH is not used.
DECIMAL_DIGITS int => the number of fractional digits
NUM_PREC_RADIX int => Radix (typically either 10 or 2)
NULLABLE int => is NULL allowed.
columnNoNulls - might not allow NULL values
columnNullable - definitely allows NULL values
columnNullableUnknown - nullability unknown
REMARKS String => comment describing column (may be null)
COLUMN_DEF String => default value (may be null)
SQL_DATA_TYPE int => unused
SQL_DATETIME_SUB int => unused
CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
ORDINAL_POSITION int => index of column in table (starting at 1)
IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.
SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
SCOPE_TABLE String => table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF)
SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
Regards,
bazooka -
How to find out the tablename and column name
Hi,
I have inserted a value (say 'I am here') in a table. but i don't know which is getting inserted this value.
Now i want to know which table and colums has this value (I am here). How to find out as without knowing the table name.
Is there any option to get the tablename and colum??.
Please help me.
thanks.Does nobody document their code anymore?
See my response Re: How to find out a tablename for one possible solution.
HTH
John -
How to find the difference of two columns in deski
Hi Everyone,
I have a deski report which is build from a single query. The report contains two tables.
Table-1:MTK Loc
MTKnet
Table-2:WTK Loc
WTKnet
Now i need to find the difference of the columns WTKnet and MTKnet.
These two are report level variables.Their definitins are as below:
MTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vMTKLocation>
WTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vWTKLocation>
Where <Fees Collected by Per Collected> is universe variable.
Please help...
Thanks in Advance......Hi Bol,
As I understand you are taking MTK_Loc and WTK_Loc together in the report which have common values under Fees Collected by Per Collected column.
Please follow the steps mentioned below:
1. Calculate the Variables MTK_Net as
=Sum(<Fees>) IN <MTK_Loc>
2. Calculate the Variables WTK_Net as
=Sum(<Fees>) IN <WTK_Loc>
3. You will get the values based on the Locations MTK_Loc and WTK_Loc .
You are using combination of values for MTK_Loc and WTK_Loc hence you will get the variable values in combination.
Insert new column right to the WTK_Net and write the formula name it Variance.
=<MTK_Net>- <WTK_Net>
The values look like :
MTK_Loc WTK_Loc MTK_Net WTK_Net Variance
Chicago Chicago 16,696,274.43 157,168.26 16,539,106.17
Chicago Madison 16,696,274.43 274,396.12 16,421,878.31
Chicago Milvaki 16,696,274.43 16,622,870.97 73,403.46
Chicago Pennsylvania 16,696,274.43 4,299.35 16,691,975.08
Chicago Waukesha 16,696,274.43 22,067.08 16,674,207.35
Here you will see values for MTK_Net are repeated because these are based on the MTK_Loc which is same for all rows i.e. Chicago , same is the case with remaining values of MTK_Loc.
We can not calculate variabnce based on the values like Canada,Pennsylvania for all values as these values come in combination of each other and as these are all connected columns WEBI groups Measure data based on the Dimension and variable columns associated with it.
MTK_Loc WTK_Loc MTK_Net WTK_Net Variance.
Chicago Chicago 16696274.43 157168.26 16539106.17
However you can compare the values based on the values as :
1. Drag and Drop MTK_Loc and MTK_Loc separately on the report.
2. Drag and Drop WTK_Loc and WTK_Loc separately and put it on the report, Connect it to the columns MTK_Loc and MTK_Loc columns already dragged. Then you can compare the values
MTK_Loc MTK_Net WTK_LOC WTK_Net
Chicago 16,696,274.43 Chicago 157,168.26
Madison 315,705.91 Madison 274,396.12
Manitowoc 362,632.50 Manitowoc 359,978.50
Milvaki 54,172.84 Milvaki 16,622,870.97
Pennsylvania 2,966.56 Pennsylvania 4,299.35
Waukesha 9,028.03 Waukesha 22,067.08
Here I unchecked the option avoid duplicate row aggregation (select table-> format table) thatu2019s why it is showing all values as a sum of all MTK_Net and WTK_Net values corresponding to Location values..
Here we are using MTK_Loc and WTK_Loc separately and not connected because though values seems same but they are used in combination ( Chicago, Pennsylvania) in 2 separate tables in DB hence we canu2019t synchronize them by liking these 2 location columns using 2 data providers.
I Hope this is what you want....
Thanks....
Pratik -
How to find max based on 2 columns.
Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
Column A represents date and column B represent time.
How would I find max value of column A and with results for A find Max for B.
example
A - - - - - - - - - -B
101010 - - - - - 202020
101011 - - - - - 202021
101012 - - - - - 202021
101010 - - - - - 202022
101012 - - - - - 202020
What I looking for is
A - - - - - - - - - - B
101012 - - - - - 202021
ThanksYou can try one of the following...
sql> select * from temp;
A B
101010 202020
101011 202021
101012 202021
101010 202022
101012 202020
1 select a,b from (
2 select a,
3 b,
4 rank () over (order by a desc, b desc) rnk
5 from temp
6* ) where rnk = 1
sql> /
A B
101012 202021
1 select a,b from (
2 select a,b from temp
3 order by a desc, b desc
4* ) where rownum = 1
sql> /
A B
101012 202021Please try to provide create table statements and insert data scripts instead of "select * from table".
It helps creating your case easier. -
How to find the duplicate entries in column
clolum name descripitoin ex:
CLIENT_NAME | Last Name | First Name | Middle Name |suffix | Tendulkar Sachin Ramesh Jr.Sachin
| | Sachin Tendulkar Ramesh Jr.Sachin
| | Ramesh Sachin Tendulkar Jr.Sachin
PANno | no | AUBIU1966E
Address | Address of clint | Any address
Insert multiple records as per the e.g. shown in table. Write a oracle procedure in database schema to input the string and identify the possible duplicates from above table.942919 wrote:
HI
but clint name is like
CLINT_NAME
Sachin Tendulkar Ramesh
Sachin Ramesh Tendulkar
Tendulkar Sachin Ramesh
in this senario clint name column show diffrent names
your query is not working
above three entries are same we need to find aboue three entries are duplicate1. Have one other column called Name2 in the table
2. scan the table and run the "combined" (means you combined every row from below separated by a space) the below output into name2 column
with t as (
select 'Sachin Tendulkar Ramesh' col from dual
select TRIM(substr (splitted,
instr (splitted, ' ', 1, level ) + 1,
instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 )) as ret_row
from (select ' '||col||' ' splitted
from t)
connect by level <= length(splitted)-length(replace(splitted,' ',''))+1
and instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 > 0 order by 1;
3. now run this
select name2,count(*)
the same like above but group by name2, then you will see it -
Hi Team,
I Have one requirement,In SSRS Reporsitory 3000 reports are available.
My end user requirement All 3000 reports are used Table names & columns list of each wise to display single table or single result set.
I find out all 3000 reports details are diplayed single results set like
Report Id,Path,Dataset,Source Query Text,Datasource
In Source Query Text column level All reports Queries are available but I want Each Report wise Table name & columns List.If any solution Please share me.
Regards
RamaHi Ramakoteswara,
According your description, you want to show used tables and columns of each report, and display is into a single result set. Right?
In this scenario, we don't know where to find a column contains the Source Query Text. With my understanding, in Reporting Services, we have Catalog table in ReportServer DataBase, it has a column called Content stores the report code (.xml). In the
code we can find the Query and Fields. Then you need to use VB/C# code to parse each .xml code of each report and fetch out the table name and columns. We do not support writing any queries against SSRS DataBase or parsing data records in any
table.
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How can find text only in second column of cell?
Hi, everyone
I only want to find second column of dollar sign
aim to apply to character style: "Bold+Italic",
I can I make it happen?
screenshot:
I have this script, can someone help me to change it's function?
if ( app.selection.length > 0 && ( app.selection[0].constructor.name == "Cell" || app.selection[0].constructor.name == "Table" ) ) {
if ( app.scriptPreferences.version >= 6 ) {
app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "style every second column in selection" );
else {
main();
} else {
alert ( "Nothing or wrong selection!" );
function main() {
var myColor = "PANTONE 252 U";
var myFillTint = 20;
var myCharStyleName = "Bold";
var curSel = app.selection[0];
var allCells = curSel.cells;
var startCol = curSel.cells[0].name.split(":")[0]*1;
var endCol = curSel.cells[-1].name.split(":")[0]*1;
var counter = startCol + 1;
for ( var i = 0 ; i < allCells.length; i++ ) {
var curCell = allCells[i];
var curCol = curCell.name.split(":")[0]*1;
if ( curCol == counter ) {
curCell.fillColor = myColor;
curCell.fillTint = 20;
curCell.texts[0].appliedCharacterStyle = myCharStyleName;
counter = counter + 2;
if ( counter > endCol ) {
counter = startCol + 1;
} // end if
} // end for
} // end main
JohnHi Chinna,
What if I add something into it, Can it working?
var doc = app.activeDocument,
_selection = app.selection[0];
for(var i =1;i<_selection.columns.length;i+=2)
var _cells = _selection.columns[i].cells;
for(var j =0;j<_cells.length;j++)
// I think have to add a function in here like this:
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "HK\\$\\'000";
_cells[j].texts[0].appliedCharacterStyle = "Bold+Italic";
app.findGrepPreferences = app.changeGrepPreferences = null;
John -
How to find out the primary key column of a database table?
Hi
Given the following scenario :
Given an inputfield, the user can enter a table name. The code behind will base on the table name given and extract out the fieldname of the primary key and concatenate the two field to become a unique string.
Eg. Order ID and Product ID make out a primary key.
How do i achieve that? Any code sample?
Regards,
RaydenCheck the below code :
REPORT zTest no standard page heading.
data : i_DD03P like DD03P occurs 0 with header line.
data v_table like DCOBJDEF-NAME.
parameters : p_table like dd02l-tabname.
start-of-selection.
v_table = p_table.
CALL FUNCTION 'BDL_DDIF_TABL_GET'
EXPORTING
NAME = v_table
STATE = 'A'
LANGU = 'E'
IMPORTING
GOTSTATE =
DD02V_WA =
DD09L_WA =
TABLES
DD03P_TAB = i_DD03P
DD05M_TAB =
DD08V_TAB =
DD12V_TAB =
DD17V_TAB =
EXCEPTIONS
ILLEGAL_INPUT = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at i_DD03P.
if i_dd03p-KEYFLAG = 'X'.
write:/ 'Key fields', i_dd03p-FIELDNAME.
endif.
endloop.
Thanks
Seshu -
How to find same values in 1 column???
TITLE AUTHOR_NUM
A Deepness in the Sky 3
Magic Terror 5
The Stranger 18
Venice 11
Second Wind 4
The Edge 4
Dreamcatcher: A Novel 6
Treasure Chests 23
Treasure Chests 25
Beloved 1
Harry Potter and the Prisoner of Azkaban 15
Van Gogh and Gauguin 9
Van Gogh and Gauguin 19
Of Mice and Men 20
Electric Light 17
Group: Six People in Search of a Life 2
Nine Stories 16
The Soul of a New Machine 24
Travels with Charley 20
Catch-22 10
Jazz 1
Band of Brothers 14
A Guide to SQL 7
Franny and Zooey 16
East of Eden 20
Harry Potter and the Goblet of Fire 15
The Fall 18
Godel, Escher, Bach 12
When Rabbit Howls 8
Black House 5
Black House 6
Song of Solomon 1
The Grapes of Wrath 20
Slay Ride 4
The Catcher in the Rye 16
To Kill a Mockingbird 13List the branch number and names of shops which do not have any books written by Pratt in stock. Order the list by branch number.
how can I code this? if that statement was positive, i would say something like "*where ..... author_last IN ('Pratt')"*
But in this case, how can I do it? i don't think there's a command like "OUT" in SQL :) -
How to find the column name and table name with a value
Hi All
How to find the column name and table name with "Value".
For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
Any help is highly appricatable
Thanks & Regards
Srikkanth.M2 solutions by Michaels (the latter is 11g upwards only)...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
SQL> select table_name,
column_name,
:search_string search_string,
result
from cols,
xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
columns result varchar2(10) path '.'
where table_name in ('EMP', 'DEPT')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME ES RESEARCH
DEPT DNAME ES SALES
EMP ENAME ES JONES
EMP ENAME ES JAMES
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES PRESIDENT
EMP JOB ES SALESMAN
9 rows selected. -
How to find bounds of textcolumn
Hello ,
can anybody tell me ,how to find bounds of textcolumn.Text columns don't have a geometricBounds property, so you have to calculate that yourself. Take the bounds of the text frame, check the number of columns (myTextFrame.textFramePreferences.textColumnCount) and the gutter width ((myTextFrame.textFramePreferences.textColumnGutter). Then you can work out the bounds of a text column.
Peter -
How to find the Data Type of a column
Dear All,
How to find the Data Type of a Column dynamically in oracle Form.
Thanks and Regards,
Fazil
Edited by: user11334489 on Aug 25, 2012 9:06 PMhi,
you can use get_item_property built-in
eg:
declare
l_item VARCHAR2(10);
begin
l_item := Get_Item_Property('item_name',DATATYPE);
end;
Maybe you are looking for
-
Safari won't open websites on hotel network in korea, but other macs will
I'm in South Korea on business and am staying at a hotel with free wireless. I'm the only person here that can't get my computer to work correctly. I'm actually writing this from a mac computer using safari. I have tried both Safari and firefox on my
-
Getting files from laptop to iPad for email
I have been stuck trying to find a solution for this problem. I have a desktop, laptop and iPad2. My iPad generally syncs with the desktop (which has my photos, complete iTunes library, etc.). I regularly travel to a location that has no internet acc
-
Show font command crashes application
I recently posted a complaint that Show font (cmd-T) reproducibly crashes Mail. I have been trying to find out which line in my Mail preferences is responsible for this, when suddenly I discovered that the same behavior occurs in Textedit ! Clearly m
-
What's with the spinning ball?
Sometimes, when transferring even just one song to my iPod, the beach ball spins for 15-30 seconds, during which time, of course, I'm unable to do anything. I have the latest firmware and have verified the iPod in DIsk Utility to make sure all is wel
-
On our 7K's we run our interfaces in dedicated and not shared mode. Since we are running in dedicated mode, does one need to be concerned with the input queuing policy or can we just let the egress policy take care of the queuing? Service-policy (