CSV string to list of number for IN() statement
Here is the problematic part of my function:
<blockquote>cr.client_id in (to_number(:ClientId)</blockquote>
I want my SQL*Plus function to handle a list of ClientIds supplied by the user, but if I enter "20006336, 27340036" I get the following error:
<blockquote>ORA-01722: invalid number
01722. 00000 - "invalid number"</blockquote>
Seems like there should be an easy solution to conversting a string to a list of numbers...
Running 10g. Also, the function works with &ClientId but I would prefer to keep it as a bind variable if possible (large query)
Thanks for the help!
Edited by: 791028 on Aug 26, 2010 8:58 AM
Something like:
SQL> ed
Wrote file afiedt.buf
1 select *
2 from emp
3 where ename in (
4 with t as (select '&input_string' as txt from dual)
5 select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
6 from t
7 connect by level <= length(regexp_replace(txt,'[^,]*'))+1
8* )
SQL> /
Enter value for input_string: SCOTT,JAMES
old 4: with t as (select '&input_string' as txt from dual)
new 4: with t as (select 'SCOTT,JAMES' as txt from dual)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-04-1987 00:00:00 3000 20
7900 JAMES CLERK 7698 03-12-1981 00:00:00 950 30
SQL>
Similar Messages
-
Using apex item for list of number for 'IN' clause
Greetings,
I have a computation that looks like this:
select count(mr.mr_id)
from ds_moriver mr
where mr.approved = 0 OR mr.approved IS NULL
and mr.mr_id NOT IN (:P62_MRID)
I am looking to enter numbers in the NOT IN clause like '123,234,...'
I have a text field item (P62_MRID) where the user can enter IDs for the NOT IN clause. So for example, 13578,182. If the user enters one number it works fine. If the user enters 2 numbers with a comma (13578,182) then I get this error when the computation is run:
ORA-01722: invalid number
So substituting 13578,182 for P62_MRID the SQL statement should compute as:
select count(mr.mr_id)
from ds_moriver mr
where mr.approved = 0 OR mr.approved IS NULL
and mr.mr_id NOT IN (13578,182)
Why am I getting the error, 'ORA-01722: invalid number'?
Thanks in advance!
JohnGlad to help. Don't know how long you've been using APEX, but thought I'd caution you against "going wild" with the item substitution syntax. In general, if you can do it with bind variable syntax, that's better. The use of item substitution syntax can contribute to SQL injection attacks. But, if you have suitable control over the contents of the items being substituted, the risk is mitigated. Just don't create an APEX process like this:
begin
&P10_TEXT_DIRECTLY_FROM_USER.
end;
That'll get you into trouble. -
HT4865 How can I change the incorrectly listed cellular number for SMS code
I listed my iPad cellular number incorrectly to receive an SMS code which musted be listed to progress further. So I cannot retreive the four digit number
which was sent to the incorrect number. How can I change it to the correct cellular number?From http://support.apple.com/kb/TS4644:
Devices using iOS 7.0.3 or later: Tap Settings > iCloud > Account, then tap Keychain. Check that the phone number listed under Verification Number is correct. If not, enter another phone number.
Macs using OS X Mavericks v10.9 or later: Choose Apple () menu > System Preferences. Click iCloud, then click Account Details. Check that the phone number listed under Verification number is correct. If not, enter another phone number. -
Can't get a telephone number for the State Of Main...
Maine isn't on the list to start the telephone number process, does anyone know why
http://support.apple.com/kb/ht1808
-
Stored Procedure with CSV string as parameters
Hi,
I have been tasked with this issue, but I have no real SQL/Oracle experience. My boss advises that the best way to do this would be to pass a CSV string into the stored proc for each parameter,
What I need to do is parse the CSV string and use each value within their as part of the where clause so. If I have two parameter CSV strings A and B. My outcome would be something like:
select * from table where col1 = A1 or A2 or A3 and col2 = B1 or B2 or B3.
The number of values within each CSV string are unknown until they are passed into the stored proc. How would I best go about this?
Thanks,
Darren.You can use a comma separated string of values in the where clause of the query this way:
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> select * from emp
2 where ','||&instr||',' like '%,'||empno||',%';
Enter value for instr: '7654,7876,7369'
old 2: where ','||&instr||',' like '%,'||empno||',%'
new 2: where ','||'7654,7876,7369'||',' like '%,'||empno||',%'
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20Max -
To differenciate string and list types in Xpress language
Hi! I have a question in Xpress language:
I'd like to know how to differentiate between string and list types. For example, *<s>orange</s>* and *<list><s>orange<s></list>*
How does it know Xpress language what is it string or list?
Thanks a lot.
P.D. Excuse for the strike text, I don't know why it shows striked test.Try this:
<instanceof name='List'>
<ref>orange</ref>
</instanceof>
Edited by: Mindie on Mar 28, 2008 8:12 AM
Edited by: Mindie on Mar 28, 2008 8:13 AM
Edited by: Mindie on Mar 28, 2008 8:13 AM
Edited by: Mindie on Mar 28, 2008 8:13 AM -
Skype number for country not listed yet?
Can I get a Skype number for a country that is not yet listed?
Hi, DannyNav01, and welcome to the Community,
No, you can not. The list of numbers in the available countries and areas that appears is simply that - what is available.
Regards,
Elaine
Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often! -
String Field rendering as Number Field in CR Basic for VS2008
I recently migrated from CR for VS2005 to CR Basic for VS2008 and am creating my first report using CR 2008. The SQL result set returns rows containing strings (nvarchar), integers and decimal (7,2) fields.
The report is getting all rows in the result set, but the string fields as defined in the SQL are 1) rendering in the report as numbers, and 2) showing as empty. The non-string fields render fine. I tried reformatting the report field to string, but only the Number tab appears in the formatting dialog. I also tried converting the SQL field result into an unbound string field, as well as tried the ToText function, but the results were the same. I suspect the field appears empty because of the formatting issue.
How can I get CR Basic for VS2008 to render a string (nvarchar) field as a string?Try placing the field inside a formula field or inside a text field. That should cause the field to be shown no matter what type of data it is. If the data is still not showing, then perhaps it is not being returned properly.
Things to check:
-Are you connecting directly to the tables - or are you connecting to a stored procedure? If you are connecting to a stored procedure and you are using Temp Tables, then make sure you add the line "SETNOCOUNT ON" to your stored proc.
-Run SQL profiler - see what query is being made, then try running that exact same query through the SQL admin console (Or some other utility that lets you run SQL queries)
Thanks
Shawn -
In the packing list, batch number and expiry date is not appearing for a ma
Dear Friends,
I have an issue in the packinglist.
In the packing list, batch number and expiry date is not appearing for a material.
But in the delivery the batch number and expiry date is appearing.
Why this has triggered and how to solve this?
With regardsHi Vamsi,
Please go through the output type Smart form or script programe of the packing list and check with the abaper If is there any Bug.
Regard's
Murali. -
How can I create a matrix question? Specifically, I need a question in table format that allows each respondent to list a number of events and then data for each event (date, location, number of participants, topics covered, etc.
Hi,
Sorry, we do not support a matrix-question field. Please try the multilines text field (where your participant can enter multiple lines in the input text box) and see if it works for you.
Thanks,
Lucia -
External number for Task list group
Dear experts,
I want to give external number(actually name) to all the groups for equipment task lists.In SPRO , number ranges for task lists, I have created one external along with internal number range. But as soon as I want to create the equipment task list, the " group" picked its value from internal range.
Is there any setting to do , so that I can get external number for the group for equip. task list.
Regards,
RajeshHello Rajesh,
It is not possible to have external numbering for equipment or functional location task lists. Only possible for general task lists.
-Paul -
Change starting number for Numbered List.
I am breaking up a list into 4 columns and I want them numbered. When you use the Numbered List it automatically starts at 1. I want it to start with the number I left off with in the text box next to it. How do you change the starting number for a Numbered List?
Ok, this is how you do it (just figured it out myself!)
If you click in the text box and do command A to select all, it will select all of the text BUT not the numbers. If you want to change the size of the numbers, you have to click on the number in the text box (the entire line will highlight) and use command-+ and command-minus to increase/decrease the size (or choose from the character palette. This WILL change the size of everything in the text box, but then you can go back to a simple command-a to change the text to the size you want. -
Hi Folks,
I am looking for a PL/SQL procudre that generates a unique hash number for a character string. Does Oracle have such a procuder.
Thanks in advnace.
nullThanks for your reply. Won't there be any loss of data if I consider only first 8 bytes? Will Integrity be maintained.?
In some cases my Strings can be unusually long - having length of 400 to 500.
I want 8 bytes as I want to map the number with MySQL bigint field. -
Generate spool req number for report output list
Hi,
How to generate spool request number for report output list while executing the report.Please provide if you have any sample code.
Thanks and Regards,
BSR.HI srinivas,
welcome to sdn.
Exporting the Contents of a Spool Request
Use
You want to export the content of a spool request in one of the following ways:
· As a text file to the SAP GUI working directory
· Unconverted or as a table, RTF, or HTML to a directory of your choice
· As a PDF file to a directory of your choice
Procedure
Follow the procedure below:
Exporting to the SAP GUI Working Directory
If you are exporting large quantities of data, downloading the spool request as a text file to the SAP GUI working directory is a good solution.
Choose Spool Request ® Forward® Export as Text.
The entire text is stored in your SAP GUI working directory in ASCII format.
A file of this type is named using the following pattern:
.txt
Example: ABC0000004327.txt
You require appropriate authorization for this function from your administrator.
Exporting Unconverted or as a table, RTF, or HTML to a Directory of Your Choice
With this method of exporting a spool request, the content of the spool request is first displayed, and you then download the content in the format of your choice to a directory of your choice.
1. Select the spool request to be exported and choose Display Contents.
2. In the case of SAPscript/Smart Forms documents, activate list display by choosing Goto.
3. Choose System ® List ® Save ® Local File.
4. Choose one of the available formats and confirm your choice.
5. Choose a directory and save the spool request.
By default, only the first 10 pages of a spool request are saved in a file. You can increase the number of pages to be saved by choosing Goto ® Display Requests ® Settings and making the desired entries in the Display Area group box.
Exporting as a PDF File
You want to export the contents of a spool request as a PDF file to a directory of your choice, and print the file as required. The PDF file contains the print data in the format in which it would be output by the printer.
The following procedure is irrelevant for the printing of PDF-based forms, since a PDF file is already returned with this method. See also Displaying and Printing PDF-Based Forms.
You also require authorization from your administrator to run this report.
The PDF file is generated as follows with report RSTXPDFT4:
1. Generate a spool request from the document to be printed.
2. In transaction SE38, start report rstxpdft4.
3. In the displayed window, enter the spool request number and the directory in which the PDF file is to be stored.
Leave the Download PDF File option selected.
Choose Execute.
4. In the next window, you can confirm or change the path in which the file is be stored.
Save your entries.
5. The system displays a log from which you can see whether the report was successfully performed.
You can then open the file from the directory and print it as required.
Restrictions for Exporting as a PDF File
· The PDF conversion only supports true bar codes for Smart Forms, which were generated with the new bar code technology as of SAP NetWeaver 04. In all other cases, the bar code is only simulated.
· PDF conversion, especially of ABAP lists, is slower and is therefore not suitable for mass printing. However, you can speed up the conversion to PDF using the FASTLISTCONV option in report RSTXPDF3.
· The font selection for ABAP lists is predefined in the PDF converter and cannot be changed.
For more information about constraints, see SAP Note 323736 in the SAP Service Marketplace
see this links
http://help.sap.com/saphelp_40b/helpdata/en/d9/4a98f351ea11d189570000e829fbbd/content.htm
http://web.mit.edu/SAPR3/docs/webdocs/reports/rpRFprint.html
regards
shankar
reward me if usefull -
Get week number for day from a list of days within a year..
I am beginning in ORACLE / SQL and wondering how I can use this query to work with a column of Dates that span over a number of years?
Ideally, I would like to use this script to add a number for the week of the year based on this.
Then when a new year begins to start over..
I am referencing an old thread..
TO_CHAR with dates to get week number issue
Here is what I have so far:
I keep getting an error stating "Bind Variable "p_date_beg" is NOT DECLARED"..
Thanks in advance for any help you can provide.
DECLARE
p_date_beg DATE;
BEGIN
SELECT RETRIEVAL_DATE
INTO P_DATE_BEG
FROM OBS_SELECT_LST12_SPG;
WITH TAB AS
(SELECT TO_DATE(TO_CHAR(:p_date_beg,'YYYYMM')||'01','YYYYMMDD') + LEVEL -1 DATE_COL
FROM DUAL
CONNECT BY LEVEL <=TO_NUMBER(TO_CHAR(LAST_DAY(:p_date_beg),'DD')))
SELECT DATE_COL, TO_CHAR(DATE_COL, 'FMDAY') DAY,
(CASE
WHEN TO_CHAR(TRUNC(DATE_COL, 'mm'),'FMDAY') = 'SUNDAY'
THEN TO_NUMBER(TO_CHAR(DATE_COL,'W'))
ELSE CEIL((TO_CHAR(SYSDATE, 'dd') + 1 - TO_CHAR(NEXT_DAY(TRUNC(SYSDATE, 'mm'), 'SUNDAY'), 'dd'))/7)
END) WEEK_NOB
END;hi, referring to this link about ISO week, http://www.epochconverter.com/date-and-time/weeknumbers-by-year.php, here is the code:
/* Formatted on 2012/06/13 06:32 (Formatter Plus v4.8.8) */
WITH t AS
(SELECT MIN (TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1)
start_date,
1 week_th
FROM DUAL
WHERE TO_CHAR ( TRUNC (TO_DATE ('20120101', 'rrrrmmdd'), 'mm')
+ LEVEL
- 1,
'FMDAY'
) = 'MONDAY'
AND ( TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1 <
TRUNC (NEXT_DAY (TO_DATE ('20120101', 'rrrrmmdd'),
'THU'
OR (TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1
BETWEEN TRUNC (NEXT_DAY (TO_DATE ('20120101',
'rrrrmmdd'
'THU'
AND TRUNC (NEXT_DAY (TO_DATE ('20120101',
'rrrrmmdd'
'THU'
+ 7
CONNECT BY LEVEL < 15),
v AS
(SELECT t.start_date + 7 * (LEVEL - 1) start_date,
t.week_th + LEVEL - 1 week_th
FROM t
CONNECT BY LEVEL < 53),
u AS
(SELECT '20120501' dt
FROM DUAL
UNION ALL
SELECT '20120502'
FROM DUAL
UNION ALL
SELECT '20120503'
FROM DUAL
UNION ALL
SELECT '20120504'
FROM DUAL
UNION ALL
SELECT '20120505'
FROM DUAL
UNION ALL
SELECT '20120506'
FROM DUAL
UNION ALL
SELECT '20120507'
FROM DUAL
UNION ALL
SELECT '20120508'
FROM DUAL
UNION ALL
SELECT '20120509'
FROM DUAL)
SELECT *
FROM u, v
WHERE TO_DATE (u.dt, 'rrrrmmdd') BETWEEN v.start_date AND (v.start_date + 6);output:
DT START_DATE WEEK_TH
20120501 30/04/2012 18
20120502 30/04/2012 18
20120503 30/04/2012 18
20120504 30/04/2012 18
20120505 30/04/2012 18
20120506 30/04/2012 18
20120507 07/05/2012 19
20120508 07/05/2012 19
20120509 07/05/2012 19
Maybe you are looking for
-
Lotus Notes connector: Error while crawling LOB contents
Hi all, I am trying to configure Lotus Notes connector on SP search. We have successfully followed the Randy Rempel's blog on test environment. No problem to search lotus notes content. In production environment, we've followed the same procedure but
-
Why does "Find Text" pause for a few seconds?
I've got a VI with about 250 subVIs, and when I search them for any text, the search zooms through them all except it pauses on a particular one. The names don't matter, so I'll just use letters; alphabetical order of VIs seems to matter.... So the
-
Connect to local oracle database at form design with Win98 or Me
Hi all, Is there a possible way to connect to a local oracle database when you design a form in Win98 or Me? Thank you
-
I have a movie on my stage that will need to load in a relatively small xml document. The problem is that the xml that is loaded into the flash is based on search results so it will change all the time and therefore won't read from a local xml file.
-
Hi everyone, This error has taken away my two workdays now. When I activate any sender file adapter, the audit log output is: Error: com.sap.aii.af.ra.ms.api.ConfigException: Some of the IS access information is not available. SLDAcess property may b