<h3 class="EP8xU" style="color: rgb(121, 6, 25);"><span>kubo $B$5$s(B</span></h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thank you for your kind reply...<br>I got solution for my problem after your instrunctions....<br><br><br><div class="gmail_quote">On Tue, Dec 2, 2008 at 6:02 PM, kubo <span dir="ltr">&lt;<a href="mailto:dbflute@gmail.com">dbflute@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">$B5WJ](B(jflute)$B$G$9!#(B<br>
<br>
Hello, John<br>
<div class="Ih2E3d"><br>
&gt; I am new to dbflute.<br>
</div>Thank you for your using DBFlute!<br>
<br>
I answer by both English and Japanese<br>
because I am NOT good at English.<br>
So if you have someone who understands Japanese,<br>
please request him to read the Japanese answer.<br>
<br>
<br>
[English Answer]<br>
The creating SQL functions in outside-SQL is unsupported now.<br>
(&#39;creating&#39; means DDL &#39;CREATE OR REPLACE FUNCTION&#39;)<br>
<br>
Which is your purpose about SQL functions in outside-SQL<br>
 &nbsp;Creating or Calling?<br>
<br>
If it&#39;s Calling(Maybe I think it&#39;s Calling),<br>
Please create the SQL function at the timing of creating database schema?<br>
<br>
1. prepare DDL contains SQL functions<br>
2. run ReplaceSchema<br>
3. run JDBC and Generate and Sql2Entity<br>
4. call SQL function by behavior&#39;s outside-SQL<br>
<br>
Please check out &#39;dbflute-postgresql-example&#39; from SVN repogitry.<br>
And refer to it. This example project has the example of the SQL functions<br>
for PostgreSQL.<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example</a><br>
<br>
A. Please watch the SQL(DDL) for replace-schema that contains creating<br>
SQL functions.<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/playsql/replace-schema-vendorcheck.sql" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/playsql/replace-schema-vendorcheck.sql</a><br>

<br>
B. Please watch the setting for stored procedures of outside-SQL.<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/dfprop/outsideSqlDefinitionMap.dfprop" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/dfprop/outsideSqlDefinitionMap.dfprop</a><br>

<br>
C. Please watch the class &#39;VendorCheckTest.java&#39; that contains calling<br>
SQL functions.<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/src/test/java/com/example/dbflute/postgresql/dbflute/various/VendorCheckTest.java" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/src/test/java/com/example/dbflute/postgresql/dbflute/various/VendorCheckTest.java</a><br>

<br>
If you have doubt about detail again, please question again.<br>
<br>
<br>
[Japanese Answer]<br>
$B8=:_$O30$@$7(BSQL$B$NCf$G%U%!%s%/%7%g%s$r:n@.$9$k$3$H$O%5%]!<%H$5$l$^$;$s!#(B<br>
($B$3$3$G$$$&:n@.$9$k$H$$$&$N$O(B&#39;CREATE OR REPLACE FUNCTION&#39;$B$N(BDDL$BJ8$3$H$G$9(B)<br>
<br>
$B30$@$7(BSQL$B$NCf$G%U%!%s%/%7%g%s$r07$&L\E*$O!"(B<br>
$B!V:n@.$9$k$3$H!W$G$7$g$&$+!)$=$l$H$b!V8F$S=P$9$3$H!W$G$7$g$&$+!)(B<br>
<br>
$B$b$7!"!V8F$S=P$9$3$H!W$J$N$G$"$l$P(B($BB?J,!V8F$S=P$9$3$H!W$@$H;W$$$^$9$,(B)$B!"(B<br>
$B%G!<%?%Y!<%9%9%-!<%^$r:n@.$9$k;~E@$G$=$N%U%!%s%/%7%g%s$r:n@.$7$F2<$5$$!#(B<br>
<br>
1. $B%U%!%s%/%7%g%s$r4^$s$@(BDDL$B$r=`Hw(B<br>
2. ReplaceSchema$B$r<B9T(B<br>
3. JDBC$B$H(BGenerate$B$H(BSql2Entity$B$r<B9T(B<br>
4. Behavior$B$N(Boutside-SQL$B$+$i%U%!%s%/%7%g%s$r8F$S=P$9(B<br>
<br>
SVN$B%j%]%8%H%j$+$i(B&#39;dbflute-postgresql-example&#39;$B$r%A%'%C%/%"%&%H$7$F$=$l$r;29M$K$7$F2<$5$$!#(B<br>
$B$3$N(BExample$B%W%m%8%'%/%H$K$O(BPostgreSQL$B$N%U%!%s%/%7%g%s$K4X$9$k(BExample$B$,$"$j$^$9!#(B<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example</a><br>
<br>
1. $B%U%!%s%/%7%g%s$r:n@.$7$F$$$k(BReplaceSchema$BMQ$N(BSQL(DDL)$B$r$4Mw$/$@$5$$!#(B<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/playsql/replace-schema-vendorcheck.sql" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/playsql/replace-schema-vendorcheck.sql</a><br>

<br>
2. $B30$@$7(BSQL$B$N%9%H%"%I%W%m%7!<%8%c$N@_Dj$r$4Mw$/$@$5$$!#(B<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/dfprop/outsideSqlDefinitionMap.dfprop" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/dbflute_exampledb/dfprop/outsideSqlDefinitionMap.dfprop</a><br>

<br>
3. $B%U%!%s%/%7%g%s$r8F$S=P$7$F$$$k(B&#39;VendorCheckTest.java&#39;$B%/%i%9$r$4Mw$/$@$5$$!#(B<br>
<a href="https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/src/test/java/com/example/dbflute/postgresql/dbflute/various/VendorCheckTest.java" target="_blank">https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-postgresql-example/src/test/java/com/example/dbflute/postgresql/dbflute/various/VendorCheckTest.java</a><br>

<br>
$B$b$7!":Y$+$$$H$3$m$G5?Ld$,$"$j$^$7$?$i:FEY$4<ALd$/$@$5$$!#(B<br>
<br>
<br>
<br>
<br>
2008/12/2 John Peter &lt;<a href="mailto:jp.mcy.10@gmail.com">jp.mcy.10@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; Hai all,<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I am new to dbflute.<br>
&gt; I have one doubt.can dbflute support SQL functions.<br>
&gt;<br>
&gt; i wrote one SQL functions,but i have to use this function in dbflute<br>
&gt;<br>
&gt; can any body help me in this.....<br>
&gt;<br>
&gt;<br>
&gt; Here i attached my sql Function<br>
&gt;<br>
&gt;<br>
&gt; -- #GrowthRateDealerFunction#<br>
&gt; -- !GrowthRateDealerFunctionPmb!<br>
&gt; -- !!String Nsccode!!<br>
&gt; -- !!Date fromDate1!!<br>
&gt; -- !!Date toDate1!!<br>
&gt; -- !!Date fromDate2!!<br>
&gt; -- !!Date toDate2!!<br>
&gt;<br>
&gt; CREATE OR REPLACE FUNCTION get_GrowthRate_dealer()<br>
&gt; &nbsp; RETURNS SETOF growth_dealer_type<br>
&gt; &nbsp; AS &#39;<br>
&gt; DECLARE<br>
&gt; &nbsp; growth growth_dealer_type;<br>
&gt; &nbsp; dealer RECORD;<br>
&gt; BEGIN<br>
&gt; &nbsp; FOR dealer IN<br>
&gt; &nbsp; &nbsp; select distinct tdealer.dealercode from mnsc,tdealer,tdos where<br>
&gt; tdealer.nsccode=mnsc.nsccode<br>
&gt; and tdealer.dealercode=tdos.dealercode and<br>
&gt; /*IF GrowthRateDealerFunctionPmb.nsccode!= null*/mnsc.nsccode=/*IF<br>
&gt; GrowthRateDealerFunctionPmb.nsccode*/&#39;&#39;China&#39;&#39;<br>
&gt;<br>
&gt; &nbsp; LOOP<br>
&gt;<br>
&gt; &nbsp; &nbsp; growth.dealercode:=dealer.dealercode;<br>
&gt; &nbsp; &nbsp; growth.periodone:=(select count(*) from tdos,tdealer,mnsc,mstandard<br>
&gt; where tdos.standardcode = mstandard.standardcode and<br>
&gt; tdos.dealercode=tdealer.dealercode and<br>
&gt; tdealer.nsccode = mnsc.nsccode and<br>
&gt; tdos.dosresult = 1 and<br>
&gt; tdealer.dealercode=dealer.dealercode and<br>
&gt; tdos.dosnakbn = 0 and<br>
&gt; tdos.dosdatersv1 between<br>
&gt; /*GrowthRateDealerFunctionPmb.fromDate1*/&#39;&#39;2006/11/1&#39;&#39; and<br>
&gt; /*GrowthRateDealerFunctionPmb.toDate1*/ &#39;&#39;2007/4/1&#39;&#39;);<br>
&gt; growth.periodtwo:=(select count(*) from tdos,tdealer,mnsc,mstandard<br>
&gt; where tdos.standardcode = mstandard.standardcode and<br>
&gt; tdos.dealercode=tdealer.dealercode and<br>
&gt; tdealer.nsccode = mnsc.nsccode and<br>
&gt; tdealer.dealercode=dealer.dealercode and<br>
&gt; tdos.dosresult = 1 and<br>
&gt; tdos.dosnakbn = 0 and<br>
&gt; tdos.dosdatersv1 between<br>
&gt; /*GrowthRateDealerFunctionPmb.fromDate2*/&#39;&#39;2007/4/1&#39;&#39; and<br>
&gt; /*GrowthRateDealerFunctionPmb.toDate2*/&#39;&#39;2008/11/1&#39;&#39;);<br>
&gt; if(growth.periodtwo!=0) then<br>
&gt; growth.growth_rate =<br>
&gt; (round((growth.periodtwo-growth.periodone)*100/(1.0*growth.periodtwo),0));<br>
&gt; else<br>
&gt; growth.growth_rate =0;<br>
&gt; end if;<br>
&gt; &nbsp; &nbsp; RETURN NEXT growth;<br>
&gt; &nbsp; END LOOP;<br>
&gt; &nbsp; RETURN;<br>
&gt; END;<br>
&gt; &#39; LANGUAGE plpgsql STRICT;<br>
&gt;<br>
&gt; This is my SQL function.<br>
&gt;<br>
&gt; if i run SQL2Entity,it shows following Error..<br>
&gt;<br>
&gt; BUILD FAILED<br>
&gt; C:\AgnieWork\workspace\nsdos\mydbflute\dbflute-0.8.4\build-torque.xml:323:<br>
&gt; org.s<br>
&gt; easar.dbflute.helper.jdbc.sqlfile.DfSQLExecutionFailureException: Look! Read<br>
&gt; the<br>
&gt; &nbsp;message below.<br>
&gt; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *<br>
&gt; It failed to execute the SQL!<br>
&gt;<br>
&gt; [SQL File]<br>
&gt; ..\src\main\resources\sql\growthrate\growthrateDealer.sql<br>
&gt;<br>
&gt; [Executed SQL]<br>
&gt; -- #GrowthRateDealerFunction#<br>
&gt; -- !GrowthRateDealerFunctionPmb!<br>
&gt; -- !!String Nsccode!!<br>
&gt; -- !!Date fromDate1!!<br>
&gt; -- !!Date toDate1!!<br>
&gt; -- !!Date fromDate2!!<br>
&gt; -- !!Date toDate2!!<br>
&gt;<br>
&gt; CREATE OR REPLACE FUNCTION get_GrowthRate_dealer()<br>
&gt; &nbsp; RETURNS SETOF growth_dealer_type<br>
&gt; &nbsp; AS &#39;<br>
&gt; DECLARE<br>
&gt; &nbsp; growth growth_dealer_type<br>
&gt;<br>
&gt; [SQLState]<br>
&gt; 42601<br>
&gt;<br>
&gt; [ErrorCode]<br>
&gt; 0<br>
&gt;<br>
&gt; [SQLException]<br>
&gt; org.postgresql.util.PSQLException<br>
&gt; ERROR: unterminated quoted string at or near &quot;&#39;<br>
&gt; DECLARE<br>
&gt; &nbsp; growth growth_dealer_type&quot;<br>
&gt; * * * * * * * * * */<br>
&gt;<br>
&gt; Thanks in advance<br>
&gt; $B%H%^%9(B<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Seasar-user mailing list<br>
&gt; <a href="mailto:Seasar-user@ml.seasar.org">Seasar-user@ml.seasar.org</a><br>
&gt; <a href="https://ml.seasar.org/mailman/listinfo/seasar-user" target="_blank">https://ml.seasar.org/mailman/listinfo/seasar-user</a><br>
&gt;<br>
&gt;<br>
_______________________________________________<br>
Seasar-user mailing list<br>
<a href="mailto:Seasar-user@ml.seasar.org">Seasar-user@ml.seasar.org</a><br>
<a href="https://ml.seasar.org/mailman/listinfo/seasar-user" target="_blank">https://ml.seasar.org/mailman/listinfo/seasar-user</a><br>
</blockquote></div><br>