<h3 class="EP8xU" style="color: rgb(121, 6, 25);"><span>kubo $B$5$s(B</span></h3> 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"><<a href="mailto:dbflute@gmail.com">dbflute@gmail.com</a>></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>
> 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>
('creating' means DDL 'CREATE OR REPLACE FUNCTION')<br>
<br>
Which is your purpose about SQL functions in outside-SQL<br>
Creating or Calling?<br>
<br>
If it's Calling(Maybe I think it'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's outside-SQL<br>
<br>
Please check out 'dbflute-postgresql-example' 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 'VendorCheckTest.java' 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'CREATE OR REPLACE FUNCTION'$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'dbflute-postgresql-example'$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'VendorCheckTest.java'$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 <<a href="mailto:jp.mcy.10@gmail.com">jp.mcy.10@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hai all,<br>
><br>
> I am new to dbflute.<br>
> I have one doubt.can dbflute support SQL functions.<br>
><br>
> i wrote one SQL functions,but i have to use this function in dbflute<br>
><br>
> can any body help me in this.....<br>
><br>
><br>
> Here i attached my sql Function<br>
><br>
><br>
> -- #GrowthRateDealerFunction#<br>
> -- !GrowthRateDealerFunctionPmb!<br>
> -- !!String Nsccode!!<br>
> -- !!Date fromDate1!!<br>
> -- !!Date toDate1!!<br>
> -- !!Date fromDate2!!<br>
> -- !!Date toDate2!!<br>
><br>
> CREATE OR REPLACE FUNCTION get_GrowthRate_dealer()<br>
> RETURNS SETOF growth_dealer_type<br>
> AS '<br>
> DECLARE<br>
> growth growth_dealer_type;<br>
> dealer RECORD;<br>
> BEGIN<br>
> FOR dealer IN<br>
> select distinct tdealer.dealercode from mnsc,tdealer,tdos where<br>
> tdealer.nsccode=mnsc.nsccode<br>
> and tdealer.dealercode=tdos.dealercode and<br>
> /*IF GrowthRateDealerFunctionPmb.nsccode!= null*/mnsc.nsccode=/*IF<br>
> GrowthRateDealerFunctionPmb.nsccode*/''China''<br>
><br>
> LOOP<br>
><br>
> growth.dealercode:=dealer.dealercode;<br>
> growth.periodone:=(select count(*) from tdos,tdealer,mnsc,mstandard<br>
> where tdos.standardcode = mstandard.standardcode and<br>
> tdos.dealercode=tdealer.dealercode and<br>
> tdealer.nsccode = mnsc.nsccode and<br>
> tdos.dosresult = 1 and<br>
> tdealer.dealercode=dealer.dealercode and<br>
> tdos.dosnakbn = 0 and<br>
> tdos.dosdatersv1 between<br>
> /*GrowthRateDealerFunctionPmb.fromDate1*/''2006/11/1'' and<br>
> /*GrowthRateDealerFunctionPmb.toDate1*/ ''2007/4/1'');<br>
> growth.periodtwo:=(select count(*) from tdos,tdealer,mnsc,mstandard<br>
> where tdos.standardcode = mstandard.standardcode and<br>
> tdos.dealercode=tdealer.dealercode and<br>
> tdealer.nsccode = mnsc.nsccode and<br>
> tdealer.dealercode=dealer.dealercode and<br>
> tdos.dosresult = 1 and<br>
> tdos.dosnakbn = 0 and<br>
> tdos.dosdatersv1 between<br>
> /*GrowthRateDealerFunctionPmb.fromDate2*/''2007/4/1'' and<br>
> /*GrowthRateDealerFunctionPmb.toDate2*/''2008/11/1'');<br>
> if(growth.periodtwo!=0) then<br>
> growth.growth_rate =<br>
> (round((growth.periodtwo-growth.periodone)*100/(1.0*growth.periodtwo),0));<br>
> else<br>
> growth.growth_rate =0;<br>
> end if;<br>
> RETURN NEXT growth;<br>
> END LOOP;<br>
> RETURN;<br>
> END;<br>
> ' LANGUAGE plpgsql STRICT;<br>
><br>
> This is my SQL function.<br>
><br>
> if i run SQL2Entity,it shows following Error..<br>
><br>
> BUILD FAILED<br>
> C:\AgnieWork\workspace\nsdos\mydbflute\dbflute-0.8.4\build-torque.xml:323:<br>
> org.s<br>
> easar.dbflute.helper.jdbc.sqlfile.DfSQLExecutionFailureException: Look! Read<br>
> the<br>
> message below.<br>
> /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *<br>
> It failed to execute the SQL!<br>
><br>
> [SQL File]<br>
> ..\src\main\resources\sql\growthrate\growthrateDealer.sql<br>
><br>
> [Executed SQL]<br>
> -- #GrowthRateDealerFunction#<br>
> -- !GrowthRateDealerFunctionPmb!<br>
> -- !!String Nsccode!!<br>
> -- !!Date fromDate1!!<br>
> -- !!Date toDate1!!<br>
> -- !!Date fromDate2!!<br>
> -- !!Date toDate2!!<br>
><br>
> CREATE OR REPLACE FUNCTION get_GrowthRate_dealer()<br>
> RETURNS SETOF growth_dealer_type<br>
> AS '<br>
> DECLARE<br>
> growth growth_dealer_type<br>
><br>
> [SQLState]<br>
> 42601<br>
><br>
> [ErrorCode]<br>
> 0<br>
><br>
> [SQLException]<br>
> org.postgresql.util.PSQLException<br>
> ERROR: unterminated quoted string at or near "'<br>
> DECLARE<br>
> growth growth_dealer_type"<br>
> * * * * * * * * * */<br>
><br>
> Thanks in advance<br>
> $B%H%^%9(B<br>
><br>
</div></div>> _______________________________________________<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>
><br>
><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>