------=_Part_82102_14265828.1166774595504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 12/21/06, Sandip <sandip (AT) singapore (DOT) com> wrote:
Quote:
CREATE OR REPLACE FUNCTION sp_get_phase(character varying, character
varying, character varying)
RETURNS ret_dv_sp_get_phase AS
$BODY$
SELECT BOOK_NO, USER_ID, COMPANY_ID, PHASE, UPDATE_USER_ID,
UPDATE_DATE,
AddInfo1, AddInfo2
FROM T_PHASE
WHERE (USER_ID = $1) AND (COMPANY_ID = $2) AND BOOK_NO IN ($3)
$BODY$
LANGUAGE 'sql' VOLATILE;
select * from sp_get_phase ('sandip', 'oms', '1,4') this return a Blank
record. |
For this function call, the SELECT inside the function gets translated into
SELECT ...
FROM T_PHASE
WHERE (USER_ID = 'sandip') AND (COMPANY_ID = 'oms') AND BOOK_NO IN
('1,4')
Notice the quotes around the list of values for $3. So you can see that the
IN list contains just one value and not two as you might have expected.
You'll need to do some trickery. Try the EXECUTE, perhaps that might help!!!
I tried to execute the SQL statement from the function
Quote:
SELECT BOOK_NO, USER_ID, COMPANY_ID, PHASE, UPDATE_USER_ID,
UPDATE_DATE,
AddInfo1, AddInfo2
FROM T_PHASE
WHERE (USER_ID = 'testUser') AND (COMPANY_ID = 'testCompany')
AND
BOOK_NO IN (1,4)
----- This Works fine... returns 2 records. What may be the problem?
Best regards,
|
--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | yahoo }.com
------=_Part_82102_14265828.1166774595504
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On 12/21/06, <b class="gmail_sendername">Sandip</b> <<a href="mailto:sandip (AT) singapore (DOT) com">sandip (AT) singapore (DOT) com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
CREATE OR REPLACE FUNCTION sp_get_phase(character varying, character<br>varying, character varying)<br> RETURNS ret_dv_sp_get_phase AS<br>$BODY$<br>SELECT &nbs p; BOOK_NO, USER_ID, COMPANY_ID, PHASE, UPDATE_USER_ID,<br>
UPDATE_DATE,<br> &nbs p; Ad dInfo1, AddInfo2<br>FROM &nbs p; T_PHASE<br>W HERE &nbs p; (USER_ID = $1) AND (COMPANY_ID = $2) AND BOOK_NO IN ($3)<br>$BODY$<br> LANGUAGE 'sql' VOLATILE;<br><br><br>select * from sp_get_phase ('sandip', 'oms', '1,4') this return a Blank
<br>record.</blockquote><div><br>For this function call, the SELECT inside the function gets translated into <br><br> </div><br><div><br>SELECT &nb sp; ...<br>FROM &nb sp; T_PHASE<br>WHERE& nbsp; &nb sp; (USER_ID = 'sandip') AND (COMPANY_ID = 'oms') AND BOOK_NO IN ('1,4')
<br><br>Notice the quotes around the list of values for $3. So you can see that the IN list contains just one value and not two as you might have expected. You'll need to do some trickery. Try the EXECUTE, perhaps that might help!!!
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I tried to execute the SQL statement from the function<br><br>SELECT &nbs p; BOOK_NO, USER_ID, COMPANY_ID, PHASE, UPDATE_USER_ID,
<br>UPDATE_DATE,<br> &n bsp; &nbs p;AddInfo1, AddInfo2<br>FROM &nbs p; T_PHASE<br>W HERE &nbs p; (USER_ID = 'testUser') AND (COMPANY_ID = 'testCompany') AND<br>BOOK_NO IN (1,4)<br><br>----- This Works fine... returns 2 records. What may be the problem?
<br><br></blockquote></div><br>Best regards,<br><br clear="all"><br>-- <br>gurjeet[.singh]@EnterpriseDB.com<br>singh.gurjeet@{ gmail | hotmail | yahoo }.com
------=_Part_82102_14265828.1166774595504--