SQL Query in Javascript

Hi All,
I have an SQL query which needs to be invoked when ever javscript function is called.
Is it possible in Oracle Apex to embed a SQL query in the javascript function...If so, Please can anyone provide me with a right syntax ???
Regards,
Sandeep Reddy

Thank you so much for your reply..
I tried implementing it but facing the problem in PL/SQL code defined in the application process.. I am getting the coloum name is invalid..however, the coloum is valid for the table.
declare
lineprice LINEITEM%rowtype;
Begin
select LineUnitPrice
into lineprice
from LINEITEM
where PriceCategoryID = :PRICECATEGORY AND LineItemID = :LINEITEM;
htp.prn(lineprice);
exception when others then htp.prn('An error occurred retrieving record');
end;
sqlerrm:ORA-06550: line 7, column 45:PL/SQL: ORA-00904: "LINEITEMID": invalid identifierORA-06550: line 4, column 1:PL/SQL: SQL Statement ignoredORA-06550: line 8, column 1:PLS-00306: wrong number or types of arguments in call to 'PRN'ORA-06550: line 8, column 1:PL/SQL: Statement ignored
Please let me the know the correct path to sort out this problem..

Similar Messages

  • PostGre SQL Query In JavaScript

    Is it possible to run the query in the javascript.
    I wil b passing an id from the jstl to a method which is implemented in javascript .using that id can i access the values from the database?
    plz send me some dummy code if possible
    Thanks ..

    There's a very simply difference between PHP and JavaScript:
    PHP runs on the Server.
    JavaScript runs on the Client. (*)
    That's a pretty big difference.
    (*) Strictly speaking both could theoretically run both on the Server and Client, but that's the common setting.

  • Embedding javascript in a sql query

    Hello everybody,
    that is the question, how can a JavaScript function like: getElementById
    can be (if at all be embedded in a sql query? the thing is that when I do the query
    SELECT firstname, lastname etc
    WHERE branchnumber = here is where I want to include the javascript function so that it gets the value from a manually inserted value in a text field that the user enters.
    the item name is P3_X (which is a textfield)
    I would like to put something like
    WHERE branchnumber = getElementById('P3_X').value);
    but it does not parse it ..
    so I may be close but there is something that is not right

    Thank you for your good will Mennam from Turkey. I have found another way of solving it, in the data expresss edition each item you create carries the name you give it, then you make a reference to it on your SQL query, that item can be a combo box, a text field, etc any means for the user to enter data. that works fine.a reference as easy as this one: WHERE ( bookings.branchnumber = :PTEXT )
    Alvaro

  • Executing sql query in maviewer 10.1.3 javascript api

    Hi, i want to execute a sql query according to my applications requirement i.e. for retrieving some fields from the oracle database.How to do that? Please someone help me. Thanks.

    Im sorry..
    But how can I use JSP for querying non spatial data???
    Can you give me some example please..
    I've read about doQuery.. but I don't quite understand how to use it.. ^^

  • How to schedule a sql query on Windows

    Hi Experts;
    I got a sql query that I need to put on schedule, (on windows) in order it runs everyday at specific time.
    I got the query, but I want to know the next:
    How to invoke SQLPlus from this query? Explain how to include the user/password@SID
    Do I need to create this query in a .bat file?
    Also I want to know, how to send the results to an email?
    Thanks for your help.
    Regards
    Al

    I would suggest to put your sql query to a separate file and spool the result to a concrete file:
    query.sql:
    spool query.lst
    select * from emp;
    spool off;create a bat file query.bat:
    sqlplus <connection> @query.sql
    ...work with content of query.lst, send mail etcThen schedule your bat file with Windows scheduler
    The above could be simplified with JavaScript or VBScript
    Thanks.

  • Is there a simple way to refresh a SQL Query (Updatable report) region

    I have a page in APex 4.1 that has many regions. I would like to be able to refresh a single region.
    Currently, I have the following
    Region (sql query updateable report).
    STATIC ID = LANDINGS
    in the region footer, I have:
    <script type="text/javascript">
    $s('P110_LANDINGS_REGION_ID','#REGION_STATIC_ID#');
    </script>
    P110_LANDINGS_REGION_ID is a hidden field.
    I use javascript to refresh....but it does not seem to be working. Previously, we had hard-coded the region id ( $a_report('1363338167540162011','1','100','100');) ...but that ID was somehow corrupted, which has lead me to the 'OMG...there must be an easier way!' lament.
    the javascript is:
    $a_report('P110_LANDINGS_REGION_ID','1','100','100');
    thanks!
    Karen
    ps. could I just directly reference the static id in my javascript...
    $a_report('LANDINGS','1','100','100');

    Karen,
    First off: please post code in &#123;code&#125;...&#123;code&#125; tags!
    function AddFavoriteSpecies()
    get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=favorite_species_collection',0);
    gReturn = get.get();
    rowCount = rowCount + parseInt(gReturn);
    pHMS_add = '&G_HMS_FLAG.';
    $a_report('1363338167540162011','1','100','100');
    //$a_report($x('P110_LANDINGS_ID').value,'1','15','15');the statement:
    $a_report('1363338167540162011','1','100','100'); works, but the statement $a_report($x('P110_LANDINGS_ID').value,'1','15','15'); does not.
    Can anyone help.
    I am assigning the page field P110_LANDINGS_ID in the footer of a region with a static id = LANDINGS.
    <script type="text/javascript">
    $s('P110_LANDINGS_ID','#REGION_STATIC_ID#');
    </script>
    Well, let's start by dumping $a_report. This is undocumented code, and it has long been replaced by triggering a refresh.
    Next, don't use $x(pNode).value to retrieve a value. Rather use $v(pNode) to do this.
    function AddFavoriteSpecies()
       get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=favorite_species_collection',0);
       gReturn = get.get();
       rowCount = rowCount + parseInt(gReturn);
       pHMS_add = '&G_HMS_FLAG.';
       //get the region id from the item
       //use it in a jQuery selector to get the region
       //trigger the refresh event on this object
       $("#" + $v('P110_LANDINGS_ID')).trigger('apexrefresh');
    }Now if you want to make sure that P110_LANDINGS_ID contains a value, add an alert with its value before you use it.
    alert('P110_LANDINGS_ID value: '+$v('P110_LANDINGS_ID'))

  • SQL Query (report region) without full page reset

    Hello,
    I have a page with several items, some of them with default values, and a report region, performing SQL query based on one of the items – text field (always submits page when Enter pressed). When the page submits, the HTML DB engine performs and display the query, but at the same time, reset the other page items to their default values.
    Is it possible to run the query without the HTML DB reset the item values to their default state?
    Thanks,
    Arie.

    Hi Peter,
    Well, this is not exactly the case. I have an Item – File Browse – which defined as "Only when current value in session state is null", and a HTML text region, which contain Iframe, with default src tag (which I'm changing, using JavaScript, prior to the running of the SQL query). After running the query – in a report region – both the item and the Iframe reset to their original state.
    Any Ideas on how to prevent that?
    Thanks,
    Arie.

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • Update Field On Change For A SQL Query (updateable report)

    Hi,
    I'd like to request help from anyone with ideas on how to solve this.
    We are using APEX 4.2, 10GR2, RedHat5.
    I have a report that comes from SQL Query (updateable report).
    I'm using the apex_item.text and apex_item.hidden on fields.
    I'm using a button to submit and after submit process to add some logic that I need.
    There could be 1 - 10 records in the report.
    There is only 1 field that is needed to enter a value, but the value of this field determines the value of another field.
    I think that I can do this with a submit button and an after submit process where I loop through all the records. I think I have this handled.
    This is the question
    When the value of that field is changed then the value of another field in the same row changes immediately.
    Is this possible?
    All the examples I've seen so far are for a single record and that doesn't work for us.
    I guess this is a MRU process but I haven't seen an example where a dynamic action is possible on a Multi Row Update.
    Could anyone direct me to where I can see an example or help me get directions?
    I appreciate all your help an comments and I thank you in advance.

    Yes why not...what you looking for is a ajax call
    See {message:id=10390979}
    Please note:-you can also do this as a dynamic action as shown below
    Event: Change
    Selection type: jQuery Selector
    jQuery Selector: input[name="f01"]
    True action with Execute JavaScript Code and put all code inside the test funtion, you may need to amend the code to use this.triggeringElemnt in place of this

  • Default value of date picker not showing in sql query

    Hi,
    I have a tabular form page with a query similar to the following:
    select emp_name, salary from emp_table where trunc(hire_date)=trunc(to_date(:P42_START_DATE))
    where P42_START_DATE is the name of a date picker item.
    I set the source type of the date picker to be "Only when current value in session state is null" and the value to be "select trunc(next_day(sysdate,'MON')-7) from dual;" - basically the monday of the current week. I set the sequence of the date picker to be 5, and the sequence of the region to be 10. Now, when I open this page, no data gets pulled. I checked the page source, and the value of the date picker input is being set to "17-NOV-2008", but it somehow isn't reflected in the sql query.
    Data does get retrieved if I manually set the date in the date picker, but I'd like it to default to the monday of the current week. What am I doing wrong?
    Thanks

    nope, still same problem.
    I used javascript alerts to help debug, and here might be some useful information.
    The computation to set the value of :P42_START_DATE is set to run "before header", but when I put this following javascript in the header:
    <script language="javascript">
    var c = $v('P42_START_DATE');
    alert(c);
    </script>
    the alert box is blank (ie :P42_START_DATE is empty). Putting the same exact script in the footer gives 24-Nov-2008 in the alert box. Now, the SQL query is run sometime after the first alert and before the second alert, I believe. Why would the value of :P42_START_DATE not be getting set at the correct time?
    P42_START_DATE is a date picker item that belongs to the region SCHEDULE (which is where the sql query is). I set the sequence of the region to 10, and the sequence of the date picker and computation to be 5 and 6. Even so, does this mean that the sql query is executing before the call to the computation, because the region needs to be created before any items can be created that belong to the region?

  • Ajax Autocomplete Tabular does not work using apex_item.text in SQL Query.

    Hello,
    Is it possible to use the search function which is used in, Dennis Kubicek example, ENAME topic Ajax Autocomplete Tabular
    in a sql query using apex_items?
    Query line :
    , apex_item.text(17,xp.part_nr,null,null,'onfocus="f_register(this);" autocomplete="off"') PART
    At first I followed the example by adding 'onfocus="f_register(this);" autocomplete="off" in the element attributes in the report field.
    This didn't work... so tried to add the it in the attirbutes parameter of the apex_item.
    But this still doesn't work. No errors are given, it does not respond.
    Could somebody please help me?
    Thx!
    Astrid

    Well, I'm trying to take this one step further, but I seem to be having some difficulty.
    I'm trying to make a Filter screen to create a dynamic where clause filter screen.
    This is a page I made with Popup LOVS, just to show you my goal (now trying to use autofilters)
    http://apex.oracle.com/pls/otn/f?p=29989:5
    I have a table on my system that tells you where the field is, and I'm using that to get the table (didn't want to change the javascript, so I pass in a static value).
    This is the javascript code I used
    <pre>
    <script language="JavaScript" type="text/javascript">
    function f_register(p_this,p_name)
    var p_registered = $x('P5_ITEM_ID').value;
         var p_this_name = $x(p_this).id;
    //alert(p_this_name);
    if (p_registered != p_this_name)
    register(p_this_name, "COSTING_M", p_name, "blue", "red");
    $x('P5_ITEM_ID').value = p_this_name;
    </script>
    </pre>
    This is my query
    <pre>
    select column_name || apex_item.hidden(1,column_name) Col_name,
    apex_item.SELECT_LIST_FROM_lov(2,'=','OPERATOR') OPERATOR,
    apex_item.text (3,
    NULL,
    20,
    200,
    'onfocus="f_register(this,''' || column_name || ''');" autocomplete="off"',
    'f3_' || '#ROWNUM#',
    NULL
    ) value,column_id
    from user_tab_cols
    where table_name = 'COSTING_M'
    ORDER BY ROWNUM
    </pre>
    and here is my on-demand process
    <pre>
    declare
    TYPE CurTyp IS REF CURSOR;
    v_row varchar2(4000);
    rec CurTyp;
    V_TABLENAME NKW.UTFIELD_M.TABLE_NAME%TYPE;
    begin
    BEGIN
    SELECT TABLENAME INTO V_TABLENAME
    FROM NKW.UTFIELD_M
    WHERE FIELD_NAME = :TF_SL_COLUMN;
    EXCEPTION WHEN NO_DATA_FOUND THEN RETURN; END;
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&amp;','&');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&lt;','<');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&gt;','>');
    :TF_SL_SEARCH := replace(:TF_SL_SEARCH, '&quot;','"');
    owa_util.mime_header('text/xml', FALSE);
    htp.p('Cache-Control: no-cache');
    htp.p('Pragma: no-cache');
    owa_util.http_header_close;
    htp.prn('<rowset>');
    open rec for
    'select distinct ' || :TF_SL_COLUMN || ' ' ||
    'from NKW.' || V_TABLE_NAME || ' ' ||
    'where '||:TF_SL_COLUMN||' like :1||''%'' ' ||
    'and rownum < 100 ' ||
    'order by '||:TF_SL_COLUMN
    using :TF_SL_SEARCH;
    loop
    fetch rec into v_row;
    exit when rec%NOTFOUND;
    htp.prn('<row>' || htf.escape_sc(v_row) || '</row>');
    end loop;
    htp.prn('</rowset>');
    end;
    </PRE>
    I made some slight mods to make the table dynamic from my source table (this is to grab master files when they exist and not to when they don't).
    I get my select list, but it's blank on all fields, any suggestions?
    thanks,
    Scott

  • Dynamic Link in SQL Query Report

    Andy,
    I refromatted the message since it was all garbled, I didn't realize it came out like that the first time.
    1) I am not sure what you meant by the "#" in your message until I did the substitution of #'s for < > I didn't have that in my URL.
    2) Since the whole statement is enclosed in single quotes to be inside of a decode statement I think this is an issue with the javascript and it's double quotes or is it?
    3) I took care of the passing values for items, even if I can just get the link to work some what I would be happy I can worry abou those values later..
    Hello I have a a link that is generated in a report
    sql based on an SQL query and I would like to turn it
    into a popup instead of a direct link. But I seem to
    be having some problems going from a link to a popup
    link...
    <b> I replaced the brackets < > with "#" </b>
    This statement works;
    SELECT decode(create_date, NULL, NULL, '#a
    href="f?p=&APP_ID.:71:&SESSION.::NO:100:P71_EQUIPMENT_
    ID,P71_CONTAINER_TYPE_ID:' || equipment_id || ',' ||
    container_type_id || '"/#' || create_date ||'#/#>' )
    AS "HIST_NOTE",
    </br>
    </br>
    but I would like to turn make it a popup instead of a
    direct link, I think the problem has something to do
    with the parenthesis (double and single mixed) any
    ideas?
    </br>
    </br>
    I tried doubling them up (using three single ticks
    for double parens inside of single ticks and
    everything
    </br>
    </br>
    <b> I replaced the brackets < > with "#" </b>
    decode(create_date,
    NULL,
    NULL,
    '#a href="javascript:popupPage('f?p=&APP_ID.:71:&SESSION.::NO:100:P71_EQUIPMENT_ID,P71_CONTAINER_TYPE_ID:' || equipment_id || ',' || container_type_id || '"/#' || create_date ||'#/a#')" ' AS "HIST_NOTE",
    </br>
    </br>
    Any ideas?
    The error I usually get mostly complains about "ORA-00907: missing right parenthesis"....
    I put an example up on apex.oracle.com if you want to debug it there (it of course does not work right now)
    http://apex.oracle.com/pls/otn/f?p=18490:5
    guest/apex123
    Thanks
    Justin
    Message was edited by:
    Justin P

    Denes,
    I was able to get it working based on one of your examples, it gets ugly when you embed the popup javascript into the link as you know. You have some really great examples, I hadn't been to your page in awhile.
    Here is my end result (this is embedded in a decode statement so single ticks would go around the entire example below)
    &lt;a href="javascript:popUp2('''
    || 'f?p=&APP_ID.:71:&SESSION.::NO:100:'
    || 'P71_EQUIPMENT_ID,P71_CONTAINER_TYPE_ID:'
    || equipment_id || ',' || '&F110_CONTAINER_TYPE_IP.'
    || ''', 900, 600);">'
    || create_date
    || '&lt;/a>
    Thanks to all that helped me out here,
    Justin

  • Sql Query(Updateable Report) with pagination

    Hi,
    We're on APEX 3.2 I have a question on Sql Query(Updateable Report) and pagination. I have an updateable report which we have set to show 20 rows. When the userwhi has more than 20 rows enters the data and clicks next the data disappears. I have been reviewing other posts, but haven't come to a clear conclusion on how to prevent this from happening. I have been trying to use javascript to show a save popup when clicking 'Next' Any help is appreciated.
    Thanks,
    Joe

    any ideas?

  • APEX validations in updateable reports built on a PL/SQL query

    Sorry if the question is not clear (english is not my mother language) or if the answer already exists on the forum (I have not been able to find it).
    I build a report on a PL/SQL function query.
    In this PL/SQL query i use apex_item.checkboxes or texts to let the end user change/enter some new data.
    As i need to do some validations on the user entries, i have already used some events (e.g. onChange) that trigger
    simple javascript validations checking if data is numeric or length of data entered....
    But i would like to use also the standard validations of APEX to make some more complex validations (e.g. checking coherency) on
    many data entered by the end user.
    I am trying to build a PL/SQL to loop through the report lines through a checkbox item i have added
    but the process of debugging is awfull for me.
    - Is there a pointer to a code example of validations within a query report that would help me in achieving this validation
    - or could someone give me some clue on how to acess these report data in the interface.
    Thanks in advance,
    Daniel

    Daniel:
    You can check out Denes Kubicek's APEX demo site for ideas on how to create validations for a tabular form.
    http://htmldb.oracle.com/pls/otn/f?p=31517:41:3322496527336906:::RP,::
    Varad

  • Check dynamic SQL Query

    Hi,
    i often use the feature SQL Query (PL/SQL Function Returning SQL Query).
    Sometimes there is an error in the query and zero rows are returned. It would be nice to see which SQL-Statement was used.
    I tried to copy the sql statment to an item on the page, but that doesn´t work.
    Example:
    DECLARE
    s VARCHAR2(32000);
    BEGIN
    s:='select * from emp where 1=1 ';
    IF :P15_1 <>'%null%' THEN
    s:=s||q'( AND ...' )';
    END IF;
    IF :P15_2 IS NOT NULL THEN
    s:=s||q'( AND ...' )';
    END IF;
    insert into msta_log (datum,aktion) values (sysdate,s);
    commit; -- This worked
    :MY_DEBUG:=s; -- Error Item not Found in Application 4000
    RETURN s;
    END;
    Are there other tricks available?
    Thanks
    marco

    Yes yor are right. I deleted <> before '%null%' sorry
    the javascript example did not work. i had to change a litlle bit, but it was a good idea, thanks a lot
    This worked for me:
    htp.p('<script type=text/javascript>alert("'||replace(s,chr(10),'')||'");</script>');
    Thanks
    marco

Maybe you are looking for

  • Exception in the XML consuming from JMS Queue

    In the CEP application we have a business flow like we want to consume an xml message from the JMS queue. While CEP is consuming the message sometimes we are getting an exception. But this issue occurs rarely and we have no idea about the root cause.

  • Calendar task entries do not show carriage returns...

    Hi, maybe somebody in this forum can help me with a weird problem with my Nokia N9. Whenever I sync task entries of my calendar all carriage returns in the task notes are lost and if I change the entry on the Nokia N9 end also the carriage returns ar

  • Simple Doubt in BDC

    Hi friends,    I am new to BDC .I am just trying a simple code which is written already.    This is the simple code to fill the transaction VK13 first screen.   PERFORM bdc_dynpro      USING 'SAPMV13A' '0100'.   PERFORM bdc_field       USING 'BDC_CUR

  • Recycle

    When I was setting up and registering my new MacBook there was a label that could be used to send back an old computer to be recycled. Since I was not connected to a printer at the time I figured I would come back to that after I had finished transfe

  • Radeonhd and Audiohd on Solaris 10 (x86)

    This is getting rediculous. We have have several X86 boxes now, some almost 2 years old, that are not properly supported now by Solaris 10. What ever happened to the Sun concept of backporting important stuff from the next release to the current rele