FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


help convert this to oracle function [SOLVED]





badai
i don't know anything about orcale. say, you have this in php:

Code:
function some_function($seq) {
   $ret = '';
   $qy = "select some_field from some_table where seq = ".$seq;
   $rs = mysql_query($qy);
   for ($i = 0; $i < mysql_numrows($rs); $i++) {
     if ('' != $ret)
        $ret .= ', ';
     $ret .= mysql_result($rs, $i, "some_field");
   }
   return $ret;
}


how to write this in oracle function? please note that if no result is return, the function still can handle it by simply return blank, maybe just check if mysql_numrows($rs) == 0, then return ''

thanks.

=======SOLVED=============

Code:

CREATE OR REPLACE
FUNCTION "SOME_FUNCTION" (SOME_SEQ IN NUMBER)
RETURN VARCHAR2
IS
RET VARCHAR2(512);
CURSOR C1 is SELECT SOME_FIELD FROM SOME_TABLE WHERE SEQ = SOME_SEQ ORDER BY SOME_FIELD ASC;
BEGIN
   RET := '';
   FOR SOME_VAR IN C1
   LOOP
      IF (LENGTH(RET) > 0) then
         RET := CONCAT(RET, ', ');
      END IF;
      RET := CONCAT(RET, SOME_VAR.SOME_FIELD);
   END LOOP;
   RETURN RET;
END;
Related topics
Search function
Please....I need help! (please close problem solved)
HELP!PLZ HELP ME!Convert swf to gif
php..free account help
Any program that modifies picture resolution?
Online string comment
Need help fixing some js.. F$500 (long post)
DEV C++ HAS NO SLEEP FUNCTION!! SOLVED!
Media wiki help for 150 frih$ [Solved]
Error with MySQL and PHP script in my CMS
Convert from PDF format to Word Document...
What to eat for staying healthy
A Healthy Diet for Life
Help with a query[solved]
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.