0

こことWebで解決策を検索しましたが、経験の浅い他のエラーが発生しているようです(最初のビルドはPHPでしたが、今はストアドプロシージャに移動する必要があります)。私が持っているのは私のキャンパスの地図です。ユーザーが建物をクリックすると、情報バブルが開き、いくつかの情報と写真のギャラリーが表示されます。写真のアドレスはテーブルに格納されているため、それらをループできるように配列に戻す必要があります。リストを取得する呼び出しは次のとおりです。

$.ajax({ //get the picture URLs, load into array
        type: "post",
        url: "video_tour.get_pics",
        data: { pBldg_id:  building
        },
        error: function(xhr,thrownError) { alert("error get pics"); },
        success: function(data){
                  $.each(data, function(index,obj) {
                         picArray[index] = obj.ADDRESS;
                  });
        }
});//and ajax for pic load

および呼び出されたプロシージャ:

procedure get_pics(pBldg_id int) is
     type array_varchar is table of varchar2(2000) index by binary_integer;

     array_of_pics array_varchar;
     v_counter int := 0;
begin

for i in(select address from ucs.campus_pictures where building_id = pBldg_id and thumbnail = 1) loop
     array_of_pics(v_counter) := i.address;
     v_counter := v_counter + 1;
end loop;               

end get_pics;

array_of_pics を ajax 呼び出しに戻すにはどうすればよいですか?

4

2 に答える 2

0

したがって、見た目ほど複雑ではありませんでした。データが出力されたときにデータを印刷し、区切り文字を追加するだけです。

  for i in(select address from ucs.campus_pictures where building_id = pBldg_id and thumbnail = 1) loop
htp.prn(i.address || ';');
end loop; 

そして、ajax呼び出しで配列を作成します。

 $.ajax({ //get the picture URLs, load into array
                     type: "post",
                     url: "video_tour.get_pics",
                     data: { pBldg_id:  building
                     },
                     error: function(xhr,thrownError) { alert("error get pics"); }, 
                     success: function(data){
                      $.each(data.split(";"), function(index,obj) {
                                    picArray[index] = obj;
                              });

                     }
            });

時間を割いて助けてくれてありがとう!

于 2012-05-21T22:27:50.490 に答える
0

リクエストを処理してからプロシージャを呼び出すミドルウェア(PHPページであっても)があると仮定しています。そこから始めて、実際にカーソルを返す必要があります (以下の例を参照)。ミドルウェアでは、カーソルからの結果セットをループします。

    create or replace function get_pics(bldg_id_in ucs.campus_pictures.building_id%TYPE)
return sys_refcursor
as
ref_cursor sys_refcursor;
begin
   open ref_cursor for
     select address from ucs.campus_pictures where building_id = bldg_id_in and thumbnail = 1;
   return ref_cursor;
end;
于 2012-05-18T01:50:41.480 に答える