Dynamic execution

Hi all this is Subhanu,
   i have a question please give me code with an example
how to display all the records in a table ,i am passing the table name as in param to the procedure/function
suppose if i pass emp table name it will display 14 rec, if i pass dept it will display 4 records.

You can use a refcursor to do that. But the issue would be for the client in handling the refcursor. Think about it how will it process it if it does not know the exact projection of the returned cursor. You need to come up with a solution like that of the PRINT command in SQL Plus.
Here is a example
You can simply have a Procedure that will return a  refcursor in a output variable like this.
SQL> create or replace procedure print_table
  2  (
  3    p_table_name in varchar2,
  4    p_output    out sys_refcursor
  5  )
  6  as
  7  begin
  8    open p_output for 'select * from ' || p_table_name;
  9  end;
10  /
Procedure created.
Now this is the tricky part. In SQL Plus it looks very easy with the PRINT command. In SQL Plus you just create a variable of type REFCURSOR and pass it to the procedure. Then use the PRINT command to print it.
SQL> var rc_output refcursor
SQL> exec print_table('EMP', :rc_output)
PL/SQL procedure successfully completed.
SQL> print rc_output
     EMPNO ENAME  JOB              MGR HIREDATE         SAL        COM     DEPTNO         ID
      7369 SMITH  CLERK           7902 02-APR-13      12975          0         20
      7499 ALLEN  SALESMAN        7698 20-FEB-13      11600        300         30
      7521 WARD   SALESMAN        7698 22-FEB-13      11250        500         30
      7566 JONES  MANAGER         7839 02-APR-13      12975          0         20
      7654 MARTIN SALESMAN        7698 28-SEP-13      11250       1400         30
      7698 BLAKE  MANAGER         7839 01-MAY-13      12850          0         30
      7782 CLARK  MANAGER         7839 09-JUN-13      12450          0         10
      7788 SCOTT  ANALYST         7566 19-APR-87      13000          0         20
      7839 KING   PRESIDENT            17-NOV-13       5000          0         10
      7844 TURNER SALESMAN        7698 08-SEP-13      11500          0         30
      7876 ADAMS  CLERK           7788 23-MAY-87      11101          0         20
11 rows selected.
SQL> exec print_table('DEPT', :rc_output)
PL/SQL procedure successfully completed.
SQL> print rc_output
    DEPTNO DNAME      LOC
        10 ACCOUNTING NEW YORK
        20 RESEARCH   DALLAS
        30 SALES      CHICAGO
        40 OPERATIONS BOSTON
If you can give more detail on your actual need to do such a thing we could help you better.

Similar Messages

  • Dynamic execution of boolean expression

    Hi folks,
    I want to execute a boolean expression dynamically, can you pls help me how to do it.
    For example,
    String str = " ( X & ( Y | Z ) ) " ;
    They value of X , Y or Z will be either true or false.
    After replacing their value, I will get string as follow
    String result = "( true & (false | true ) ".
    Now I want to execute the String as boolean expression in order to get
    a result as a true or false.
    So, i need a solution to implement this. The expression may be simple or compound . It is so urgent waiting for your reply.
    Appreciated if you provide sample code.
    Thx !
    With regards,
    Rahul

    Java is a compiled language (well, strictly, a semi-compiled language.) This means that stuff like parsing expressions only happens at compile time. Variable names don't exist at run time, neither does the code which analyses expressions.
    If you really need to do this kind of thing, therefore, all the code for parsing these expressions has to be a part of your program, and stuff like values for variable names will have to be set explicitly by your program, not in regular variables but in variable list for the "scripting engine" you invoke.
    You can either write your own expression analyser (not a trivial task if you haven't done it before) or you can search arround the web for one someone else has written and find out if it covers your requirements. BeenShell has been suggested. Find it on the web and study it's documentation.
    Incidentally when the new release of Java comes out it will include serveral such "Scripting engines" for languages like JavaScript or Jython, and such things will be less hastle.

  • Dynamic execution of sequenc

    Hi,
    I have the below function which takes the sequence name as variable and
    returns me the next val.
    Function fngetnextseq(object_id varchar2) return number IS
    l_next_no number(38);
    l_sql varchar2(100);
    BEGIN
         l_sql := 'select '||object_id ||'.nextval into l_next_no from dual';
          execute immediate l_sql;
          return l_next_no;  
    END;END TEST;
    But while executing its throws an error.
    Any idea how this can be solved so that i can take sequence name dynamically at runtime and then execute it.
    Thanks

    execute_immediate_statement ::=
    EXECUTE_IMMEDIATE dynamic_string
        INTO { define_variable [, define_variable ...] | record_name }
      | BULK COLLECT INTO { collection_name [, collection_name ...] | :host_array_name }
       [ USING [ IN | OUT | IN OUT ] bind_argument
       [, [ IN | OUT | IN OUT ] bind_argument] ... ] [ returning_clause ] ;Try like this:
    Function fngetnextseq(object_id varchar2) return number IS
    l_next_no number(38);
    l_sql varchar2(100);
    BEGIN
         l_sql := 'select '||object_id ||'.nextval from dual';
          execute immediate l_sql into l_next_no;
          return l_next_no;  
    END;

  • Dynamic Execution of Stored Procedure

    Hi Everybody!
    I have two questions for you. All my questions are pertaining PL/SQL programming with Oracle 8i. But before that, I would like to introduce a bit about the background.
    We have .NET based application, which calls some 80 odd Oracle stored procedures one after one. The input parameters for all these stored procedure are same i.e. two IN parameters of Integer type and a OUT parameter of cursor type. The name of these stored procedures are listed in table (let say tblSPTable). We use to get the list of stored procedures from this table and execute them one after one.
    Sooner or later we realized that, this way of calling the stored procedures is causing a performance issue. So, we thought of moving the call to all these stored procedures to a new stored procedure. We thought of giving a call to this new stored procedure, which will in turn execute all these stored procedures one after one (by using the tblSPTable), and return us the all the cursors at one shot. But here is where we got stuck:
    How can I declare a OUT parameter for a list of cursors? Because I need to store the output of all the 80 odd calls in different cursors and have to get it back. I have tried to declare VARRAY of cursors or TABLE of cursors but it is not supported. One way of doing this is to declare all the 80 cursors as OUT parameters in the new stored procedure, but that is absolutely a bad programming practice. Apart from that, in future if we want to modify the order of the stored procedure, OR if we want to add or remove few stored procedures listed in tblSPTable, we have to modify this new procedure every time. My question is how can I declare or use a variable which can hold the list of cursors, which I can use from a .NET base application.
    Secondly, I will get the name of all the stored procedure by querying the tblSPTable, and will execute them dynamically. I have tried out something like this but not succeeded
    declare
    cur_result some_package.some_cursor;
    var_spname varchar;
    begin
    var_spname:=’pr_some_procedure’;
    execute immediate 'begin ‘ || var_spname || ‘(:2); end;' using out cur_result;
    end;
    Bur, I am getting an error saying “Error while trying to retrieve text for error ORA-03113”. I have scanned through few docs available over net, but none of them are really helpful. My question is how can I dynamically execute a stored procedure which has a cursor as a OUT parameter.
    Please help me out if you people have any idea regarding this. Please let me know whether my approach is correct or not. I am waiting for your valuable suggestions.
    Thanking you
    Ayan Mitra
    Message was edited by:
    user588628

    your solution will work out only in case all the functions returning you a cursor which holds same number of columnNot so. It is unfortunate that my example does not make that clear.
    The UNION ALL is of a single column which is of type weak refcursor.
    By way of example the below changes the p_dept procedure so it returns two columns rather than three.
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> CRE ATE OR REPLACE PROCEDURE p_dept (
      2     p_deptno IN dept.deptno%type,
      3     p_resultset OUT SYS_REFCURSOR)
      4  IS
      5  BEGIN
      6     OPEN p_resultset FOR
      7        SELECT d.deptno, d.dname
      8        FROM   dept d
      9        WHERE  d.deptno = p_deptno;
    10  END p_dept;
    11  /
    Procedure created.
    SQL> VARIABLE p_resultset REFCURSOR;
    SQL> BEGIN
      2     :p_resultset := f_all (
      3        p_deptno => 30,
      4        p_functions => varchar2_table ('F_DEPT', 'F_EMP'));
      5  END;
      6  /
    PL/SQL procedure successfully completed.
    SQL> PRINT p_resultset;
            RN FN     RS
             1 F_DEPT CURSOR STATEMENT : 3
    CURSOR STATEMENT : 3
        DEPTNO DNAME
            30 SALES
             2 F_EMP  CURSOR STATEMENT : 3
    CURSOR STATEMENT : 3
         EMPNO ENAME      JOB
          7499 ALLEN      SALESMAN
          7521 WARD       SALESMAN
          7654 MARTIN     SALESMAN
          7698 BLAKE      MANAGER
          7844 TURNER     SALESMAN
          7900 JAMES      CLERK
    6 rows selected.
    SQL>[pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • TestStand - dynamic execution flow with symbolic stepnames?

    I want to jump to different parts of a sequence, depending on the user privileges as have been read out of a mySQL database. What I would like to do is to use a post-expression statement to set Runstate.NextStepIndex (as described when searching for "Next STep to Execute").
    This is quite easy when using direct numbers, but what if I have to add other steps inbetween, so changing these numbers? So I'd prefer to use the step's names instead. How can this be done?
    I have found out by myself that conditionals can be nested so that I can adress more than two target steps.
    Any hint is apreciated!

    Carlos Leon answered this Q on Info-TestStand as follows:
    > These are 2 approaches you can take:
    > 1) Using a single Goto step configured to go to multiple locations depending on a condition. When you edit the destination of the "Goto" step, instead of selecting a particular step name, you can type in an
    expression looks like the following:
    > Locals.MyValue == 1?"Action"Locals.MyValue == 2?"Pass/Fail Test":"Numeric Limit Test")
    > Meaning: If Locals.MyValue == 1, it will jump to the step named "Action". Otherwise, if Locals.MyValue == 2, it jumps to the step named "Pass/Fail Test", and so on.
    > 2) Using the PostActions of a step (instead of the PostExpressions). To accomplish the same thing as before, you can set the following "Custom Condition" i
    n a step's post actions: Locals.MyValue == 1 Then, "On condition True", select the name of the step to jump. E.g. "Action. "On condition False", type in an expression like the following:
    > Locals.MyValue == 1?"Pass/Fail Test":"Numeric Limit Test"
    > The second approach would be easier to implement than using "Post Expressions" if you want to specify a destination by step name rather than by step index. If you still want to use a Post Expression to specify a
    step name, it is still possible but the expression would be rather difficult to read.
    Unfortunately the PostAction Aproach did not work. A simple Target like OnFail goto might work, but a conditional like above was ignored. I could, however,
    achieve my aproach be inserting a "Goto" step with that kind of conditional target. Even the very same expression operates in the "Goto" and is ignored as a PostAction in a message popup step.
    Anyway, Problem solved! Thanx to all who helped!
    Greetings from Germany!
    Uwe F
    renz

  • Dynamic where clause based on Page Items

    I need an example of how to build a where clause with values from page items.
    I want to do something like the following but do not know the syntax:
    sql_string := ' where lab.ceventno is not null and lab.cts_no_show is null ';
    if :P1_RECID is not null then
    sql_string := sql_string || ' and lab.recid = ' || :P1_RECID;
    end if;
    if :P1_CAS_NO is not null then
    if :P1_CAS_TYPE = 1 then
    sql_string := ' and upper(lab.cas_no) = ' || :P1_CAS_NO;
    elsif :P1_CAS_TYPE = 2 then
    sql_string := ' and lab.ceventno in (Select ceventno from msds_ing where cas_no = ' || :P1_CAS_NO;
    end if;
    end if;
    :P2_WHERE := sql_string;
    I put this in a process that I want to pass to Page 2 when search button is pushed. I'm not sure what I'm doing wrong, but this doesn't seem to work.
    When I print out :P2_WHERE, I only get the first line
    'where lab.ceventno is not null and lab.cts_no_show is null '
    Any help would be much appreciaed
    Thanks
    Pam

    Pam - We need more details about exactly what you are doing, e.g., how are you going to dynamically execute that SQL, what items are on page 1 that will be submitted (all search criteria), what happens on page 2, etc.
    But here are a few points:
    1. when building a query for dynamic execution, put the bind variables like ":P1_RECID" into the generated SQL, e.g., do this:
      sql_string := 'select ename from emp where empno = :P1_EMPNO';
    not
       sql_string:= 'select ename from emp where empno ='||:P1_EMPNO;They may appear to give you the same results but the first introduces non-reusable SQL into the shared pool (this is bad).
    2. When code runs that references user-entered item values on the current page, like "if :P1_CAS_NO is not null", you have to make sure those items have been submitted (as with a page-submitting button) before you reference them. So if the user enters search criteria into form fields, then submits the page, then you reference those items in the SQL-building process, you'll be okay.
    3. Watch for errors like your line: "sql_string := ' and upper(lab.cas_no) = ' || :P1_CAS_NO;" which you may have intended to be "sql_string := sql_string||' and upper(lab.cas_no) = ' || :P1_CAS_NO;".
    Scott

  • How to give dynamically mapping in interface

    Hi all,
    I have requirement for this requirement i am thinking various scenarios,
    could please tell me is there any way to we can give source,target data stores and mapping dynamically(execution time) to the interfaces ? if it is possible then i can re use job again and again ?
    please give your solutions for this post
    Thanks,
    Surya.

    Please let me know if I miss the mark here.
    If you are trying to build the 150 interfaces without spending the time to do so manually, use the ODI SDK. Check out David Allan's blog post for examples here https://blogs.oracle.com/warehousebuilder/entry/odi_11g_interface_builder. You can build your interfaces once - without need for dynamic mapping at execution time.
    I'm pretty sure there is no good way in ODI "out of the box" to dynamically map columns at execution time, but I imagine you could use the ODI SDK to write a Java program that does so. Then, use the Open Tools feature in ODI to run the Java program within your ODI processes. I'm not sure the value of this, but I do not have a full understanding of your requirement.
    I hope this helps. Enjoy!
    Michael R.

  • Dynamically start class member vi (non blocking)

    Hi folks,
    I've got a problem.
    I thought about building a framework, where i can dynamically start modules based on one class.
    The inherited classes representing the modules shold have a class member vi, that (containing a while loop) can be started dynamically.
    All selectes modules should be started from a loop starting one module after the other. Thus the dynamically start needs to be non blocking.
    I tried several ways, but allways reached the point, where the OOP approach limits the dynamically execution.
    Has anyone done something similar and can tell me how/if this is possible?
    Thanks in advance.
    Best regards,
    Balze

    Have a look at this link:
    http://lavag.org/topic/15035-lapdog-messaging-and-actor-framework/
    Or this:
    http://lavag.org/topic/14600-self-addressed-stamped-envelopes/
    On lavag.org there are a lot of discussion on that type of framework. There are a whole section for OOP, try to see if anything help you. 
    Look for Actor Framework or LapDog.
    Some talk alot on messages between loops, but that is to control free runing loops/vi's.
    Hope this helps.

  • Upgrading from Weblogic 6.1sp5/TopLink 3.6.3 to Weblogic 8.1/TopLink 9.0.4

    Hi.
    We are doing the migration from Weblogic 6.1sp5/TopLink 3.6.3 to Weblogic 8.1 & TopLink 9.0.4
    We have been reading available documentation and started the migration. We have not had any problems with package ranaming issues and XML DOCTYPES changes.
    As we do have a lot of ammedmed querys, we do prefer to use a java class as our proyect mapping descriptor rather than a huge XML.
    We are currently porting all our querys to the new system.
    As we are doing a lot of changes we are also updating our EJB 1.1 entity beans to EJB 2.0 (maybe in the future we will deploy our EJBs with local interfaces too).
    The main problem we are facing right now is with all the querys we had in our toplink-cmp-<bean>.xml files. Even if most of the finders are "REDIRECT" querys that had to be ammendmed we have a good number of "EXPRESSION"s on them.
    As far as we are able to see we should move them to the TopLink Project java file in the querys section. The question is: is it possible to declare them in the ejb-jar.xml file into the <ejb-ql> tag (we have seen that the TopLinkImplemented string appears on the <ejb-ql> telling the container who should handle the query, so if Weblogic can be "tricked" to do that "ejb-ql" it may be possible to do the same with a TopLink expression isn't it?.
    Another issue we don't have clear is if now all the querys must be either ejb-ql (compliant with the EJB 2.0 standard) or named querys (either TopLink expressions or SQL querys) defined in the TopLink Project java or XML files. What happened with the redirect querys
    I would like to point just another issue we have "solved" but we are not really satisfied with how we solved it.
    We are using timestamp locking with our entity beans. The shouldBindAllParameters is set to true too and we have the logging activated so we have been able to track down the problem.
    The problem seems to be something like this.
    You create a new entity bean and TopLink issues a sentence like this against the DB (Oracle 8.1.7 I must say we have also configured the login session to use the Oracle8PlatformSupport)
    INSERT INTO FOO(OID,OCA) VALUES (?, ?)
    bind => [1, 2004-04-26 13:16:45.251]
    As far as we know Oracle 8.1.7 doesn't store the milliseconds (we are using DATE type in Oracle tables) so the ".251" value is stored as "0"
    Then we try to delete the entity bean and TopLink sends this sentence to the database:
    DELETE FROM FOO WHERE ((OID = ? AND OCA = ?))
    bind => [1, 2004-04-26 13:16:45.251]
    Then, a TOPLINK-5003 (the object has been modified or deleted since last read) is raised and the transaction is rolled back.
    We tried without binding and it works perfect (it seems that the timestamp is treated as YYYY-MM-DD SSSSS in the "to_date" function issued)
    As we would like to keep with binding all parameters in order to optimize our database accesses we have changed the default jdbc driver (sun.jdbc...) that is showed when reading the proper property of the login sesion with the oracle.jdbc.driver.OracleDriver. This latest driver seems to solve the problem with the reminders of the timestamps but this brings us a doubt.
    If we have configured two datasources in our Weblogic's config.xml file (one for transactional operations, beeing that one also an XA driver as we need to coordinate RDBMS operations with a JMS service, and the other one being a "standar" oracle.jdbc.driver.OracleDriver) why is that the driver used as default by the login method is that "weird" sun.jdbc... driver? Shouldn't TopLink use one (the XA driver I hopefully) of the drivers defined in Weblogic's datasource?
    1. Is the issue we are seeing with the timestamp a known bug/problem?
    2. Is there a better way to solve it than changing the driver (we are affraid of the "new" issues changing it could raise)
    I have seen that with TopLink 3.6.3 and the "default" driver used in the login (it is the same by default on both TopLink 3.6.3 and TopLink 9.0.4) the binded timestamp are "truncated" to the second resolution and it works without any problem.
    Thanks in advance.
    Ignacio

    Not sure on all of the issues, but can provide some information on some of them.
    Re-directors:
    Support was added for re-director to core queries, so now your named queries can make use of re-director if they require advanced dynamic execution. So all re-director queries can become named queries.
    Timestamp locking:
    In general we would always suggest numeric version locking if you have the choice. I'm not clear on what you are saying about the driver having an effect on the problem, however in general Oracle 8 does not support milliseconds, if you use timestamp locking with local timestamps they will have milliseconds and the database values will not match the ones in memory.
    To resolve this you can,
    - Use server timestamps TimestampLockingPolicy.useServerTime()
    - Clear the timestamp's milli/nano second value through an aboutToInsert event.
    - Extend Oracle8Platform.convertObject to clear the timestamp's milli/nano second value.
    - If you can use Oracle 9 or 10 there is now a TIMESTAMP type that does support milliseconds.
    If a different driver seems to be solving this, it is most likely the database ignores the milliseconds in the comparison, but the driver you are using sends the millisecond to the database incorrectly when binding.

  • OWB 9i Features.

    Hi All,
    I am planing to prepare a comparison document for feature provided by Oracle Warehouse Builder & Ab initio ver 1.11.15 as ETL.
    OWB config details
    Oracle Warehouse Builder Client 9i Ver 9.2.0.2.8
    Oracle Warehouse Builder Repository Ver 9.2.0.2.0.
    Windows XP OS.
    I believe following features are not avaialable in OWB 9i Release.
    1> OWB doesn't support Array, Union, Vector handling.
    2> OWB can read only ASCII Serial files & not Binary, Multifiles.
    3> Global Library feature is not available in OWB. To make it clear in Abinitio there is concept of Project Parameter file which can hold Global Variables can be referred in Ab initio graph, also these variables value can be assigned by execution of Unix Shell script.
    4> OWB doesn't support dynamic execution in a mapping. E.g. If a mapping consist of 5 flow operators at run time based on certain criteria certain flow operators can be disabled & will not get executed. This feature is available in Abinitio.
    5> Change Manager in OWB provides limited feature for Config Management.
    6> Optimization can be achieved by setting Set Based or Row Based option in configuration of OWB mapping.
    7> No flow operator is available for Cumulative summary records.
    8> Plug in component is required for Name & Address flow operator.
    I am aware that Oracle is planing to launch a new release OWB 10 G & it may be possible that some of above features will be available in the new release.
    Can someone please confirm my understanding is correct?
    Thanks in Advance.
    Regards,
    Vidyanand

    Hi Vidyanand,
    I will try to address some of your concerns/questions, but may need some more information on some of them:
    1> OWB doesn't support Array, Union, Vector handling.
    JPD: Array's are supported in the next release (end of the year). I'm not sure what you mean with Union (I'm guessing this NOT as SQL union) and vector handling. Can you elaborate a bit on those terms?
    2> OWB can read only ASCII Serial files & not Binary, Multifiles.
    JPD: OWB supports the capabilities of SQL Loader and External Tables. SQL Loader should be able to handle multiple files...
    3> Global Library feature is not available in OWB. To make it clear in Abinitio there is concept of Project Parameter file which can hold Global Variables can be referred in Ab initio graph, also these variables value can be assigned by execution of Unix Shell script.
    JPD: We are adding both global and local variable support in OWB (end of the year). You will be able to store the variables on the platform, which of course is in the database (secure and easy to access).
    4> OWB doesn't support dynamic execution in a mapping. E.g. If a mapping consist of 5 flow operators at run time based on certain criteria certain flow operators can be disabled & will not get executed. This feature is available in Abinitio.
    JPD: While this sounds very interesting, I'm struggling a bit with when you would want to use this, and even more with how the flow would be linked together if I randomly switch of operators...
    One of the things to keep in mind is that OWB generates code (I believe Ab Initio does not and interprets metadata at runtime). So this feature is harder to implement in a code generator. However I'm not convinced this is a crucial feature for ETL... Any thoughts?
    5> Change Manager in OWB provides limited feature for Config Management.
    JPD: Change Manager is intended for version management. We are adding full multi-configuration support in the next release where you can attach physical characteristic to objects. That combined with Change Manager will give you a much better configuration management tool.
    6> Optimization can be achieved by setting Set Based or Row Based option in configuration of OWB mapping.
    JPD: This is actually not correct. Set based vs row based will influence performance but is not intended for just that! It gives you different ways of interpreting a graph. In Row based you can do if-then code and row-by-row evaluations. Setbased has only SQL language as implementation.
    You can influence performance with various parameters:
    - Oracle DB Hints on both extract and load operators (in mapping that is)
    - Set the parallel degree on the objects (invokes database parallelism)
    - Influence the various code flavors with:
    > Bulk Processing and Bulk Size for processing multiple rows in one go (for rowbased settings)
    > Parallel row code (for rowbased settings)
    The latter allows you run PL/SQL row based sections in parallel within the DB (transparently).
    7> No flow operator is available for Cumulative summary records.
    JPD: I'm not sure what this means, is this covered by the aggregator?
    8> Plug in component is required for Name & Address flow operator.
    JPD: OWB supports this natively. What you do need is to purchase the library files that the operator runs on and you can do that from First Logic, Trillium and Data Flux allowing you to use OWB with the market leading data libraries (or with localized ones if desired). We think this is a much stronger story than a closed box vendor specific solution. OWB is intended to work globally and we open up this interface as some vendors have better support in some regions as others.
    But just to state this again, you do NOT need any plug-ins into the client tool and it is all there natively. You just have a choice of data libraries.
    Match/Merge is of course also supported and this is completely native (and free of charge).
    I sincerely think that OWB has the strongest data quality story in the ETL business!

  • Syntax error but I'm too blind to see...

    Using the below SQL from my usrStartFrm.ASP page to ORA 8i I have set a page variable = a session variable
    +++++++++++++++++++++++
    dim usrLoginID
    SUB usrStartFrm_onenter()
         usrLoginID = Session("LoginID")
    End SUB
    +++++++++++++++++++++++++
    But I cannot return records using the following syntax.
    SELECT DISTINCT
    L.LOGINID,
    B.BUSINESSSEGMENTNAME
    FROM SODA.ASSIGNMENTS_TB A,
    SODA.LOGINS_TB L,
    SODA.BUSSEGMENT_TB B
    WHERE A.FK_LOGIN_NO = L.LOGIN_NO
    AND
    A.FK_BUSSEGID = B.BUSSEGID AND
    (L.LOGINID = '" & usrLoginID &" ')
    ORDER BY B.BUSINESSSEGMENTNAME
    NOR DOES THIS
    ++++++++++++++++++++++++++++++++++++++++++++++++
    (L.LOGINID = '" & Session("LoginID") &" ')
    +++++++++++++++++++++++++++++++++++++++++++++++++
    BUT if I change the sytax to a hard code
    (L.LOGINID = 'ajgrasso')
    The query works.
    I know the page creates the variable because I print it out to the p;age as it loads..
    SO I figure it must be the bugaboo string single double qutes issue.
    Any Ideas.
    Thanks beforehand
    AJ

    It does help somewhat to see the complete code. I can now see and understand how you are building your select statement including your variable and storing the select statement to another variable to be executed. Unfortunately, I don't know enough about ASP and javascript and so forth to be certain of the correct code. However, I can see a lot of similarities between what you are doing and how we build a select statement in PL/SQL and store it to a variable for dynamic execution. There are various ways of including variables within that select statement. About the best I can do is offer various legitimate syntaxes in PL/SQL and hope that you can see the similarities and will be able to adapt one or more of them. In each of the examples below, which demonstrate slightly different methods, I have used current_user for the Oracle user, but you can substitute os_user for current_user in any of them if you want the operating system user. However, note that it will include the domain, like your_domain\ajgrasso so you may need to do some parsing for proper comparison. If you don't get any errors, but it also doesn't return any rows, it might be due to something like that. Notice that, when building a select statement and storing it to a variable, all single quotes within the string must be doubled. That is, replace each single quote with two single quotes (not double quotes) within the string. Also, in Oracle, || is the concatenation symbol, not &. However, because you are using ASP and javascript, if they require double quotes and &, then you may have to experiment with such substitutions. Please see what you can derive from the following and let us know. Also, if it doesn't work for you, please be specific as to whether it returns an error message or if it just doesn't return any rows. A cut and paste of the run, as I have done below, would help.
    SQL> -- test tables and data:
    SQL> SELECT * FROM scott.assignments_tb
      2  /
    FK_LOGIN_NO FK_BUSSEGID                                                        
              1           1                                                        
    SQL> SELECT * FROM scott.logins_tb
      2  /
      LOGIN_NO LOGINID                                                             
             1 SCOTT                                                               
    SQL> SELECT * FROM scott.bussegment_tb
      2  /
      BUSSEGID BUSINESSSEGMENTNAME                                                 
             1 SCOTT bussegname                                                    
    SQL>
    SQL>
    SQL> -- code samples using scott schema
    SQL> -- instead of soda schema:
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PACKAGE types_pkg
      2  AS
      3    TYPE weak_ref_cursor_type IS REF CURSOR;
      4  END types_pkg;
      5  /
    Package created.
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE test_procedure
      2    (p_weak_ref_cursor OUT types_pkg.weak_ref_cursor_type)
      3  AS
      4    CommandText VARCHAR2 (4000);
      5  BEGIN
      6    CommandText :=
      7    'SELECT      DISTINCT
      8             l.loginid,
      9             b.businesssegmentname
    10       FROM      scott.assignments_tb a,
    11             scott.logins_tb      l,
    12             scott.bussegment_tb  b
    13       WHERE      a.fk_login_no = l.login_no
    14       AND      a.fk_bussegid = b.bussegid
    15       AND      (l.loginid = SYS_CONTEXT (''USERENV'', ''CURRENT_USER''))
    16       ORDER BY b.businesssegmentname';
    17 
    18    OPEN p_weak_ref_cursor FOR CommandText;
    19  END test_procedure;
    20  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXECUTE test_procedure (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    LOGINID                        BUSINESSSEGMENTNAME                             
    SCOTT                          SCOTT bussegname                                
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE test_procedure
      2    (p_weak_ref_cursor OUT types_pkg.weak_ref_cursor_type)
      3  AS
      4    CommandText VARCHAR2 (4000);
      5  BEGIN
      6    CommandText :=
      7    'SELECT      DISTINCT
      8             l.loginid,
      9             b.businesssegmentname
    10       FROM      scott.assignments_tb a,
    11             scott.logins_tb      l,
    12             scott.bussegment_tb  b
    13       WHERE      a.fk_login_no = l.login_no
    14       AND      a.fk_bussegid = b.bussegid
    15       AND      (l.loginid = ' || 'SYS_CONTEXT (''USERENV'', ''CURRENT_USER'')' || ')
    16       ORDER BY b.businesssegmentname';
    17 
    18    OPEN p_weak_ref_cursor FOR CommandText;
    19  END test_procedure;
    20  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXECUTE test_procedure (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    LOGINID                        BUSINESSSEGMENTNAME                             
    SCOTT                          SCOTT bussegname                                
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE test_procedure
      2    (p_weak_ref_cursor OUT types_pkg.weak_ref_cursor_type)
      3  AS
      4    usrLoginID  VARCHAR2 (30);
      5    CommandText VARCHAR2 (4000);
      6  BEGIN
      7    usrLoginID := SYS_CONTEXT ('USERENV', 'CURRENT_USER');
      8 
      9    CommandText :=
    10    'SELECT      DISTINCT
    11             l.loginid,
    12             b.businesssegmentname
    13       FROM      scott.assignments_tb a,
    14             scott.logins_tb      l,
    15             scott.bussegment_tb  b
    16       WHERE      a.fk_login_no = l.login_no
    17       AND      a.fk_bussegid = b.bussegid
    18       AND      (l.loginid = ''' || usrLoginID || ''')
    19       ORDER BY b.businesssegmentname';
    20 
    21    OPEN p_weak_ref_cursor FOR CommandText;
    22  END test_procedure;
    23  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXECUTE test_procedure (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    LOGINID                        BUSINESSSEGMENTNAME                             
    SCOTT                          SCOTT bussegname                                
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE test_procedure
      2    (p_weak_ref_cursor OUT types_pkg.weak_ref_cursor_type)
      3  AS
      4    usrLoginID  VARCHAR2 (30);
      5    CommandText VARCHAR2 (4000);
      6  BEGIN
      7    usrLoginID := SYS_CONTEXT ('USERENV', 'CURRENT_USER');
      8 
      9    CommandText :=
    10    'SELECT      DISTINCT
    11             l.loginid,
    12             b.businesssegmentname
    13       FROM      scott.assignments_tb a,
    14             scott.logins_tb      l,
    15             scott.bussegment_tb  b
    16       WHERE      a.fk_login_no = l.login_no
    17       AND      a.fk_bussegid = b.bussegid
    18       AND      (l.loginid = :usrLoginID)
    19       ORDER BY b.businesssegmentname';
    20 
    21    OPEN p_weak_ref_cursor FOR CommandText USING usrLoginID;
    22  END test_procedure;
    23  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> EXECUTE test_procedure (:g_ref)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    LOGINID                        BUSINESSSEGMENTNAME                             
    SCOTT                          SCOTT bussegname                                
    SQL>
    SQL>
    SQL> CREATE OR REPLACE PROCEDURE test_procedure
      2    (p_weak_ref_cursor OUT types_pkg.weak_ref_cursor_type,
      3       usrLoginID       IN  VARCHAR2)
      4  AS
      5    CommandText VARCHAR2 (4000);
      6  BEGIN
      7    CommandText :=
      8    'SELECT      DISTINCT
      9             l.loginid,
    10             b.businesssegmentname
    11       FROM      scott.assignments_tb a,
    12             scott.logins_tb      l,
    13             scott.bussegment_tb  b
    14       WHERE      a.fk_login_no = l.login_no
    15       AND      a.fk_bussegid = b.bussegid
    16       AND      (l.loginid = :usrLoginID)
    17       ORDER BY b.businesssegmentname';
    18 
    19    OPEN p_weak_ref_cursor FOR CommandText USING usrLoginID;
    20  END test_procedure;
    21  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL> VARIABLE g_ref REFCURSOR
    SQL> VARIABLE usrLoginID VARCHAR2(30)
    SQL> EXECUTE :usrLoginID := SYS_CONTEXT ('USERENV', 'CURRENT_USER')
    PL/SQL procedure successfully completed.
    SQL> EXECUTE test_procedure (:g_ref, :usrLoginID)
    PL/SQL procedure successfully completed.
    SQL> PRINT g_ref
    LOGINID                        BUSINESSSEGMENTNAME                             
    SCOTT                          SCOTT bussegname                                

  • An INSERT EXEC statement cannot be nested.Please tel me some good way of formulation in following situation.

    Hi,
        The following query is showing error An INSERT EXEC statement cannot be nested
    CREATE PROCEDURE [dbo].[Procedur3]
    @para1 int
    AS
    BEGIN
    CREATE TABLE #tem
    select * from detialpar where did=@para1
    --this code is quite big and is called from many place so we kept it inside this SP , so that we can call the sp to get result.
    END
    CREATE PROCEDURE [dbo].[Procedur2]
    @para1 int
    @para2 datetime
    AS
    BEGIN
    CREATE TABLE #tem
    insert into #tem (value) exec [dbo].[Procedure3] @para1
    exec ('select * from abc
    left join #tem on id=temid
    where id =' + cast(@para1 as varchar) -- i do not want to change this big dynamic query, because it has many optonal code concatinated by using "if then else".
    END
    CREATE PROCEDURE [dbo].[Procedure1]
    @para1 int,
    @para2 datetime
    AS
    BEGIN
    delete from table1 where id=@para1
    insert into table1 ( col1,col2) exec Procedure2 @para1,@para2
    ……. There are many blocks in this SP where we are deleting and inserting with different SP .
    select Name,Amount from #Temp1
    END
    CREATE PROC Procedure
    AS
    BEGIN
    SET TRANSACTION ISOLATION LEVEL SNAPSHOT
    SET NOCOUNT ON
    LOOP "A" starts here which gests id from a table xyz @para1
    begin try
    begin trans
    exec [Procedure1] @para1
    LOOP "A" ents here
    COMMIT TRANSACTION;
    END TRY
    BEGIN CATCH
    IF @@trancount > 0 ROLLBACK TRANSACTION;
    END CATCH;
    END
    GO
    Please tel me some good way of solving the error.
    yours sincerly

    You can not do like above:
    Try the below:(Not tested), Below, we do not change the code, however, we placed your dynamic execution to different procedure.
    CREATE PROCEDURE [dbo].[Procedur3]
    @para1 int
    AS
    BEGIN
    CREATE TABLE #tem
    insert into #tem (value)
    select * from detialpar where did=@para1
    --this code is quite big and is called from many place so we kept it inside this SP , so that we can call the sp to get result.
    END
    CREATE PROCEDURE [dbo].[Procedur2]
    @para1 int
    @para2 datetime
    AS
    BEGIN
    CREATE TABLE #tem
    exec [dbo].[Procedure3] @para1
    END
    CREATE PROCEDURE [dbo].[Procedure1]
    @para1 int,
    @para2 datetime
    AS
    BEGIN
    delete from table1 where id=@para1
    insert into table1 ( col1,col2)
    exec ('select * from abc
    left join #tem on id=temid
    where id =' + cast(@para1 as varchar) -- i do not want to change this big dynamic query, because it has many optonal code concatinated by using "if then else".
    ……. There are many blocks in this SP where we are deleting and inserting
    with different SP .
    select Name,Amount from #Temp1
    END
    CREATE PROC Procedure
    AS
    BEGIN
    SET TRANSACTION ISOLATION LEVEL SNAPSHOT
    SET NOCOUNT ON
    LOOP "A" starts here which gests id from a table xyz @para1
    begin try
    begin trans
    exec [Procedure1] @para1
    LOOP "A" ents here
    COMMIT TRANSACTION;
    END TRY
    BEGIN CATCH
    IF @@trancount > 0 ROLLBACK TRANSACTION;
    END CATCH;
    END
    GO

  • "Best Practices" for using different Authentication Schemes ?

    Hi
    We are using different authentication schemes in different environments (Dev/QA/Prod). Changing the authentication scheme between the environments is currently a manual step during the installation. I am wondering if there are better "Best Practices" to follow, where the scheme is set programmatically as part of the build/ load process for a specific environment. ... or any other ideas.
    We refrained from merging the authentication schemes (which is possible) for the following reasons:
    - the authentication code becomes unnecessary complex
    - some functions required in some environments are not available in all environments (LDAP integration through centrally predefined APIs), requiring dynamic execution
    Any suggestions / experience / recommendation to share are appreciated.
    Regards,
    - Thomas
    [On Apex 4.1.0]

    t-o-b wrote:
    Thanks Vikram ... I stumbled over this post, I was more interested in what the "Work Around" / "Best Practices" given these restrictions.
    So I take it that:
    * load & change; or
    * maintain multiple exports
    seem to be the only viable options
    ... in addition to the one referred to in my questions.
    Best,
    - ThomasThomas,
    Its up-to you really and depends on many criteria +(i think its more of release process and version controlling)+.
    I haven't come across a similar scenario before..but I would maintain multiple exports so that the installation can be automated (no manual intervention required).
    Once the API is published +(god knows when it will be)+ you can just maintain one export with an extra script to call the API.
    I guess you can do the same thing with the load & change approach but I would recommend avoiding manual intervention.
    Cheers,
    Vikram

  • How to provide tuning solution from explain plan only

    Dear all,
    If I do not have any kind of access to the database and only have explain plan with me,how I can provideperformance or query  tuning solutions from that??
    Regards
    Anirban

    958657,
    If I do not have any kind of access to the database and only have explain plan with me,how I can provide performance or query  tuning solutions from that??
    This is contradictory as you said you don't have access but you have explain plan. You wont get any explain plan until you connect to the database and run "Explain plan for" statement for the query. How do you get the "explain plan"? If it is provided by someone to you, you might request to get the "Execution Plan" for the query.
    Keep in mind that "explain plan" and  "execution plan "  - these two are not same.
    Explain plan  is not enough for predicting elapsed/response time of a query as Explain plan is static Whereas Execution plan is dynamic and talks about query in execution.
    Oracle provides following things for a query to diagnose its performance :
    1. Static - Explain plan  - Not enough
    2. Dynamic:  Execution plan - Run time Plan
    3. awr/ statspack execution plan --Run time from the past - this is again dynamic execution plan of query runs in the past
    Tuning recommendation is possible by comparing run time of the same query in the past and today's run time and based on further analysis.
    Tuning Recommendation is not possible if you have only Explain plan.

  • Workspace Provisioning

    I recently upgraded my database from 10.0.2 to 10.0.3.
    Since then I have been unable to create/provision new workspaces. I tracked it down to an error in the patch application process which I need to fix.
    However, I am curious to know why the workspace provisioning process interacts with Oracle's Change Data Capture feature. Here's the Pl/SQL stack trace for the error
    ----- PL/SQL Call Stack -----
    object line object
    handle number name
    306E73A4 12 package body SYS.DBMS_CDC_IPUBLISH
    306061AC 5 anonymous block
    307D9C98 1590 package body SYS.DBMS_SYS_SQL
    307DA65C 200 package body FLOWS_020200.WWV_EXECUTE_IMMEDIATE
    2E209414 503 package body FLOWS_020200.WWV_FLOW_SAMPLE_APP
    2E209414 9 package body FLOWS_020200.WWV_FLOW_SAMPLE_APP
    305FF36C 896 package body FLOWS_020200.WWV_FLOW_PROVISIONING
    305FF36C 423 package body FLOWS_020200.WWV_FLOW_PROVISIONING
    2E2363B0 7 anonymous block
    307D9C98 1204 package body SYS.DBMS_SYS_SQL
    307DA65C 224 package body FLOWS_020200.WWV_EXECUTE_IMMEDIATE
    33C58A68 3949 package body FLOWS_020200.WWV_FLOW
    33C58A68 11526 package body FLOWS_020200.WWV_FLOW
    3047CDE4 22 anonymous block
    ----- Call Stack Trace -----
    calling call entry argument values in hex
    location type point (? means dubious value)
    621F54AF 00000000
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Varad,
    It appears to be happening during dynamic execution of one of the following operations, when the sample application is being created and the objects used by the app are first cleaned up in case they already exist:
    drop sequence demo_cust_seq
    drop sequence demo_order_items_seq
    drop sequence demo_ord_seq
    drop sequence demo_prod_seq
    drop sequence demo_users_seq
    drop sequence demo_images_seq
    delete from htmldb_application_files where id in ( <the images for the demo app> )
    drop table demo_order_items
    drop table demo_product_info
    drop table demo_states
    drop table demo_orders
    drop table demo_customers
    drop table demo_users
    drop table demo_images
    drop table demo_page_hierarchy
    drop function custom_hash
    drop function custom_auth
    Scott

Maybe you are looking for

  • Relese Purchase Order ....??

    Hi experts, I did Relese procedure for Purchase order . its working through ME29N  for relese PO. there was a 2 leves to relese PO   100 euro  -   1000 2nd  leves for relese                      1000euro  -   10000 after relesing first level system h

  • How can I update shockwave for director?

    Hi My Shockwave For Director plug-in is out of date but when I try to download it from Adobe's website stage 2 is skipped & the update will not even download let alone install.  Could anyone help please? I am currently using 12.0.4.14 Thank you!

  • PA GL IMPORT시 GROUP ID MISSING

    제품: FIN_GL 작성날짜 : 2006-05-30 PA GL IMPORT시 GROUP ID MISSING ============================== PURPOSE 특정 Group ID에 IMport가 안될경우 Problem Description "No records exist for this Source with a Group ID"에러 메시지로 GL Import가 안됨 Workaround gl_interface_control i

  • Overlapping subscriptions

    Hi All. I want to ask about overlapping subscriptions. I have already the subscription World minutes for Office 365 which provides me 60 minutes of free calling to my country. As i checked, i am interested to buy another subscription for my country t

  • [SOLVED]pacman: libusb-compat: /usr/bin/libusb-config exists ...

    Hi, I just installed the arch base system and did a 'pacman -S kernel26' and got some errors error: failed to commit transaction (conflicting files) libusb-compat: /usr/bin/libusb-config exists in filesystem libusb-compat: /usr/include/usb.h exists i