Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing an Array from PL/SQL On Demand process to Javascript?How? (AJAX)

675865Dec 23 2008 — edited Dec 24 2008
Hello everyone,

I'm working with AJAX in APEX and right now i 'm developing an aplication which querys the database for results and returns the results to the javascript so that i can show them with the javascript

I need, preferably to return the query results in an array so that i can manipulate the same array in javascript without having to get the results and inserting them in an array to manipulate them.

I know it is possible in PHP to pass an array through the ajax request object to javascript and manipulate that object the very same way you would inside php.


I have tried creating something like this:

---------------------CODE--------------------------
DECLARE
auxcontent VARCHAR2(3000) :='' ;
type my_record is record( content_line varchar2(2000) );
type my_list is table of my_record index by binary_integer;
list my_list;
CURSOR content_cursor IS SELECT ent_cod,ent_nom FROM v_grh_funcionarios where rownum < 4;
content content_cursor%rowtype;
contador number;

BEGIN
contador := 0;
open content_cursor;
loop
fetch content_cursor into content;
exit when content_cursor%notfound;
begin
list(contador).content_line := content.ent_cod ||'~colsep~'|| content.ent_nom || '~colsep~
';
contador := contador + 1;


end;
end loop;
close content_cursor;
HTP.prn(list);
END;
---------------------CODE--------------------------

But it gives an error saying that type can't be used, how should i do it then?

Right now i m grouping everything in a single varchar2 variable , but that isn t viable since it has a limit and would be heavy parsing it afterwards again in the client, any way here is how i am doing now:


---------------------CODE--------------------------
DECLARE
auxcontent VARCHAR2(3000) :='' ;
type my_record is record( content_line varchar2(2000) );
type my_list is table of my_record index by binary_integer;
list my_list;
CURSOR content_cursor IS SELECT ent_cod,ent_nom FROM v_grh_funcionarios where rownum < 4;
content content_cursor%rowtype;
contador number;

BEGIN
contador := 0;
open content_cursor;
loop
fetch content_cursor into content;
exit when content_cursor%notfound;
begin
list(contador).content_line := content.ent_cod ||'~colsep~'|| content.ent_nom || '~colsep~
';
contador := contador + 1;
auxcontent := content.ent_cod ||'~colsep~'|| content.ent_nom || '~colsep~
';
HTP.prn(auxcontent);
end;
end loop;
close content_cursor;
END;
---------------------CODE--------------------------


I don't think the javascript side of my aplication need to be shown since it doesn t really relates to it right now, but if it is required i can psot it.
Any help would be apreciated cause altough i can use it for now i will have to change it soon.

Good hollydays everyone.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 21 2009
Added on Dec 23 2008
3 comments
1,453 views