Stored procedure with select return multiple rows
hi,
in transact the stored procedure is . .
CREATE PROCEDURE MIPROCEDIMIENTO @CODE INT AS
BEGIN
SELECT COD, NAME, LASTNAME FROM EMPLOYE WHER COD = @CODE;
END
in oracle how?
please, i speak spanish. .
thanks
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10767/procedures_plsql.htm#TDPNG60035
Sybrand Bakker
Senior Oracle DBA
Similar Messages
-
Stored procedure in package return multiple columns from multiple tables
Hi ,
Can a single stored procedure return multiple column values from different tables.
example:
tabA: col2, tabB:col3,tabC:col4 etc.
one more question:
if a stored procedure like to return 10 columns for a particular record from a single table do i need to define a TYPE statement for each colum like
TYPE col1 is TABLE of varchar
TYPE col2 is TABLE of varchar
here i want to return only one row, not many rows.
thanksYou can try one procedure with OUT or IN/OUT parameters that collect the values from one or more sql statements.
CREATE OR REPLACE PROCEDURE P1
(P_COD IN TABLE.COD%TYPE,
P_DESC1 OUT TABLE1.DESC1%TYPE,
P_DESC2 OUT TABLE2.DESC2%TYPE)
IS
BEGIN
SELECT table1.DESC1, table2.DESC2
INTO P_DESC1, P_DESC2
FROM TABLE1, table2 WHERE
table1.COD = P_COD and
table1.cod = table2.cod ;
END P1;
JP -
How to use stored procedure with many return results and variable with perl
Hi everybody,
i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
My example:
PROCEDURE get_projects_and_sub_projects (
v_project_id IN INTEGER,
v_project_c_id OUT INTEGER,
v_project_id_find OUT VARCHAR2
IS
BEGIN
SELECT c_id, proj_id
INTO
v_project_c_id,
v_project_id_find
FROM t_projet
WHERE t_projet .ksa_pro_art_kbz = 'KU'
AND t_projet.proj_id LIKE v_project_id || '%';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_project_c_id := NULL;
v_project_id_find := NULL;
WHEN OTHERS
THEN
kmessages.error (NULL,
'get_projects_and_sub_projects',
'Project-Name: ' || v_project_id,
'Errornumber: '
|| SQLCODE
|| ' Error: '
|| SQLERRM,
TRUE,
TRUE
raise_application_error (-20001,
'Error '
|| SQLCODE
|| ' get_projects_and_sub_projects: '
|| SQLERRM,
TRUE
END get_projects_and_sub_projects;
in Perl Program:
sub get_projects_unterprojects_name($$){
my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
my $db_proj_c_id;
my $db_proj_name;
eval{ my $csr = $db_handle->prepare(q{
BEGIN
pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
END;
# parameter value
$csr->bind_param(":proj_name_id", $proj_name_id);
# return values
$csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
$csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
$csr->execute(); };
But this didn´t work. Could somebody give me some idea?
Thank you
FelxSome additional info would probably be helpful.
What is your programming enviironment? Java?
In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly. -
Procedure from PowerBuilder returning multiple rows
In want to call a procedure from PowerBuilder which return multiple rows. I would like to know how to write the procedure and also how to call it. I tried using REFCURSOR , but i heard that Powerbuilder doesnot support REFCURSOR . Please help
Thanks in advanceThis is not a PL/SQL qustion, but a Powerbuilder question.
Just what SQL constructs does Powerbuilder supports? And if there is no support for ref cursors, then the choice of using a client language that lacks basic core SQL support is questionable. -
Stored procedure with select query
Hi,
I have a problem , We have a sysnchronous scenario and executing a stored procedure and a selcect statement .
it is running fine with little confilt in data is there.
We we run the scenario it execute the strored procedure and return the value like 500 and under select statement it select entire table which has same flag.
I want to execute stored procdure and in slect statement one row at a time and then again it will insert to other table in then database.
currently we are getting value like this.
<?xml version="1.0" encoding="utf-8" ?>
- <ns0:MT_SP_JDBC_response xmlns:ns0="http://ns_cfgCountry">
- <GetNextSiteNumber_response>
<Result>10000000000400</Result>
</GetNextSiteNumber_response>
- <Statement2_response>
- <row>
<ID>IN</ID>
<Description>INDIA</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
- <row>
<ID>EN</ID>
<Description>ENGLAND</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
- <row>
<ID>ZA</ID>
<Description>SA</Description>
<GDate />
<FLAG>FALSE</FLAG>
</row>
</Statement2_response>
</ns0:MT_SP_JDBC_response>
Regards
Laxmi Bhushan JhaHi,
Can u please write your req little clear....
If you want to selcect and update a table and again select ... what ever it may be.... all these has to be done in the stored procedure only.
At the end of all ur statements u pass back the value from your Stored Procedure
Babu -
Stored Procedure fails to return all rows of data.
Our HR database uses a procedure to build a list of employee IDs (ie. 1,3,14,...1210,1215) then calls a procedure to with a variable to extract details per employee. Unfortunately the list is 947 ids, however only 887 rows are returned.
As a test I split the list in two and called the procedure. If I add the data rows together I get 947, hence I know the employees are valid. Can anyone suggest why a long list of Ids should fail? Is there a limit a stored procedure can return?
The procedure (simplified down a bit) is:
ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
@EmpIds varchar(4000)
AS
SELECT E.empid as EmpId ,E.Surname
FROM Employee E
WHERE (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
I can run the procedure as:
"exec sp_Employee_CreateTable @EmpIds=N'1,3,14.....999'" which returns (say) 700 rows and "exec sp_Employee_CreateTable @EmpIds=N'1001,.....1215'" which returns 247 rows. (ie. 700+247 = 947 which is correct.
But exec sp_Employee_CreateTable @EmpIds=N'1,3,14......1215' only returns 887 rows.
I have looked at the length of the data passed to the procedure (1,3,...1215) which equals 4126 chars, therefore I bumped the varchar space from 4,000 to 6,000 which is still within limits, however the number of rows returned was still 887.
Any help would be gratefully received.Hi Scott. I run the script you suggested (thank you), the var EmpIds was set to a string with over 930 ids. The returned data set started with 0 but only had 888 rows. As mentioned above I refer the 930+ list as full list, and the 888 as the short list.
The difference (around 47) were the last values in the full list.
Although EmpIds was set to 6K it definately seems like it gets to around 4K chars then ignores any other values.
Re "since you pass....". Absolutely. I have modified the Employee_CreateTable with the var update to 6K/
ALTER PROCEDURE [dbo].[sp_Employee_CreateTable]
@EmpIds varchar(6000),
@IncludeLeavers Bit
AS
SELECT E.empid as EmpId ,E.Surname, E.Firstname as Forename,E.PayrollID, E.intextno as Extension, EJ.position as Position, [dbo].[GetEmployeeDepartment](E.empid) as Department, [dbo].[GetEmployeeLocation](E.empid) as Location,
E.title as Title, EJ.ReportsTo,
CoEmail,E.[left]
FROM Employee E INNER JOIN EmployeeJobs EJ
ON E.empid = EJ.empid
WHERE (E.[EmpID] IN (select * from GetAllUsersUnderManager(@EmpIds))) AND EJ.id=dbo.GetCurrentEmployeeJobRecord(EJ.empid)--EJ.dateto IS NULL
AND (E.[left]=0 or E.[left]=@IncludeLeavers)
ORDER BY E.Surname, E.Firstname, E.empid -
Returning Multiple Rows From DBAdapter Calling PL/SQL Procedure
Oracle XE 10g Express Edition
JDeveloper 11.1.1.2.0
WebLogic Server 11g
Guys,
I have a table of orders, which I need to interrogate, and pass back any matching rows which meet certain criteria (e.g. status = 'OPEN').
However, rather than create a DBAdapter using an Operation Type of "Peform an Operation on a Table/Select", I need to use an Operation Type of "Call a Stored Procedure or Function".
I therefore need the procedure to return all the matching rows, rather than a single row.
I have looked at declaring return parameters for the procedure of the following types:
RECORD - is good because it allows me to return the elements of the row with their correct datatypes, but does not meet my needs because it will only support the return of a single row.
VARRAY - good because it can contain many row elements, but not good because it only supports a single row return, and also because all elements of the VARRAY must be of the same data type.
TABLE - good because it can contain many rows, but bad because each row can contain only two elements - the index element and the data element.
I think I could first define a RECORD (to hold a row), and then define a TABLE, with the data element being the RECORD, but I have found JDeveloper very fussy indeed when dealing with 'non-standard' data types in the DBAdapter.
Apologies if I am missing something obvious, but can anyone suggest a way of doing this?
Many thanks in advance.
Edited by: user2541290 on 17-Feb-2010 02:48Hi, I've been able to create process that seems to work. My platform is a but different but I don't think this is important for your question.
Here is the PL/SQL code. Just make Db Adapter for Calling stored procedure and it returns all rows!
Be aware of possible limitations on how manyrows you could return in one select! This can have severe impact on performance.
Succes.
Jos Baan
CREATE OR REPLACE PACKAGE lab2_multiple_rows IS
-- Author : 801455
-- Created : 18-2-2010 8:05:52
-- Purpose :
-- Public type declarations
TYPE rrows IS RECORD(
mutdat DATE,
opmerking VARCHAR2(20));
TYPE trows IS TABLE OF rrows INDEX BY BINARY_INTEGER;
-- Public constant declarations
-- Public variable declarations
-- Public function and procedure declarations
FUNCTION retrows RETURN trows;
END lab2_multiple_rows;
CREATE OR REPLACE PACKAGE BODY lab2_multiple_rows IS
-- Private type declarations
-- Private constant declarations
-- Private variable declarations
-- Function and procedure implementations
FUNCTION retrows RETURN trows IS
lrows trows;
lidx binary_integer := 1;
BEGIN
FOR rsql IN (SELECT t.* FROM jba_transactions t ORDER BY t.mutdat)
LOOP
lrows(lidx).mutdat := rsql.mutdat;
lrows(lidx).opmerking := rsql.opmerking;
lidx := lidx + 1;
END LOOP;
RETURN(lrows);
END;
BEGIN
-- Initialization
NULL;
END lab2_multiple_rows;
Edited by: Baan, Jos on 18-feb-2010 8:53 -
PL-SQL Returning multiple rows
hi all
i am using an oracle 8i database.My front end application is a JSP code which calls an oracle procedure.How do i pass a pl-sql table or an equivalent to a jave code since the procedure has to return multiple rows.i have been told that the jdbc driver version
(1.0) which we are using does not support this.
should i go about it differently and use temporary tables?..please help
thanks
LAhi all
i am using an oracle 8i database.My front end application is a JSP code which calls an oracle procedure.How do i pass a pl-sql table or an equivalent to a jave code since the procedure has to return multiple rows.i have been told that the jdbc driver version
(1.0) which we are using does not support this.
should i go about it differently and use temporary tables?..please help
thanks
LA -
Stored Procedure Returning Multiple Rows
Hello. Where can I find sample code from a class that calls a stored procedure that returns multiple rows?
I have a servlet that calls the DB directly from the servlet & loops through the result set. I want to put that code into a stored procedure, but I'm not sure how to loop through the results.
Your help is greatly appreciated!Surely you would call the stored procedure and loop
through the resultset as usual.
all that is different is the method by which you obtain the resultSet .
assuming CallableStatement, Connection have been
instantiated.
cstmt=con.prepareCall("{call sp_NewOfficeSurgery (?,?)}");
cstmt.setString(1,"first");
cstmt.setString(2,"second");
rs = cstmt.executeQuery();
while (rs.next())
String nme = rs.getString(1)
etc,etc
Hope this helps , Sorry If I have misinterpreted this
please let me know if my thinking is floored or you need
further clarification ect.
[email protected] -
The simplest way for plsql procedure to return multiple rows
Hi,
What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
Sample query would be: SELECT * FROM EMPLOYEES;
I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
Thank you!Hi,
It depends :-).
With +...that is appropriate for plsql beginners...+ in mind... it still depends!
The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
+Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
What is the level of "programming experience" ?
What is the level of understanding of "Relational Result set" as processible in Oracle?
If you are looking for
Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
vr,
Sudhakar B. -
How to call stored procedure with multiple parameters in an HTML expression
Hi, Guys:
Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
The orginal HTML expression is :
<img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
Thanks a lot.
SamHi:
Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
<img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
create or replace
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
v_counter number:=0;
cursor cur_All_Images_of_Offender is
SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
FROM sor_image
WHERE offender_id = p_n_Offender_id;
rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
BEGIN
open cur_All_Images_of_Offender;
loop
fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
v_counter:=v_counter+1;
if (v_counter=p_n_image_Count) then
owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||rec_Image_of_Offender.image_length);
owa_util.http_header_close;
wpg_docload.download_file (rec_Image_of_Offender.image);
end if;
exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
end loop;
close cur_All_Images_of_Offender;
END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
Thanks
Sam -
TimesTen SQL with group by returning multiple rows
I have a Active-Standby TimesTen nodes.
Using group by with or without having clause:
Whenever I do a group by query on table1 table with or without having clause, SQL returns multiple rows. This looks very strange to me. Each time it gives different count
Command> select count(*) from table1 group by pname having pname='pool';
< 390400 >
1 row found.
Command> select count(*) from table1 group by pname having pname='pool';
< 390608 >
< 32639 >
2 rows found.
Command> select count(*) from table1 group by pname having pname='pool';
< 2394 >
< 351057 >
2 rows found.
Command> select count(*) from table1 group by pname having pname='pool';
< 305732 >
1 row found.
Command> select count(*) from table1 group by pname having pname='pool';
< 420783 >
1 row found.
Command> select count(*),pool_name from root.rms_address_pools group by pool_name order by pool_name;
< *435473, pool* >
< *32313, pool* >
< 453, smvG3 >
< *28980, pool* >
< 3786, smvG4 >
< *26025, pool* >
< 236120, smvG6 >
< 131455, smcG3 >
< *65150, pool* >
< 23, snt1G1 >
< 510, snt2G1 >
< 510, snt2G2 >
Using where clause:
Command> select count(*) from table1 where pname='pool';
< *442354* >
1 row found.
Command> select count(*) from table1 where pname='pool';
< 442354 >
1 row found.
Table description:
Command> desc table1;
Table table1:
Columns:
*IP_ADDRESS BIGINT NOT NULL
PNAME CHAR (32) NOT NULL
SITEID TINYINT NOT NULL
1 table found.
ttVersion:
bash-3.00# ./ttVersion
TimesTen Release *7.0.3.1.0 (64 bit Solaris)* (tt70:17001) 2007-10-30T22:17:07Z
Instance admin: root
Instance home directory: /TimesTen/tt70
Daemon home directory: /var/TimesTen/tt70
bash-3.00#
Could any one suggest what is wrong with my SQL? or is it a bug with TimesTen?
Many thanks in advance.
Br,
BrijHi Gena,
When i execute the query with where clause, it gives me the output with more than one pool:
Command> select pname, count (*) from table1 where pname='pool' group by pname ;
< smcG3 , 18836 >
< pool , 423527 >
2 rows found.
Command> select pname, count (*) from table1 where pname='pool' group by pname ;
< intG302 , 17202 >
< pool , 425159 >
2 rows found.
While if give use the having clause it gives me multiple rows for one pool only ( sometimes) :
select pname, count (*) from table1 group by pname having pname='pool';
< pool , 32686 >
< pool , 420445 >
2 rows found.
select pname, count (*) from table1 group by pname having pname='pool';
< pool , 393574 >
< pool , 5838 >
< pool , 110943 >
3 rows found.
Command> select pname, count (*) from table1 group by pname having pname='pool';
< pool , 414590 >
< pool , 8395 >
2 rows found.
Please suggest what can be done in this case, need i open a case with Oracle for this.
Regards, Brij -
Problem with database control returning multiple rows as Array using Oracle
Has anybody using Oracle gotten a Database control that
returns multiple rows to work returning an array?
The only way I can seem to return multiple rows is by returning
a RowSet. Returning an array gives me a NullPointerException
(when called within a pageFlow). When calling a database control
that returns an array from a web service I get a
"java.sql.SQLException: ResultSet has no more data." error.
The samples using the pointbase database seem to work, but when I
converted the CustomerDBClient web service to use Oracle, it starts
failing on calling the database control that returns an array
with: "java.sql.SQLException: ResultSet has no more data."
Has anybody gotten this to work using Oracle?
I'm also having some problem returning an Iterator. It seems
to work when called from a web service, but returns nothing
if called from a page flow.
I'm using Oracle 8.1.7 and WebLogic 8.1.
EricDo you need a particular service pack installed to return an array of custom object?
I am getting a ResultSet contained no data error when trying.
Thanks,
-Thomas
"Robin Karlin" <[email protected]> wrote:
>
Eddie O'Neil <[email protected]> wrote:
All--
Unfortunately, returning an Iterator to a JPF (or JSP) from a
database control is broken in WLW 8.1, though it will work inside of
a
JWS or JCS.
There shouldn't be a problem with returning an array of objects out
of Oracle to the JPF, and if you need an Iterator specifically, youcan
wrap the array in an Iterator implementation.
Sorry for the inconvenience.
Eddie
Lenny wrote:
I have gotten it to work on Oracle using Array:)
However, I haven't gotten it to work on Oracle using Iterator:( Itis so
simple, but doesn't work:(
"Eric Dokken" <[email protected]> wrote in message
news:[email protected]...
Has anybody using Oracle gotten a Database control that
returns multiple rows to work returning an array?
The only way I can seem to return multiple rows is by returning
a RowSet. Returning an array gives me a NullPointerException
(when called within a pageFlow). When calling a database control
that returns an array from a web service I get a
"java.sql.SQLException: ResultSet has no more data." error.
The samples using the pointbase database seem to work, but when I
converted the CustomerDBClient web service to use Oracle, it starts
failing on calling the database control that returns an array
with: "java.sql.SQLException: ResultSet has no more data."
Has anybody gotten this to work using Oracle?
I'm also having some problem returning an Iterator. It seems
to work when called from a web service, but returns nothing
if called from a page flow.
I'm using Oracle 8.1.7 and WebLogic 8.1.
Eric
I get the same error that Eric reported when trying to return an Array
of objects.
It is really frustrating because I can't use much of the built-in control
logic
that WLW provides. All I did was create a data pool for Oracle and a
datasource.
I modified the sample app in C:\bea81\weblogic81\samples\workshop\SamplesApp\WebApp\callJavaControl
to point to that datasource and I get the error that Eric reports above.
Can
anyone help me out????
Thanks,
Robin -
Stored Procedure with Input & output parameter as XML
Hi
I have a requirement wherein i need to have a stored procedure with accepts huge XML from Java and the SP has to process all the records in the XML and return XML output with some messages in it.
Currenty, I have a stored procedure to process the xml stored in Oracle Database.
I am using the following SQL statement to read the data from the XML column.
select xmltest1.id,xmltest1.name
from xmltest,
XMLTABLE(
XMLNamespaces(default 'syncpsna/schemas'),
'/XMLTestRequest/insert/row'
PASSING xmltest.data_xml
COLUMNS
"ID" number(10) PATH 'id',
"NAME" varchar2(50) PATH 'name') xmltest1
where xmltest.id = 2;I want to execute similary queries to fetch data from the XML Passed as an input parameter from JAVA.
if i could get some examples of reading the XML and sending the xml back to the calling program.
RegardsHi,
if i could get some examples of reading the XML and sending the xml back to the calling program.What kind of process do you want to perform on the input XML?
You said "reading", but for what purpose? Storing data in the database, or just transform the XML into another form?
Anyway, you'll probably need a function, something like :
create or replace function processXML (inputXML in xmltype)
return xmltype
is
outputXML xmltype;
begin
-- process inputXML here, and construct outputXML
return outputXML;
end;Back in Java, you can use the oracle.xdb.XMLType class to map the XMLType SQL datatype to a Java object and manipulate it. -
Hello,
I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
Suppose ,
Parameter value : person 1,person2,person3
table structure :
Project Name | officers 1 | officers 2
here, officers 1 or officers 2 may contain names of multiple people.
expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2.
please explain or provide solution in detail
- ThanksHi Visakh,
Thanks for reply.
But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
Your solution is working fine for following scenario :
Project
Officers 1
Officers 2
p1
of11
off21
p2
of12
off22
with parameter : of11,off22 : it will give expected output
And its not working in case of :
Project
Officers 1
Officers 2
p1
of11,of12
off21,off23
p2
of12,of13
off22,off24
with parameter : of11,off22 : it will not give any row in output
I need patten matching not exact match :)
ok
if thats the case use this modified logic
CREATE PROC GetProjectDetails
@PersonList varchar(5000)
AS
SELECT p.*
FROM ProjectTable p
INNER JOIN dbo.ParseValues(@PersonList,',')f
ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
GO
Keep in mind that what you've done is a wrong design approach
You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
Problems with Adobe Acrobat - last resort!
I've tried at the Adobe Macintosh forum, but haven't had any advice that's helped, so thought I'd try here!... I have Adobe CS3 Design Standard Suite, Educational version, running on OS X 10.5.5 on my MacBook Pro. 1 - I cannot update Acrobat from 8.0
-
Problem with image after exporting from Lightroom 5
Good day. Please can someone help me? I have Lightroom 5, and I have a problem in exporting edited images. At issue, do all the necessary settings and retreat noise and sharpness adjustment by brush adjustment tool, however, to export the image, nois
-
Dear Folks, In the transaction SPRO i find two kinds of check access 1. for files in the file system and 2 . for stored files . what is the difference between them . can XI carry out both XMl-based archiving and ADK based archiving. is it necessary
-
monitor too faint to read. the greays on my monitor are so faint, they're almost impossible to see. especially the numbers of the dates in ical. i've gone to system preferences and contrast controls. but no luck. any other suggestions? thank yo
-
I have one Nice Suggestion for the PC Suite which saves lot of time, that is offline editing of the contacts. If we can make the offlie contacts / new groups on pc than it saves lot of times as it can be synchronized later on pc to mobile. Thanks Mod