Thread: emedded SQL in C to get the record type from plpgsql

emedded SQL in C to get the record type from plpgsql

From
Sun Duozhong(孙多忠)
Date:
<div class="Section1"><p class="MsoPlainText"><span lang="EN-US" style="font-size:14.0pt">So how can emedded SQL in C
toget the record type which returning from plpgsql function?</span><p class="MsoPlainText"><span lang="EN-US"
style="font-size:14.0pt">Ihave tested as following code:</span><p class="MsoPlainText"><span lang="EN-US"> </span><p
class="MsoPlainText"><i><spanlang="EN-US">CREATE OR REPLACE FUNCTION test4(IN a integer, OUT b int,OUT c int) AS $BODY$
declarebegin b:=100; c:=200; return; END $BODY$</span></i><p class="MsoPlainText"><i><span lang="EN-US">  LANGUAGE
'plpgsql'VOLATILE</span></i><p class="MsoPlainText"><i><span lang="EN-US">  COST 100;</span></i><p
class="MsoPlainText"><i><spanlang="EN-US"> </span></i><p class="MsoPlainText"><i><span lang="EN-US"> </span></i><p
class="MsoPlainText"><i><spanlang="EN-US">// imbedded SQL in C</span></i><p class="MsoPlainText"><i><span
lang="EN-US">inttest(int a)</span></i><p class="MsoPlainText"><i><span lang="EN-US">{</span></i><p
class="MsoPlainText"><i><spanlang="EN-US"> </span></i><p class="MsoPlainText"><i><span lang="EN-US">EXEC SQL TYPE
my_typeIS STRUCT</span></i><p class="MsoPlainText"><i><span lang="EN-US">{</span></i><p class="MsoPlainText"><i><span
lang="EN-US">intb[1];</span></i><p class="MsoPlainText"><i><span lang="EN-US">int c[1];</span></i><p
class="MsoPlainText"><i><spanlang="EN-US">};</span></i><p class="MsoPlainText"><i><span lang="EN-US"> </span></i><p
class="MsoPlainText"><i><spanlang="EN-US">EXEC SQL BEGIN DECLARE SECTION;</span></i><p class="MsoPlainText"><i><span
lang="EN-US">my_typeppp;</span></i><p class="MsoPlainText"><i><span lang="EN-US">EXEC SQL END DECLARE
SECTION;</span></i><pclass="MsoPlainText"><i><span lang="EN-US"> </span></i><p class="MsoPlainText"><i><span
lang="EN-US">EXECSQL WHENEVER sqlerror SQLPRINT;</span></i><p class="MsoPlainText"><i><span lang="EN-US"> </span></i><p
class="MsoPlainText"><i><spanlang="EN-US">EXEC SQL select  test4(1) into :ppp;</span></i><p
class="MsoPlainText"><i><spanlang="EN-US">EXEC SQL COMMIT;</span></i><p class="MsoPlainText"><i><span
lang="EN-US">return0;</span></i><p class="MsoPlainText"><i><span lang="EN-US"> </span></i><p
class="MsoPlainText"><i><spanlang="EN-US">}</span></i><p class="MsoPlainText"><span lang="EN-US"> </span><p
class="MsoPlainText"><spanlang="EN-US" style="font-size:14.0pt">Running binary cause error:</span><p
class="MsoPlainText"><spanlang="EN-US" style="font-size:14.0pt">SQL error: invalid input syntax for type int:
"(100,200)",</span><pclass="MsoPlainText"><span lang="EN-US" style="font-size:14.0pt"> </span><p
class="MsoPlainText"><spanlang="EN-US" style="font-size:14.0pt">My project is migrating from Oracle to postgresql,can
youhelp me ?</span><p class="MsoNormal"><span lang="EN-US"> </span><p class="MsoNormal"><span lang="EN-US"> </span><p
class="MsoNormal"style="layout-grid-mode:char"><span lang="EN-US"
style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F3A87">Regards,</span><spanlang="EN-US"
style="font-size:10.0pt;font-family:"Verdana","sans-serif";
color:#1F3A87"></span><p class="MsoNormal" style="layout-grid-mode:char"><span lang="EN-US"
style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F3A87">George</span><b><spanlang="EN-US"
style="font-size:9.0pt;font-family:"ComicSans MS";color:teal"></span></b><p class="MsoNormal"
style="layout-grid-mode:char"><b><spanlang="EN-US" style="font-size:9.0pt;font-family:"Comic Sans
MS";color:teal">------------------------------------------------------------</span></b><spanlang="EN-US"></span><p
class="MsoNormal"><b><spanlang="EN-US" style="font-size:9.0pt;font-family:"他","serif"; 
color:teal">Duozhong Sun</span></b><b><span lang="EN-US" style="font-size:9.0pt;
font-family:"他","serif";color:teal"></span></b><p class="MsoNormal"><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";
color:teal">Guangdong Revenco Enterprise Co</span></b><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">.</span></b><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">Ltd</span></b><b><spanlang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">.</span></b><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">AMRIDepartment</span></b><b><span lang="EN-US"
style="font-size:9.0pt;font-family:
"他","serif";color:teal"></span></b><p class="MsoNormal"><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";
color:teal">Tel</span></b><b><span style="font-size:9.0pt;font-family:"他","serif";
color:teal">:</span></b><span lang="EN-US" style="font-size:9.0pt;font-family:
"他","serif";color:teal">+86 20 8713</span><span lang="EN-US" style="font-size:
9.0pt;font-family:"Comic Sans MS";color:teal"> </span><span lang="EN-US" style="font-size:9.0pt;font-family:"Times New
Roman","serif";color:teal">5305</span><spanlang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">,</span><spanlang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal">+8615800005957</span><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";
color:teal"></span><p class="MsoNormal"><b><span lang="EN-US" style="font-size:9.0pt;font-family:"他","serif";
color:teal">Fax</span></b><b><span style="font-size:9.0pt;font-family:"他","serif";
color:teal">:</span></b><span lang="EN-US" style="font-size:9.0pt;font-family:
"他","serif";color:teal">+86 20 87135388</span><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal"></span><pclass="MsoNormal"><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";
color:teal">Address</span></b><b><span style="font-size:9.0pt;font-family:"他","serif";
color:teal">:</span></b><span lang="EN-US" style="font-size:9.0pt;font-family:
"他","serif""><span style="color:teal">368 Guangzhou Avenue South</span><span style="color:teal">,</span><span
style="color:teal">Guangzhou</span><spanstyle="color:teal"> 510300</span></span><span lang="EN-US"
style="font-size:9.0pt;
font-family:"他","serif";color:teal">,</span><span lang="EN-US" style="font-size:
9.0pt;font-family:"他","serif";color:teal">P.R.C.</span><span lang="EN-US"
style="font-size:9.0pt;font-family:"他","serif";color:teal"></span><pclass="MsoNormal"><b><span lang="EN-US"
style="font-size:9.0pt;font-family:"ComicSans MS"; 
color:teal">------------------------------------------------------------</span></b><span lang="EN-US"></span><p
class="MsoNormal"><spanlang="EN-US"> </span></div> 

Re: emedded SQL in C to get the record type from plpgsql

From
Craig Ringer
Date:
Sun Duozhong(Ëï¶àÖÒ) wrote:
> So how can emedded SQL in C to get the record type which returning from
> plpgsql function?

You seem to have missed the fact that this isn't a web forum for help
questions. It's a bug report form. You are not reporting a bug. You are
not likely to get help by repeatedly posting via the bug report form.

Please ask for help on the pgsql-general mailing list or the
pgsql-newbies mailing list. I sent you the details for those in my last
email to you.

Failing that, you can get paid commercial support that will help you in
great detail from any one of a great many providers listed here:

   http://www.postgresql.org/support/professional_support_asia


--
Craig Ringer