Skip to Main Content
  • Questions
  • how to pass javascript variable value to pl/sql variable

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Anuj.

Asked: May 30, 2000 - 7:16 am UTC

Last updated: June 06, 2006 - 9:43 pm UTC

Version: 4

Viewed 1000+ times

You Asked

Hi,
i am facing a problem in oracle web application server. i am creating pl sql cart. and using web packages like HTP,owa_sec. etc well i want to know how can i pass a java script variable holding some value to pl/sql
for example
let us say we have a
create or reeplace procedure anujname
as
begin
htp.p('<script language=javascript>')
htp.p('var mgrname= "Anuj";');
htp</script>');

Now i want to run a sql qery to form the procedure to to find out how many employee are under "Anuj" which is hold in a variable mgrname as metioned above.

please send me some solution if u have or have any idea to do about . i was able to pass the sql variable to javascript variable but vice versa is not possible

thanks and regards
Anuj Chauhan

and Tom said...

Well, you must remember that javascript runs on the browser and its PLSQL that is writing the javascript. PLSQL isn't "passing a variable" to javascript - PLSQL is writing some javascript with a specific variable value.


I think you may be interested in a solution we had to dependent drop down lists. It was desired that when a list value changed on the client browser, another list was updated with values based on that (very similar to your desire to have javascript pass plsql a variable).


see
</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:234614318676 <code>
for that solution. We use 2 framesets to make this happen -- one hidden page calls plsql via a URL when needed to get the related data. Small demo online as well.




Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks

Emilija, June 06, 2006 - 8:23 pm UTC

Hi Tom,

Thank you very much for providing an explanation why is this not possible.

Thanks for the example, too.

Emilija

Tom Kyte
June 06, 2006 - 9:43 pm UTC

"ajax" - which didn't exist way back when - would today be another approach.

APEX (htmldb) makes use of that feature.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library