String function to count total number of a specific character.
Gurus,
I've been trying to use INSTR to decipher a string to count the number of pipes in each string. Anyone have a simple SQL which shows how to use a string function to return a count of a specific character?
Thanks
-Scott
Hi, Scott,
To see how many '|' characters are in txt, you can see how much txt shrinks when you remove the '|'s.
LENGTH (txt) - NVL ( LENGTH ( TRANSLATE ( txt
, 'x|'
, 'x'
, 0
)The expression above works in any version of Oracle.
Starting in Oracle 11, you can also use REGEXP_COUNT:
REGEXP_COUNT (txt, '\|')'|' is a special symbol in regular expressions, so it has to be "escaped" ('\|') to indicate the pipe character.
Similar Messages
-
Count total number of rows present in the schema
Count total number of rows present in the schema including table, sequence, view
Desirable Output
table Sequence Views
1000 20 1000You mean You need to count the No of Tables, View and Sequence Present in the Schema ??
Hi Some thing like this,
SELECT a.view_cnt AS "View Count", b.tab_cnt AS "Table Count",
c.seq_cnt AS "Sequence Count"
FROM (SELECT COUNT (*) view_cnt
FROM USER_VIEWS) a,
(SELECT COUNT (*) tab_cnt
FROM USER_TABLES) b,
(SELECT COUNT (*) seq_cnt
FROM USER_SEQUENCES) cWhich give you,
View Count Table Count Sequence Count
153 878 32Thanks,
Shankar
Edited by: Shankar Viji on Aug 28, 2012 3:03 AM -
How to count total number of records in mYSQL through JSP ??
hi
i want method to count total number of records in table.
it was there rs.count() method in VB .
But what about JSP , i used MYSQL database.
tell me solution please...
thanks...
remember JSP - total record count for mySQLhello mr.
i don't want ur suggestion ok
i know that site.
no need to give suggestion if u don't give code.
its better to give proper reply instead of making a
comment in forum.
next time take care
He was perfectly justified in that remark. I have given you the information you need, nicely, twice. But I, and noone else here is going to do your work for you. We will point you in the direction you need to be looking, but we are not going to give code. If you attempt to code something yourself, and it doesn't work, then post the code you tried, and we may make some corrections to it. Then again, with the attitude you've shown so far we probably will not. But one thing no one here will do, is do your work. Especially not for free.
Now, if you are not willing to sit down, and look at the suggestion that has already been made, and attempt to use it. Then continue wasting your time, but go away and stop wasting our time. -
How to Count total number of Words in PDF?
I am used Adobe Acrobat javascript inbuilt function getPageNumWords(<pagenumber>) it return the number of words present in specified page, but while am copy and paste text content from PDF file to MS Word, Words count given by MS Word is little bit differ, so any one know in which aspect Acrobat count the words?
Which words count result is correct?
Shall is go with Acrobat Words count result or MS Words count result?
But I want to count the total number of words in PDF file (my input is PDF file) else can I go with iText?
Words count in PDf using iText is possible?Word counts are likely to vary a little according to how you count. For instance, are hyphenated words one or two words? What if the hyphen is at the end of a line? Do numbers count as words? Headers and footers? Captions?
Generally, you just accept a slight variation. If you are counting words in a professional context, i.e. where payment is per word, you probably need a contractual definition of how words are to be counted; in the absence of one, I suggest you use Word. -
Count the number of times a character is in a string using pl/sql
I need to count the number of times ":" appers in the string ":XXX:CCC:BBB:".
I have sound some solution using SQL but I do not want the context switch.
Also I am on 10g so I can not use REGEXP_COUNT.
Any help would be great.Hi,
length(REGEXP_REPLACE(':XXX:CCC:BBB:','[[:alnum:]]'))counts all kinds of punctuation, spaces, etc., not just colons. Change any (or all) of the colons to periods and it will still return 4. Use '[^:]' instead of '[[:alnum:]]' if you really want to count just colons.
Also, "SELECT ... FROM dual" is usually needed only in SQL*Plus or similar front end tools. In PL/SQL, you can call functions without a query, like this:
x := NVL (LENGTH (REGEXP_REPLACE (txt, '[^:]')), 0); -
How to count Total Number of Pages in SAPSCRIPT
Hi,
Iam unable to print total number of pages in the First Page of SAPSCRIPT.Iam writing the Logic in the Varibale window.
Please kindly help me.
In First Page , The preview is
Page 1 of 1-
In Second Page , Teh Preview is
Page 2 of 2
The Logic is ....
1. Variable window of Script
PERFORM CHECK_PAGE IN PROGRAM ZZZF_SAPSCRIPT_EXITS
USING &SAPSCRIPT-FORMPAGES&
CHANGING &WS_PAGE&
ENDPERFORM
Page &PAGE(C)& of &WS_PAGE&
2. Program
FORM check_page TABLES p_pagein STRUCTURE itcsy
p_pageout STRUCTURE itcsy.
DATA : p_i TYPE sypagno.
READ TABLE p_pagein INDEX 1.
IF sy-subrc = 0 .
p_i = p_pagein-value.
p_i = p_i - 1 .
READ TABLE p_pageout INDEX 1.
CLEAR p_pageout-value.
*p_pageout-value = p_i+0(3).
WRITE P_I TO p_pageout-value.
condense p_pageout-value no-gaps.
MODIFY p_pageout INDEX sy-tabix.
ENDIF.
ENDFORM. "check_page
Please help me ASAP.
Regards,
Deepthi.Try this
'On The Form'
IF &NEXTPAGE& EQ 0
DEFINE &DECRE& := '2'
PERFORM SET_TEXT_SYMBOL IN PROGRAM YSS20200
USING &SAPSCRIPT-FORMPAGES&
USING &DECRE&
ENDPERFORM
ENDIF
'In The Program'
DATA : BEGIN OF script_table OCCURS 0.
INCLUDE STRUCTURE itcsy.
DATA END OF script_table.
Used to modify total pages so they print correctly
FORM set_text_symbol TABLES input_table LIKE script_table[]
output_table LIKE script_table[].
DATA: pageno TYPE i,
intCnt type i,
chrPg(2) type c.
READ TABLE input_table INDEX 1.
MOVE input_table-VALUE TO pageno.
READ TABLE input_table INDEX 2.
MOVE input_table-VALUE TO intCnt.
subtract intcnt from pageno.
write pageno to chrpg.
CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'
EXPORTING
NAME = 'FORMPAGES'
VALUE = chrpg
VALUE_LENGTH = 0
REPLACE_SYMBOLS = ' '
ENDFORM. -
Count total number of existing Portal users..Urgent
Hello All,
im working on EP6 SP9 (and SP12).
I would appreciate if anyone would please guide me - How can I retrieve total number of existing Portal users (<b>using code</b> & not Activity Reporting).
This is kinda urgent....please I request you all.
Thanks in Advance.
Warm Regards,
Ritu R HUnjanHi ritu,
Check this code. This will give you the total no of users and the names of all the users:
package com.hcl;
import com.sap.security.api.ISearchResult;
import com.sap.security.api.IUser;
import com.sap.security.api.IUserFactory;
import com.sap.security.api.IUserSearchFilter;
import com.sap.security.api.UMFactory;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class PortalUsers extends AbstractPortalComponent
public void doContent(
IPortalComponentRequest request,
IPortalComponentResponse response)
try
IUserFactory userfactory = UMFactory.getUserFactory();
IUserSearchFilter userfltr = userfactory.getUserSearchFilter();
userfltr.setMaxSearchResultSize(5000);
ISearchResult userResult = userfactory.searchUsers(userfltr);
int size = userResult.size();
response.write("<table><tr><td bgcolor=Green>"+ "Names of the user are:"+ "</td></tr></table>n");
while (userResult.hasNext())
response.write("<table border=0>n");
String uniqueid = (String) userResult.next();
IUser user = userfactory.getUser(uniqueid);
response.write("<tr><td>"+ user.getDisplayName()+ "</td></tr>n");
response.write("</table>n");
response.write("<table border=0><tr><td bgcolor=Green>"+ " Total no of users "+ "</td></tr>n");
response.write("<tr><td bgcolor=Red>"+ size+ "</td></tr></table>n");
catch (Exception e)
I hope this solves your problem
Regards
Pravesh
PS: Please reward points if answer is helpful. -
Count total number of record of table with deletion from archiving object
Does anyone know is there any SAP standard program to count the total number of record of the table with deletion from Archiving Object and display in repprt?
Not sure of the question. Are you looking to get the sql "select count(*) from table" from using the TopLink expression framework or are you getting that SQL already and want something else?
If you are looking just to get the count from a table/class, you can use a ReportQuery:
ReportQuery rquery = new ReportQuery(ClassToQueryOn.class);
rquery.addCount(); //equivalent to count(*);
session.executeQuery(rquery);
You can use a report query to return data instead of objects, and use selection criteria just like a normal read query.
Best Regards,
Chris -
Hello All:
I am very new to Power Shell and need some help:
I have 224 GAL's on our Exchange System (Ex 2007) where, I need to count the total number of email addresses/display names assigned to each GAL. I am not sure how to set up a for-next loop in PowerShell. I am not sure how to set a input
file/variable, with the names of each GAL. (GAL is Global Address List)
I think it's $GALLIST = 'NameofGal1, NameofGal2, etc thru to NameofGaln' where n is the last GAL in the list.
So I need to now a command which would get all the gal names (Get-AddressList(?) for all the GAL's in the Exchange System and then pipe them into a function to count the number of email addresses.
In making a start with the following code and got stuck:
Get-Mailbox | Where {$_.GlobalAddressList -eq “GAL” -and $_.} | Select-Object Displayname, EmailAddresses, count
Missing or invalid property reference or expression.
At line:1 char:71
+ Get-Mailbox | Where {$_.GlobalAddressList -eq "GAL" -and $_.} <<<< | Select-Object Displayname, EmailAddresses, count
I think I know how to pipe the results to a csv file - with - Export-Csv -path c:\filename.csv - NoTypeInformation.
Please can someone advise. Please help.
Thanks in advance
PS - is there a way to access, read and display variable name and value which stores the number of email addresses/per GAL in exchange 2007 database so you don't have carry out a count exercise. Because this metadata will be in the Exchange DB?
Would this be easier to get?
Started building conditional statement:
Get-Mailbox | Where {$_.GlobalAddressList -eq "GAL" AND {{HiddenFromAddressListsEnabled -eq $True} OR {HiddenFromAddressListsEnabled -eq $False}} |
If {{HiddenFromAddressListsEnabled -eq $True} | Select-Object Displayname, EmailAddresses, count ELSE {HiddenFromAddressListsEnabled -eq $False}} | Select-Object Displayname, EmailAddresses, count
ENDIF
Export-Csv -path c:\test.csv -NoTypeInformation
Will this work? Checking to see how to do a for-next loop.
$GAL = Get-GlobalAddressList
foreach($GAL IN $GAL)
Get-Mailbox | Where {$_.GlobalAddressList -eq $GAL AND {{HiddenFromAddressListsEnabled -eq $True} OR {HiddenFromAddressListsEnabled -eq $False}} |
If {{HiddenFromAddressListsEnabled -eq $True} | Select-Object Displayname, EmailAddresses, count AS "Count of Hidden Addresses" ELSE {HiddenFromAddressListsEnabled -eq $False}} | Select-Object Displayname, EmailAddresses, count AS "Count of
Visible Addresses" |
Export-Csv -path c:\test.csv -NoTypeInformation |
not sure if this works and looks spaghetti -like!Hi Everton,
In addition, If you want to export GlobalAddressList, please refer to the script below:
$filter = (Get-GlobalAddressList 'Default Global Address List').RecipientFilter
#filter HiddenFromAddressListsEnabled is ture
Get-Recipient -RecipientPreviewFilter $filter | Where-Object {$_.HiddenFromAddressListsEnabled -eq $ture} | Select-Object Name,PrimarySmtpAddress
#filter HiddenFromAddressListsEnabled is false
Get-Recipient -RecipientPreviewFilter $filter | Where-Object {$_.HiddenFromAddressListsEnabled -eq $false} | Select-Object Name,PrimarySmtpAddress
Refer to:
How to Export the Exchange 2010 Default Global Address List (GAL)
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Hello,
In some function of my program, I need to count total number of rows but, I don't need to fetch results. Only the number of rows.
Is there any way to count the total number of result rows without fetch?
In OCI ver.7, it was very simple.
Just Call ofen() (OCIStmtFetch() in ver.8) without defining, but it's impossible that fetch without defining in Ver.8
Is there any idea to solve this situation?
I can defining and fetching just like normal process, but customer can send any SQL statement so, it can include LOBs.. and so on.
It's very waste source codes and memory for just counting rows.
Thank youOne possibility is to execute a different statement
(i.e. select count(*) from foo;) to get the number of
rows directly. This would probably be the most efficient
way to get the row count (since no row data is shipped
with this statement).
Unfortunately, I was unable to fetch rows w/o defining
in OCI either (I got an ORA-24374), so I am not sure how
you can get around this.
Incidentallly, when fetching LOBs, I don't think that
the entire lob is fetched, only the LOB locator. In this
case, there is very little over head associated with the
data transfer.
Also, I believe that ofen() was doing roundtrips in the
past, and my impression was that the latency of the
roundtrip to the server (and not the associated latency
of transferring the data) was the bottleneck here. Hence,
there may not be as much of a performance penalty as
expected for doing the extra client define with OCI
v8. So you still might be able to use your old ofen logic
(after replacing with OCIStmtExecute/OCIDefine) and not
see a very high performance hit.
Hope that helps out somewh -
Count total no of records in csv file
hello
i made a function which count total no of records in csv file.
but it always return 0 goes in the exception when no data found which
it also display the total no of records in another parameter.
code is here
CREATE OR REPLACE FUNCTION COUNT_RECORDS_CSV (storeid1 number ) RETURN NUMBER
IS
wfile_handl UTL_FILE.FILE_TYPE;
v_file varchar(100);
S VARCHAR2(32767);
c number :=0;
v_dir VARCHAR2 (50) := 'REPORTS';
BEGIN
v_file :='DATA_'||storeid1 ||'.CSV';
DBMS_OUTPUT.PUT_LINE('V_FILE='||v_file);
wfile_handl := UTL_FILE.FOPEN(v_dir,'DATA_5138.CSV','R');
LOOP
UTL_FILE.GET_LINE(wfile_handl,S);
C := C + 1;
END LOOP;
UTL_FILE.FCLOSE(wfile_handl);
RETURN C;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;
END COUNT_RECORDS_CSV;
if i print the values of c it show me correct result but it always return 0 can any body told me why its happening.
thanksThe fact that you have written this:
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;means you didn't bother to read this. -
[OT] User-Defined string Functions Oracle PL/SQL
Ladies and Gentlemen,
I am pleased to offer the following string functions Oracle PL/SQL:
GETALLWORDS(): Inserts the words from a string into the table.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RAT() is case-sensitive. RAT similar to the PL/SQL function INSTR.
ATC(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (including overlaps). The search performed by ATC() is case-insensitive. ATC similar to the PL/SQL function INSTR.
RATC(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string (including overlaps). The search performed by RATC() is case-insensitive. RATC similar to the PL/SQL function INSTR.
AT2(): Returns the beginning numeric position of the first occurrence of a character expression within another character expression, counting from the leftmost character (excluding overlaps). The search performed by AT2() is case-sensitive. AT2 similar to the PL/SQL function INSTR.
REPLICATE(): Returns a character string that contains a specified character expression repeated a specified number of times.
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
Plus, there are versions for MS SQL SERVER, SYBASE ASA, DB2, MS SQL SERVER 2005 SQLCLR.
More than 8000 people have already downloaded my functions. I hope you will find them useful as well.
For more information about string UDFs Oracle PL/SQL please visit the
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,54,33,29233
Please, download the file
http://www.universalthread.com/wconnect/wc.dll?LevelExtreme~2,2,29233
With the best regards.>
I am using the Oracle Data Provider in vs2012. I am having trouble calling a function that returns an object type defined.
>
Returning a collection like that is a bad idea to begin with. That isn't scaleable and wastes memory.
Either return a REF CURSOR and let the client FETCH the rows or use a PIPELINED function and let the client query it like they would a table.
Here is an example similar to yours that uses a PIPELINED function.
create or replace
package pkg2
as
CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
type pkg_emp_table_type is table of emp_cur%rowtype;
function get_emp(
p_deptno number
return pkg_emp_table_type
pipelined;
end;
create or replace
package body pkg2
as
function get_emp(
p_deptno number
return pkg_emp_table_type
pipelined
is
begin
for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
FROM emp where deptno = p_deptno) loop
pipe row(v_emp_rec);
end loop;
end;
end;
select * from table(pkg2.get_emp(20));
EMPNO ENAME JOB MGR DEPTNO
7369 DALLAS CLERK2 7902 20
7566 DALLAS MANAGER 7839 20
7788 DALLAS ANALYST 7566 20
7876 DALLAS CLERK 7788 20
7902 DALLAS ANALYST 7566 20 -
To count the number of occurences of a character
Hi All,
Is there a particular function to count the number of occurences of a particular character in a string...?
Let me know if u know the same.
Thanx and regards
AkshatA method with a test driver:
public class a {
public static void main(String args[]) {
System.out.println(howmany(args[0],args[1].charAt(0)));
public static int howmany(String what,char c) {
String regexp = "" + c;
String s=null;
try {
s=what.replaceAll(regexp,"");
catch (Exception e) {
regexp = "\\" + c;
s=what.replaceAll(regexp,"");
return what.length() - s.length();
} -
I would like to calculate at the bottom of my table the number of runners that we have entered into the race. The total cost of the race entries will be shared among the participants, so I need to calculate the average cost/person.
Hi drnelson,
The COUNTA function will count the number of cells that are not empty. Add a Footer Row to your table. To count the number of non-blank cells in the column above (for example Column B) enter this formula into the Footer cell of Column B:
=COUNTA(B)
A formula in a Footer Row can refer to the whole Column except itself and any Header Rows. Then you can add more rows without having to adjust the formula.
Regards,
Ian. -
Count the number of rows inserted
Hi,
Is there a way to count the number of rows processed post DML in PL/SQL?
For eg,
BEGIN
INSERT INTO TMP1
SELECT * FROM EMP;
a function to count the number of rows inserted into tmp1SQL> set serveroutput on;
SQL> begin
2 insert into tmp1 select * from emp;
3 dbms_output.put_line(SQL%ROWCOUNT||' rows inserted');
4 end;
5 /
15 rows inserted
PL/SQL procedure successfully completed.
Maybe you are looking for
-
How to set up Print Specs and Profiles in CS5 Suite
I am no color management expert but I do want to get my printer to print the same colors as my monitor displays in PSD, AI and InD applications. My Intel iMac and Cinema Display running OS10.5.8 are both color calibrated with Spyder 3 Elite to achiev
-
How do I get a refund for extra iCloud storage I just bought? I can't figure it out
-
Hi everyone! I'm new to java. I've already learnt that there is no why to protect java source code or classes by encryption. It is easy to decomplile any java class. So my problem is if I want to ask the user for password to provide a special service
-
My friend upgraded to the 3G and gave me his original. I have a few questions. First the iPhone was last synced to a Mac and I have a PC. What do I have to do to use it as a Touch? I am a current AT&T user,can I activate from home?
-
hello friends i m new in ABAP i had designed database and now i want to enter the data through module pool so please guide me about the module pool and insert condition how could i do that Do post friends................... Waiting for ure precious s