Oracle SQL not working in Apex

I have been given the following SQL statement by a supposed SQL DBA
SELECT TOP 250 TRANS_CODE, TRANS_CASH_IN, Month([TRANS_DATE]) AS Transmonth, TRANS_COMMENT, TRANS_MACHINE_NO
FROM TRANSACT
WHERE (((Month([TRANS_DATE]))=Month(Now())) AND ((TRANS_COMMENT) Like "Dacom*") AND ((TRANS_MACHINE_NO)<>"7*"))
ORDER BY TRANS_CASH_IN DESC;
but when I try it in Apex I get
ORA-00923: FROM keyword not found where expected
Please tell me how I fix it.

Hi,
Dose the table[b] SGM_TRANSACT contains any value
as POK04 for the column TRANS_TABLE_NAME
. - Do reply
Post ur table structure.
Desc TRANS_TABLE_NAME;
                   Else try this
SELECT
     SGM_TRANSACT.TRANS_CODE,
     SGM_TRANSACT.TRANS_CASH_IN,
     TO_CHAR(TRANS_DATE,'Month') AS Transmonth,
     SGM_TRANSACT.TRANS_COMMENT,
     SGM_TRANSACT.TRANS_TABLE_NAME
FROM    SGM_TRANSACT
WHERE  
        TO_CHAR(TRANS_DATE,'MM') = to_char(sysdate,'MM')
     AND SGM_TRANSACT.TRANS_COMMENT Like 'SGM%'
     AND  SGM_TRANSACT.TRANS_TABLE_NAME Not BETWEEN "AR15" And "AR20"
     And  SGM_TRANSACT.TRANS_TABLE_NAME Not BETWEEN "BJ17" And "BJ22"
     And  SGM_TRANSACT.TRANS_TABLE_NAME <>"BJ25"
     And  SGM_TRANSACT.TRANS_TABLE_NAME <>"BJ31"
     And  SGM_TRANSACT.TRANS_TABLE_NAME Not BETWEEN "PB02" And "PB05"
     And  SGM_TRANSACT.TRANS_TABLE_NAME <>"PB07"
--     And  SGM_TRANSACT.TRANS_TABLE_NAME <>"POK04"   -- OR TRY THIS
ORDER BY SGM_TRANSACT.TRANS_CASH_IN DESC;
[/pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Authentication function not working in APEX but works in pl/sql

    Greetings, Jim here.
    I have written a very simple authentication funtion which uses the dbms_ldap package to authenticate using the userid and password from the login page.
    I've tested this function thru pl/sql and it returns true and false accordingly.
    I've created a custom authentication schema and in the authentication function I have return myfunction;
    The problem is, when called thru APEX, it appears to always return true and lets the login proceed, even if the password is correct. I know its using the function due to the fact that if I enter a bogus function as the authentication function, APEX spits up a message saying so.
    So, I know the function works, but I don't know why it does not work with APEX. Posting function below.
    CREATE OR REPLACE FUNCTION ODBS.CUSTAPEXLOGIN (p_username IN VARCHAR2,p_password IN VARCHAR2)
    RETURN BOOLEAN AS
    retval PLS_INTEGER;
    emp_session DBMS_LDAP.session;
    ldap_host VARCHAR2(256);
    ldap_port VARCHAR2(256);
    ldap_user VARCHAR2(256);
    ldap_passwd VARCHAR2(256);
    ldap_base VARCHAR2(256);
    BEGIN
    ldap_host := 'oraldap';
    ldap_port := '389';
    ldap_user := p_username;
    ldap_passwd := p_password;
    ldap_base := 'cn=users,dc=company,dc=com';
    emp_session := DBMS_LDAP.init(ldap_host,ldap_port);
    retval := DBMS_LDAP.simple_bind_s(emp_session,('cn=' || ldap_user || ',' || ldap_base),ldap_passwd);
    if retval = 0 then
    return true;
    else
    return false;
    end if;
    EXCEPTION
    WHEN OTHERS THEN
    begin
    if sqlcode = -31202 then
    return false;
    end if;
    end;
    END;
    /

    Hi Jim,
    Can you clarify this -
    The problem is, when called thru APEX, it appears to always return true and lets the login >proceed, even if the password is correctThat implies you're saying your authentication function ALWAYS returns true? Is that correct? Also 'even if the password is correct' doesn't read correctly to me, did you mean 'even if the password is incorrect'?
    You then say -
    now the function works, but I don't know why it does not work with APEX.So by 'does not work' you mean in APEX it is always returning true therefore allowing you to login regardless of the username/password you use? Is that correct?

  • Oracle dbms.set_role does not work in APEX application

    Hi, in our j2ee applications, we use secure application role. Basically, the data source use the app user schema to connect to the database. the app user only has create session privileges. the database logon trigger will copy a set of attribute to the local secure context. (ip address, session user, client id, application name). The applications explicitly invoke the stored procedure sec_mgr.set_role before any DMLs are executed.
    the sec_mgr.set_role will check the local context attribute , authorize the ip, application name, and set an appreciated role to this session based on session user.
    we want to apply the same framework to the APEX application. First, we change the paring schema to the app schema which only has create session privilege. then we put the plsql code in which sec_mgr.set_role is called in the application builder --> shared components ---> edit security attribute ---> Virtual Private Database (VPD).
    however, we got the error ORA-06565: cannot execute SET ROLE from within stored procedure
    the sec_mgr.set_role is defined as invoker's right(AUTHID CURRENT_USER)
    do i missing something in APEX to get it work?
    Thanks

    Please explain it does not work in APEX? Is the application updating tables that have a trigger? APEX does NOT override trigger actions. Is it possible the values your trigger is looking for are NOT available in your APEX application? Can you post the trigger code here for review?
    Thank you,
    Tony Miller
    Webster, TX
    What if you really were stalking a paranoid schizophrenic... Would they know?
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Select count(*) not working in Apex

    Hello,
    The following sql works in both SQL*Plus and Toad but not in apex.  The variable seems always to be 0 no matter what data I have on the table.
    Basically I try to flip the status from "Inactive" to "Active" only when there is no "Inactive" status left on the table.  Say there are 2 inactive statuses.
    If I delete one inactive status, the overall status should still be "Inactive".  However, with this code, it flips to "Active" status regardless. 
    I tried manually assign the variable to 1 and the status was not flipped.  Therefore, it sounds to me that the count(*) is not working in APEX.
    Does anyone experience this before? 
    Thanks in advance,
    Ning
    ===================================
    DECLARE
    v_status_count NUMBER;
    BEGIN
    UPDATE LGR_APP_STATUSES
    SET DELETED = 'Y'
    WHERE LGR_APP_STATUS_ID = :P42_LGR_APP_STATUS_ID;
    commit;
    select count(LGR_STATUS_ID) into v_status_count from LGR_APP_STATUSES
    where DELETED = 'N'
    and LGR_APPLICATION_ID = :p42_application_id
    and LGR_STATUS_ID in (3,8);
    IF (v_status_count = 0) THEN
    update lgr_applications
      set lgr_application_status = 'ACTIVE'
      where LGR_APPLICATION_ID = :P42_LGR_APPLICATION_ID;
    commit;
    END IF;
    END;

    Hi,
    In query you have used p42_application_id.
    Other statements use P42_LGR_APP_STATUS_ID
    Do you have that item? What is session state for that?
    Regards,
    Jari

  • Switch Theme is not working in apex 4.2.Plz  help me out.........

    Hi.......
    Switching from one theme to another theme is not working in apex 4.2..............
    Thanx in advance

    Hi!
    Same problem.
    Upgraded from 4.1 -> 4.2.
    Change theme from slightly modified Green theme (in mine case 101 is number and original was 11, One level Tabs) to Theme 25 Blue Responsive.
    Login page for instance doesn have "Login Region" for instance (not in LOV). And all pages are softly said strange.
    All have DISPLAY problem described on "http://1.bp.blogspot.com/-GzseTk6Lpes/UHvJkg9GulI/AAAAAAAAHRQ/Wt406GGZADQ/s640/Screen+Shot+2012-10-15+at+10.25.29.png", but without many parts that Dmitri describe.
    Rg
    Damir

  • Interactive Reports not working with APEX listener

    Hi,
    I have posted this question APEX listener forum couple of weeks ago but very few responses.
    If any one from here can help then it would be great.
    Interactive Reports not working with APEX listener
    Best Regards,
    Baig

    Sorry for late response.
    It was a firewall issue

  • Bind Variable NOT working in APEX 4.0 within charts SQL

    All,
    I had a chart working fine in 3.2 which had a bind variable like :P11_EMP_NAME, when I created the same chart in 4.0 using the same query it did not work, until I changed the variable to v('P11_EMP_NAME'). Does anyone have experienced the same behaviour?
    Thanks
    Venkat

    Hi Deb,
    Both of your queries are using multi-series syntax i.e. returning more than one series of data, therefore your generated chart is actually generating 6 series rather than just the two that you're aiming for. You could try changing your queries to ensure they each generate a single series of information, which would then result in the extra Y-axis being applied to your "Series 2". Here's an example of what I mean:
    Series 1:
    select null link, label, value from (
    select 'test' label, 1 value from dual
    union all
    select 'test2' label, 2 value from dual
    union all
    select 'test3' label, 3 value from dual
    )Series 2:
    select null link, label, value from (
    select 'test' label, 100 value from dual
    union all
    select 'test2' label, 200 value from dual
    union all
    select 'test3' label, 300 value from dual
    )I hope this helps.
    Regards,
    Hilary

  • Apex_util.get_print_Document not working outside apex environment

    I am working on one of the assignment in Apex 4.0.2 .
    The requirement is to dynamically generate reports and mail to User using the Scheduler program(Pl/sql) -> dbms_scheduler.
    I have used BI publisher to create the template and xml data for the report(Excel) and used Apex_util.get_print_Document
    in the scheduler program (which is written outside Apex), but this is not working properly,sends blank report to email.
    Please suggest how to set the apex session and use Apex_util.get_print_Document to work properly outside apex env.

    Apex (PL/SQL web-enabled) code needs to execute inside an Oracle server session that has been properly and correctly initialised for executing web enabled PL/SQL code.
    An example of how to execute such PL/SQL by intialising a proper environment, is shown in {message:id=2251131}.
    Note that this will not be able to execute Apex pages (via the flow engine) that are not public - that needs a proper authenticated Apex web session. Which could be a tad complex to emulate in this fashion.

  • SkillBuilders Modal Page is not working in Apex 4.2

    Hi All,
    I am trying to set up an example in apex.oracle.com of an application developed in Apex 4.1 and the SkillBuilders Modal Page plug-in is not working.
    To show this situation, I created a simplified version of the application, with only two pages, in apex.oracle.com.
    Workspace: EDIAZJORGE
    Username: TEST
    Password: test123
    Application: 66464 - Modal Page Sample
    When Page 3 loads, a Dynamic Action is executed to open Page 2 (Interactive Report) as a modal page, but it is not working (the modal page does not open).
    Please notice that this is working in Apex 4.1, and the Embed in Frames property in my application is set to Allow.
    I appreciate any help.
    Thanks,
    Erick
    Edited by: ediazjorge on Jan 30, 2013 3:20 PM
    Bump!

    Erick,
    This is due to a change that was made to the Dynamic Actions framework in 4.2. The workaround for now is to change your event to resource load on the DOM window object.
    It's working now. In the next release of the plug-in you'll be able to go back to the Page Load (ready) event.
    Regards,
    Dan
    blog: http://DanielMcghan.us/
    work: http://SkillBuilders.com/APEX/

  • Working in Sql, not working in Stored procedure

    Dear friends,
    I am puzzled about this strange working of Oracle , although I know that there is some problem with my code. I paste my code here. The delete statement is working properly in SQL Plus 8.0, but it is not working when I call this stored procedure from the Form.
    FUNCTION delete_record_treaty (
    p_treaty_id T_RIN_TREATY_MST.TRTY_ID_GV%TYPE, p_value VARCHAR2,p_block VARCHAR2 )
    RETURN BOOLEAN IS
    v_treaty_type varchar2(5);
    BEGIN
    v_treaty_type := substr(p_treaty_id,1,3);
    if p_block !='T_RIN_GRP_DTL' and p_block != 'T_RIN_XOLSLAB_DTL' and p_block!='T_RIN_PMTSCHD_DTL' then
    delete from T_RIN_TREATY_MST where TRTY_ID_GV=p_treaty_id ;
    commit;
    end if;
    if v_treaty_type = 'QTA' then
    delete from T_RIN_GRP_DTL where TRTY_ID_MV=p_treaty_id and T_RIN_GRP_DTL.ROWID = p_value;
    commit;
    elsif v_treaty_type = 'XOL' then
    delete from T_RIN_XOLSLAB_DTL where TRTY_ID_MV=p_treaty_id ;
    delete from T_RIN_PMTSCHD_DTL where TRTY_ID_MV=p_treaty_id ;
    elsif v_treaty_type = 'FAC' then
    delete from T_RIN_PMTSCHD_DTL where TRTY_ID_MV=p_treaty_id ;
    end if;
    RETURN(TRUE);
    END delete_record_treaty;
    Thanks in advance.
    All the paramaters that I pass, are correctly being passed to this stored procedure.
    null

    I solved it.One parameter I was passing it wrongly.
    Gee :D
    Subramanian V.

  • ORACLE tags not working after 1.5.1 patch

    I have some logic in my template the looks up information from some Oracle tables. This logic worked fine in 1.5.0, however, after applying the 1.5.1 patch it does not perform the Oracle logic, but shows the Oracle code as HTML on the page. Here is the code in question: (This is not the entire code, but one HTML TD that comes before the Oracle code, and one HTML TD that comes after it)
    <TD align="center" valign="top"><A
    href="/pls/portal/PORTAL.home"><IMG src="#WORKSPACE_IMAGES#ihome.gif" alt="Home" border="0"></A></TD>
    <ORACLE>
    BEGIN htp.tableData(htf.anchor2('javascript:help_openTopic(''/insitehelp/Insite_Help.htm'', ''' || pkg_insite_general.help_link(v('APP_ID'), v('APP_PAGE_ID')) || ''')', '', '', '', '><IMG src="#WORKSPACE_IMAGES#ihelpl.gif" alt="Help" border=0'), 'center');
    END;
    </ORACLE>
    <TD align="center" valign="top"><IMG src="#WORKSPACE_IMAGES#ilogout.gif" alt="Logout" border="0"></TD>
    This is what displays on the web page:
    BEGIN htp.tableData(htf.anchor2('javascript:help_openTopic(''/insitehelp/Insite_Help.htm'', ''' || pkg_insite_general.help_link(v('APP_ID'), v('APP_PAGE_ID')) || ''')', '', '', '', '>

    Your removal of functionality in a bug fix has broken a production application for us. This does not seem like something that should have been done with a "patch"
    I have just read all that I can find on "shortcuts" and am not finding what I need.
    Here is what we are doing:
    We are using RoboHelp for our help content. We have a help icon and a help link on the header of the page. This is defined in our template. We have to have the name of the module (Page Alias) to link the page being run to the help content for that page. Since you do not have a system variable for page name or page alias, I have had to put this information into an Oracle table. I was looking that up with a function within the Oracle Tags.
    Can I create a shortcut that would create the following code pl/sql code into a PL/SQL function body:
    BEGIN
    htp.tableData(htf.anchor2('javascript:help_openTopic(''/insitehelp/Insite_Help.htm'', ''' || pkg_insite_general.help_link(v('APP_ID'), v('APP_PAGE_ID')) || ''')', '', '', '', '><IMG src="#WORKSPACE_IMAGES#ihelpl.gif" alt="Help" border=0'), 'center');
    END;
    and call this shortcut where this help icon needs to appear like:
    <TD align="center" valign="top">
    "CALLHELPWITHICON"
    </TD>
    I have done the above, but it does not work. What am I doing wrong, how can I get this to work? We have had to remove our help icons because of this patch.
    I thank you so for your research on this.

  • JDBC (SQL) not working in thread

    I was surprised by a strange (bug?)
    I had two programs that were implementing the Java Serial Port API, each interfaced to a specific instrument. I was asked to combine the two programs into one, run it on one workstation, and run it as a service. This is on an W2K machine and they want it to work even if no one is logged in.
    Well, I started each class as a serial port listener and a runnable, thinking it might be best for each listener to have its own thread. That runs just fine. But, one of the instruments sends a lot of data, so once I had a buffer full of stuff to parse and upload (to Oracle), is started another processing thread to handle the data, and let the parent thread get back to listening to the serial port.
    Well, I parsed the data just fine, but after I created the connection, created a statement, and then tried to execute a line of SQL, it just stopped, no exceptions, but no results. I keep a log of what is going on, and it looks like the thread just dies.
    So, for experimenation, I changed the parent threads back to plain classes and created the instances of them, still leaving the processing piece as a thread. (The only draw back to this is that I cannot transmit from both instruments at the same time.) Well, the SQL worked fine, so I am wondering if there is a problem with the JDBC and threads, or inner threads?
    Anyone have any suggestions?
    Thanks,

    As I understand it, your code does not work only when you run it as a service. Although I may well not understand it (for example I don't know what you think an "inner" thread is, and I don't understand your distinction between "class" and "thread", since everything runs in some thread or other in Java).
    Is this correct? Have you managed to get the original (single instrument) code running as a service? My guess is that there's nothing wrong with Java, but there is some issue with running it as a service.

  • Sys_context not working from APEX application / environment

    I am struggling to retrieve a user-defined context value using sys_context(...) from APEX application / environment
    I have created a global context to be used as a storage mechanism for log severity to be recorded.
    CREATE OR REPLACE CONTEXT PA_LOGGER_CTX USING PA_LOGGER ACCESSED GLOBALLY;It is seeded through a function pa_logger.set_severity(1) within the package pa_logger through (excerpt):
      dbms_session.set_context(c_ctx_context_label, c_ctx_severity_label, TO_CHAR(p_severity_in));
      with:
      c_ctx_context_label     CONSTANT NVARCHAR2(16) := 'PA_LOGGER_CTX';
      c_ctx_severity_label    CONSTANT NVARCHAR2(8) := 'SEVERITY';
      p_severity_in   IN  PLS_INTEGERusing the following from sqlplus, other DB-tools, works as expected:
    -- setting it
    BEGIN
      pa_logger.set_severity(2);
    END;
    -- displaying it
    SELECT sys_context('PA_LOGGER_CTX', 'SEVERITY') FROM DUAL;returns 2
    This works from different sessions, different users ... no problem.
    Using it from within an APEX (accessed via embedded gateway/XE11.2 or OHS/11.2.0.2.0 ) application or even from the "SQL Commands" from the APEX Workspace returns a NULL value for :
    SELECT sys_context('PA_LOGGER_CTX', 'SEVERITY') FROM DUAL;And
       SELECT value  FROM GLOBAL_CONTEXT WHERE NAMESPACE='PA_LOGGER_CTX' and ATTRIBUTE = 'SEVERITY';returns the right value, which obviously defies the purpose of using the CONTEXT.
    It is as well possible to set the CONTEXT to a different value, which is picked up outside APEX, but even so using sys_context does not work, always returning NULL
    As a note aside: using sys_context with a standard CONTEXT, e.g. SELECT sys_context('USERENV', 'NLS_DATE_FORMAT') from DUAL works without any problems.
    I guess I have a conceptual break somewhere. Does this have to do with the APEX user used, wrapping within the APEX environment, the way the context is defined ....
    Any help is appreciated.
    Many thanks,
    - Thomas

    Hi Rod,
    Thanks for the time to answer. Meanwhile I found some more hints on the subject (Retrieve values from my own global context in Apex and I do now understand the concept.
    I understand that I can even clear the specific CLIENT_IDENTIFIER by issuing a "dbms_session.clear_identifier()", which then subsequently works
    Looking at the CLIENT_IDENTIFIER as set by APEX it is "<apex_login_user><apex_session>";
    I understand it is set for every DISPLAY-SUBMIT it is reset by the APEX framework.
    Hence it is not sufficient to set it for a user session; it needs to be changed for every display-submit. I can achieve this through application processes, but I am really reluctant to do so, because I do not know, if APEX relies on the CLIENT_IDENTIFIER to be set the way it is done. I suspect a purpose behind this, causing me problems elsewhere. I post this as a seprate question as this question has been answered.
    On to your point about: Using a table variable. This is the way it works currently, but allegedly using the CONTEXT would give us for the logging configuration a performance gain of about 1 dimension..... but unfortunately other problems..
    Thanks!
    - Thomas

  • Oracle reports not working

    my oracle reports are not working.
    all the inforation is being sent to the rwservlet but the report just consists of the Heading of the report and not the data.
    i have checked the queries in the respective .xml files and run those queries in sql. they are working pretty fine and returning the desired result. if i am trying to generate the reports in excel format, they are getting generated with all data.
    please help me out.

    Is this a problem with one type of report? Does a simple test report created in the builder work ok?
    How are you running the report? From a URL or from Forms?
    Is there any error showing in the ?/reports/logs or in the ?/opmn/logs (either in the report server log or in the OC4J)?
    Can you run the report using rwrun?

  • Apex Essential application is not working in Apex 4.0

    Hi,
    We recently upgrated from apex 3.2 to apex 4.0. After the upgrade the apex essentials (developed by Patrick Wolf and team) is not working.
    The application can be opened, but the pages look very odd as the icons are not displayed properly. The advisor and power search options can be run, however get the following error.
    " ORA-20555: Unknown dictionary view APEX_APPLICATION_PAGE_DA
    Return to application."
    Can it be only used in 3.x?. In order to run apex 4.0 what we need to do? We already deinstalled and reinstalled the application, but got the same error.
    Advance Thanks,
    Natarajan

    I haven't used 4.0 extensively, but get the impression that all that functionality is now built into 4.0, thus not requiring an external application any longer.

Maybe you are looking for