{"id":12725,"date":"2024-05-31T17:47:24","date_gmt":"2024-05-31T09:47:24","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=12725"},"modified":"2024-05-31T17:47:25","modified_gmt":"2024-05-31T09:47:25","slug":"%e5%8d%97%e5%a4%a7%e9%80%9a%e7%94%a8gbase-8a%e6%89%a7%e8%a1%8c%e5%8c%85%e5%90%abselect-into-%e5%8f%98%e9%87%8f%e5%8a%a8%e6%80%81sql","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/12725","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u6267\u884c\u5305\u542bselect into \u53d8\u91cf\u52a8\u6001SQL"},"content":{"rendered":"<p>\u4e00\u4e2a\u52a8\u6001SQL\u8bed\u53e5\uff0c\u5982\u679c\u8981\u628a\u6267\u884c\u7684\u4e00\u4e9b\u7ed3\u679c\u4fdd\u5b58\u5230\u53d8\u91cf\u4e2d\uff0c\u53ef\u4ee5\u7528select into \u7684\u65b9\u6cd5\uff0c\u4f46\u4e0d\u80fd\u662f\u672c\u5730\u53d8\u91cf\uff0c\u5fc5\u987b\u662fsession\u7ea7\u7684\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2aa4f9a3016\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2aa4f9a3016\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/12725\/#%E4%BD%BF%E7%94%A8%E6%9C%AC%E5%9C%B0%E5%8F%98%E9%87%8F%E6%8A%A5%E9%94%99\" >\u4f7f\u7528\u672c\u5730\u53d8\u91cf\u62a5\u9519<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/12725\/#%E4%BD%BF%E7%94%A8sesssion%E5%8F%98%E9%87%8F%E6%88%90%E5%8A%9F\" >\u4f7f\u7528sesssion\u53d8\u91cf\u6210\u529f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/12725\/#%E6%80%BB%E7%BB%93\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8%E6%9C%AC%E5%9C%B0%E5%8F%98%E9%87%8F%E6%8A%A5%E9%94%99\"><\/span>\u4f7f\u7528\u672c\u5730\u53d8\u91cf\u62a5\u9519<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>ERROR 1327 (42000): Undeclared variable: num<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>drop procedure if exists get_gc_task2;\r\ndelimiter \/\/\r\ncreate procedure get_gc_task2(in strlen int,in top int)\r\nbegin\r\n  declare num int;\r\n  set @executeSQL_sql='select count(*) into num from t1';\r\n  select @executeSQL_sql;\r\n  PREPARE executeSQL_s1 FROM @executeSQL_sql ;\r\n  EXECUTE executeSQL_s1;\r\n  DEALLOCATE PREPARE executeSQL_s1;\r\n\r\n  select strlen,top,now(),num from dual;\r\n  \r\nend\/\/\r\ndelimiter ;\r\ncall get_gc_task2(1,2);<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u7ed3\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"534\" height=\"435\" src=\"https:\/\/www.gbase8.cn\/wp-content\/uploads\/2024\/05\/image-1.png\" alt=\"\" class=\"wp-image-12727\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8sesssion%E5%8F%98%E9%87%8F%E6%88%90%E5%8A%9F\"><\/span>\u4f7f\u7528sesssion\u53d8\u91cf\u6210\u529f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>session\u53d8\u91cf\u7528@\u5f00\u5934\uff0c\u53ea\u8981\u5f53\u524dsession\u90fd\u53ef\u4ee5\u4f7f\u7528\uff0c\u6240\u4ee5\u4e5f\u8981\u6ce8\u610f\u4e0d\u8981\u548c\u5176\u5b83\u5730\u65b9\u4f7f\u7528\u7684\u53d1\u751f\u547d\u540d\u91cd\u590d\uff0c\u5bfc\u81f4\u7ed3\u679c\u9519\u8bef\u3002\u5efa\u8bae\u7528\u5305\u542b\u8fc7\u7a0b\u540d\u5b57\u7684\u53d8\u91cf\uff0c\u6bd4\u5982@get_gc_task2_AAA\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>drop procedure if exists get_gc_task2;\r\ndelimiter \/\/\r\ncreate procedure get_gc_task2(in strlen int,in top int)\r\nbegin\r\n  declare num int;\r\n  set @executeSQL_sql='select count(*) into @get_gc_task2_AAAfrom t1';\r\n  select @executeSQL_sql;\r\n  PREPARE executeSQL_s1 FROM @executeSQL_sql ;\r\n  EXECUTE executeSQL_s1;\r\n  DEALLOCATE PREPARE executeSQL_s1;\r\n  set num=@get_gc_task2_AAA;\r\n  select strlen,top,now(),num from dual;\r\n  \r\nend\/\/\r\ndelimiter ;\r\ncall get_gc_task2(1,2);<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u7ed3\u679c<\/p>\n\n\n\n<p>\u5176\u4e2d\u53d8\u91cf\u6211\u7528\u7684@AAA\uff0c\u5c31\u4e0d\u6539\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"549\" height=\"497\" src=\"https:\/\/www.gbase8.cn\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" class=\"wp-image-12726\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%80%BB%E7%BB%93\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5728\u52a8\u6001\u8bed\u53e5\u6267\u884c\u65f6\uff0c\u4e0a\u4e0b\u6587\u5df2\u7ecf\u53d8\u4e86\uff0c\u65e0\u6cd5\u76f4\u63a5\u8bbf\u95ee\u8c03\u7528\u8005\u7684\u672c\u5730\u53d8\u91cf\uff0c\u4f46session\u7ea7\u7684\u662f\u53ef\u4ee5\u7528\u7684\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2a\u52a8\u6001SQL\u8bed\u53e5\uff0c\u5982\u679c\u8981\u628a\u6267\u884c\u7684\u4e00\u4e9b\u7ed3\u679c\u4fdd\u5b58\u5230\u53d8\u91cf\u4e2d\uff0c\u53ef\u4ee5\u7528select into \u7684\u65b9\u6cd5\uff0c\u4f46\u4e0d\u80fd\u662f\u672c\u5730\u53d8\u91cf\uff0c\u5fc5\u987b\u662fsession\u7ea7\u7684<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-12725","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=12725"}],"version-history":[{"count":1,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12725\/revisions"}],"predecessor-version":[{"id":12728,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/12725\/revisions\/12728"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=12725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=12725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=12725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}