Using Table Variables MSSQL with xMII 11.5

I was trying an experiment with a query today where instead of creating a temp table in SQL, I used the T-SQL table variable.  For a simple example: 
DECLARE @ProductTotals TABLE
(  ProductID int,   Revenue money)
INSERT INTO @ProductTotals (ProductID, Revenue)
SELECT ProductID, SUM(UnitPrice * Quantity)
FROM [Order Details]
GROUP BY ProductID
SELECT *
FROM  @ProductTotals
Well, this works fine in SQL Query Analyzer , but not in xMII.  I get a message that says "no results returned from this query"    So you ask, "why not just use a temp table"  Well on the real application, the query can take up to 30 seconds to run, and I have the chance of having multiple users execute the same query in that time, in which my temp table will get stomped on creating an error.  So I thought of using table variables as a possible alternative to avoid this.  
I have already figured a work around, I put this code into a stored procedure and call that.  I could also do a similar workaround using separate queries / BLS.  However, I'm curious why xMII wouldn't execute this in the first place, being that it worked fine in Query Analyzer against the exact same database.

Doug,
I tried on my box with the "sqljdbc.jar" from 11.08.2006 (German Dateformat dd.MM.yyyy) and works also.
For my test I had using the following SQL-Statement:
DECLARE @ProductTotals TABLE
( ProductCount int, ProductID int, Revenue money)
INSERT @ProductTotals
SELECT count(O.ProductID) as ProductCount, P.ProductID, SUM(O.UnitPrice * O.Quantity)
FROM [Order Details] O
INNER JOIN Products P
ON O.ProductID = P.ProductID
GROUP BY P.ProductID
SELECT *
FROM @ProductTotals
Did you get a result back in MII only for the SELECT statement
SELECT count(O.ProductID) as ProductCount, P.ProductID, SUM(O.UnitPrice * O.Quantity)
FROM [Order Details] O
INNER JOIN Products P
ON O.ProductID = P.ProductID
GROUP BY P.ProductID
? My opinion is, that your select brings nothing back.
Regards
Pedro

Similar Messages

  • How to use Table valued MSSQL  function in OBIEE

    Hi all,
    Can some one help me to understand how to use table valued function in OBIEE? I want to use a table valued function (MSSQL function, with some input parameter), in the physical layer to pull the data?
    I know for MSSQL Stored Procedure we can write as
    EXEC SP_NAME @Parameter = 'VLUEOF(NQ_SESSION.Variablename)'
    but now I have a table valued function in the query window I can get the data as
    select * from myfunction(parametervalue)
    In physical layer of OBIEE I have tried as
    select * from myfunction('VLUEOF(NQ_SESSION.Variablename)'), but I'm getting error as the NQ_SESSION variable doesn't have a value , but actually I have initialized the variable but still Im getting error.
    Can some one help me to solve this.
    Thanks,
    Mithun

    Follow this link and try yourself. let me know for issues
    Substring instr issue in obiee
    Appreciate if you mark
    Edited by: Srini VEERAVALLI on Feb 20, 2013 8:13 AM

  • Use of variable passed with url

    hi ,
    i am new user for this forum.
    i have one problem. i call the html page resides in
    coldfution directory from the another web server. now my problem is
    that how can i get the variable which are passed with URL ? for
    example i call page x.x.x:8500//temp/test.html?id=2 from other
    windows web server ie x.x.x.//temp1/test1.php.
    now my problem is that is there any facility in coldfusion to
    get the value of the variable which are passed with URL . in this
    case it is ID

    Hi
    do you mean accessing the URL varialbes in CF?
    if it is you can say #URL.varname#.

  • Using Presentation variables..along with case statements..

    Hi All.
    I have a issue using presentation variable along with CASE statements. My approach is
    1) I have a dashboard prompt, which is being set as Presentation variable.
    Based on the value selected in prompt, for ex the values of prompt can be 'ABC' and 'DEF'.
    I have a calculated column, the calculation goes this way...
    The forumal is
    CASE WHEN @{Presentation Variable Name} = 'ABC' THEN xxxxxxxxxx ELSE IF @{Presentation Variable Name} = 'DEF' END. It gives error of "no table being referenced"..
    Is this is the right approach??
    Can i get the values of variable in a column formula, so that a column can have values selected in prompt?
    Can anybody pls help me here..
    Thanks in advance...

    Hi
    Thanks for the quick response..
    I agree to ur point..
    But the requirement is
    Based on the value of the prompt I need to switch the calculation in one of the formula area of one column..
    If Prompt value is ABC then one kind of calculation in Fx and If the prompt value is DEF then one kind of calculation in the same Fx..
    How can I acheive this?
    Thanks in advance..

  • Using a variable with "tell application"

    I'd like to use a variable (app_name) with "tell application" in the following function:
    on getAdobeDoc(app_name)
    tell application app_name
    tell current document
    return (name as Unicode text)
    end tell
    end tell
    end getAdobeDoc
    but I'm getting the following error in Script Editor
    "Expected end of line but found class name." with the word "document" highlighted.
    Are you allowed to use variables in "tell application"? All Adobe CS apps seem to use the same format to get the document name so I'd like to use one function to get them.

    If the application might have a different name on the target machine (for example, if it has a version number added), you can use an application's bundle identifier (or creator code) to set the variable, in which case the using terms from statement tells AppleScript the application (on your machine) to get the dictionary terms from. If the application you are using terms from has a dictionary identical to your variable, everything should work the same. The following example uses a variable (called, appropriately enough, TexttEdit) for the TextEdit application:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Finder" to set TextEdit to the name of application file id "com.apple.TextEdit"
    tell application TextEdit
    using terms from application "TextEdit"
    launch
    make new document with properties {text:"This is a test"}
    end using terms from
    end tell
    </pre>

  • RE: Table Variable error in a query

    Dear Readers, I am getting this error below when I create the table variable . Any ideas where I could be going wrong...
    Use GG_TS
    GO
    --Using table variable
    Declare @customerscount table
    (firstname char(30),
     totals int,
     customerNumber int)
    Insert @customerscount
    Select
          Customers.firstname,
          Count(*) as 'Totals',
          Orders.CustomerNumber
    FROM
         Customers join orders ON
         customers.customernumber = orders.customernumber
    Group BY
          customers.firstname,orders.customernumber
    The error I am getting is below:
    Incorrect syntax near the keyword 'table'.
    Thanks so much!
    SQL 75

    No, Now it's giving me a different error. Below is the error: By the way I am running this in SQL server 2012
    under tempDB as it is a table variable.
    Msg 208, Level 16, State 1, Line 6
    Invalid object name 'Customers'.
    Below is my Query:
    Declare @customerscount table
    (firstname char(30),
     totals int,
     customerNumber int)
    Insert @customerscount
    Select
          Customers.firstname,
          Count(*) as 'Totals',
          Orders.CustomerNumber
    FROM
         Customers join orders ON
         customers.customernumber = orders.customernumber
    Group BY
          customers.firstname,orders.customernumber
    Thank-you
    SQL 75
    No need to run this in tempdb
    You can run this in your database itself ie database where tables customers, orders etc exist and table variable gets created in tempdb itself
    The reason for your error is because it cant find the tables in the tempdb database
    So run the query in your own database
    Otherwise you need to change it as below if you stiil want this to be executed in tempdb
    Declare @customerscount table
    (firstname char(30),
    totals int,
    customerNumber int)
    Insert @customerscount
    Select
    c.firstname,
    Count(*) as 'Totals',
    o.CustomerNumber
    FROM
    <yourdbname>.dbo.Customers c join <yourdbname>.dbo.orders o ON
    c.customernumber = o.customernumber
    Group BY
    c.firstname,o.customernumber
     assuming dbo is your default schema
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Use a variable as a table name with NATIVE SQL

    Hi all,
    I am trying to execute a SELECT statement in order to fetch data from an external Oracle DB table to SAP with the following instructions:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM spfli
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    However, I need to indicate the external table name from a variable instead of the solution above. That is, declaring a variable and store the name of the table (e.q. spfli) in it. The resulting ABAP code would be something like:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM <VARIABLE>
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    Does anybody know if is possible to do that?
    If not, is there any other solution?
    Thank you in advance

    Yes, as Suhas said, you could use the ADBC API and his class CL_SQL_CONNECTION to achieve this...
    Here is a small example:
    PARAMETERS: p_carrid TYPE spfli-carrid,
                               p_connid TYPE spfli-connid.
    DATA:
      l_con_ref      TYPE REF TO cl_sql_connection,
      l_stmt         TYPE string,
      l_stmt_ref     TYPE REF TO cl_sql_statement,
      l_dref         TYPE REF TO data,
      l_res_ref      TYPE REF TO cl_sql_result_set,
      l_col1         TYPE spfli-carrid,
      l_col2         TYPE spfli-connid,
      l_wa           TYPE spfli.
    CONSTANTS:
      c_tabname  TYPE string VALUE 'SPFLI'.
    * Create the connecction object
    CREATE OBJECT l_con_ref.
    * Create the SQL statement object
    CONCATENATE 'select * from' c_tabname 'where carrid = ? and connid = ?'
           INTO l_stmt SEPARATED BY space.                           "#EC NOTEXT
    l_stmt_ref = l_con_ref->create_statement( ).
    * Bind input variables
    GET REFERENCE OF l_col1 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    GET REFERENCE OF l_col2 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    * Set the input value and execute the query
    l_col1 = p_carrid.
    l_col2 = p_connid.
    l_res_ref = l_stmt_ref->execute_query( l_stmt ).
    * Set output structure
    GET REFERENCE OF l_wa INTO l_dref.
    l_res_ref->set_param_struct( l_dref ).
    * Show result
    WHILE l_res_ref->next( ) > 0.
      WRITE: / 'Result:', l_wa-carrid, l_wa-connid.
    ENDWHILE.
    * Close the result set object
    l_res_ref->close( ).
    Otherwise you can also use the FM DB_EXECUTE_SQL...
    Kr,
    m.

  • Using a Variable with AJAX

    Hello,
    Below I have posted code that I have on two different PHP files, tsearch12.php and votes12.php. The code works great. The file "tsearch12.php" uses AJAX to go to votes12.php to perform some functions. However, the first page has a variable called "find." These two pages only work together when the variable "find" equals "santafe." I would like them to work together regardless of what "find" equals. In other words, I would like to replace the table name "santafe" in votes12.php with the variable "find," but I want the variable "find" to equal the same value in both tsearch12.php and votes12.php. The variable "find" is going to tsearch12.php from another file, which has a simple HTML form with "<form action="tsearch12.php" method="post">" and "<input type="text" name="find" size="55"/>". Anyway, how do I use the variable "find" in votes12.php?
    Thanks in advance,
    John
    On tsearch12.php, I have:
    # <head> 
    # <script type='text/javascript' src='jquery.pack.js'></script> 
    # <script type='text/javascript'> 
    # $(function(){ 
    #     $("a.cell1").click(function(){ 
    #     //get the id 
    #     the_id = $(this).attr('id'); 
    #     // show the spinner 
    #     $(this).parent().html("<img src='images/spinner.gif'/>"); 
    #     //fadeout the vote-count  
    #     $("span#votes_count"+the_id).fadeOut("fast"); 
    #     //the main ajax request 
    #         $.ajax({ 
    #             type: "POST", 
    #             data: "action=vote_up&id="+$(this).attr("id"), 
    #             url: "votes12.php", 
    #             success: function(msg) 
    #                 $("span#votes_count"+the_id).html(msg); 
    #                 //fadein the vote count 
    #                 $("span#votes_count"+the_id).fadeIn(); 
    #                 //remove the spinner 
    #                 $("span#button"+the_id).remove(); 
    #     $("a.vote_down").click(function(){ 
    #     //get the id 
    #     the_id = $(this).attr('id'); 
    #     // show the spinner 
    #     $(this).parent().html("<img src='images/spinner.gif'/>"); 
    #     //the main ajax request 
    #         $.ajax({ 
    #             type: "POST", 
    #             data: "action=vote_down&id="+$(this).attr("id"), 
    #             url: "votes12.php", 
    #             success: function(msg) 
    #                 $("span#votes_count"+the_id).fadeOut(); 
    #                 $("span#votes_count"+the_id).html(msg); 
    #                 $("span#votes_count"+the_id).fadeIn(); 
    #                 $("span#button"+the_id).remove(); 
    # </script> 
    # </head> 
    # <body> 
    # <? 
    # //This is only displayed if they have submitted the form 
    # if ($searching =="yes") 
    # //If they did not enter a search term we give them an error 
    # if ($find == "") 
    # echo "<p>You forgot to enter a search term"; 
    # exit; 
    # // Otherwise we connect to our Database 
    # mysql_connect("mysqlv3", "username", "password") or die(mysql_error()); 
    # mysql_select_db("sand2") or die(mysql_error()); 
    # $find = strip_tags($find); 
    # $find = trim ($find); 
    # $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") 
    # or die(mysql_error()); 
    # if(mysql_num_rows($result)>0){ 
    # while($table=mysql_fetch_row($result)){ 
    # print "<p class=\"topic\">$table[0]</p>\n"; 
    # $r=mysql_query("SELECT * FROM `$table[0]`"); 
    # print "<table class=\"navbar\">\n"; 
    # while($row=mysql_fetch_array($r)){ 
    # $effective_vote = $row['votes_up'] - $row['votes_down'];  
    # print "<tr>"; 
    # print "<td>".'<a href="http://'.$row['site'].'" class="links2">'.$row['site'].'</a>'."</td>"; 
    # print "<td class='votes'>".'<span class="votes_count" id="votes_count'.$row['id'].'">'.number_format($effective_vote).'</span>'."</td>"; 
    # print "<td class='ballot'>".'<span class="button" id="button'.$row['id'].'">'.'<a href="javascript:;" class="cell1" id="'.$row['id'].'">'.Vote.'</a>'.'</span>'."</td>"; 
    # print "</tr>\n"; 
    # print "</table>\n"; 
    # else{ 
    # print "None found"; 
    # $anymatches=mysql_num_rows($result); 
    # if ($anymatches == 0) 
    # echo "Sorry, but we can not find an entry to match your query<br><br>"; 
    # ?>    On votes12.php, I have:
    # <?php 
    # mysql_connect("mysqlv3", "username", "password") or die(mysql_error()); 
    # mysql_select_db("sand2") or die(mysql_error()); 
    # function getAllVotes($id) 
    #     Returns an array whose first element is votes_up and the second one is votes_down
    #     $votes = array(); 
    #     $q = "SELECT * FROM santafe WHERE id = $id"; 
    #     $r = mysql_query($q); 
    #     if(mysql_num_rows($r)==1)//id found in the table 
    #         $row = mysql_fetch_assoc($r); 
    #         $votes[0] = $row['votes_up']; 
    #         $votes[1] = $row['votes_down']; 
    #     return $votes; 
    # function getEffectiveVotes($id) 
    #     Returns an integer
    #     $votes = getAllVotes($id); 
    #     $effectiveVote = $votes[0] - $votes[1]; 
    #     return $effectiveVote; 
    # $id = $_POST['id']; 
    # $action = $_POST['action']; 
    # //get the current votes 
    # $cur_votes = getAllVotes($id); 
    # //ok, now update the votes 
    # if($action=='vote_up') //voting up 
    #     $votes_up = $cur_votes[0]+1; 
    #     $q = "UPDATE santafe SET votes_up = $votes_up WHERE id = $id"; 
    # elseif($action=='vote_down') //voting down 
    #     $votes_down = $cur_votes[1]+1; 
    #     $q = "UPDATE santafe SET votes_down = $votes_down WHERE id = $id"; 
    # $r = mysql_query($q); 
    # if($r) //voting done 
    #     $effectiveVote = getEffectiveVotes($id); 
    #     echo $effectiveVote; 
    # elseif(!$r) //voting failed 
    #     echo "Failed!"; 
    # ?>  

    These forums are for development with Java. Not JavaScript, which is an entirely different language. And AJAX is JavaScript. You need to use Google and find a JavaScript forum for your question (or a PHP forum if your question is really about PHP).

  • Using bind variables (in & out) with dynamic sql

    I got a table that holds pl/sql code snippets to do validations on a set of data. what the code basically does is receiving a ID and returning a number of errors found.
    To execute the code I use dynamic sql with two bind variables.
    When the codes consists of a simpel query, it works like a charm, for example with this code:
    BEGIN
       SELECT COUNT (1)
       INTO :1
       FROM articles atl
       WHERE ATL.CSE_ID = :2 AND cgp_id IS NULL;
    END;however when I get to some more complex validations that need to do calculations or execute multiple queries, I'm running into trouble.
    I've boiled the problem down into this:
    DECLARE
       counter   NUMBER;
       my_id     NUMBER := 61;
    BEGIN
       EXECUTE IMMEDIATE ('
          declare
             some_var number;
          begin
          select 1 into some_var from dual
          where :2 = 61;
          :1 := :2;
          end;
          USING OUT counter, IN my_id;
       DBMS_OUTPUT.put_line (counter || '-' || my_id);
    END;this code doesn't really make any sense, but it's just to show you what the problem is. When I execute this code, I get the error
    ORA-6537 OUT bind variable bound to an IN position
    The error doesn't seem to make sense, :2 is the only IN bind variable, and it's only used in a where clause.
    As soon as I remove that where clause , the code will work again (giving me 61-61, in case you liked to know).
    Any idea whats going wrong? Am I just using the bind variables in a way you're not supposed to use them?
    I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit

    Correction. With execute immediate binding is by position, but binds do not need to be repeated. So my statement above is incorrect..
    You need to bind it once only - but bind by position. And the bind must match how the bind variable is used.
    If the bind variable never assigns a value in the code, bind as IN.
    If the bind variable assigns a value in the code, bind as OUT.
    If the bind variable assigns a value and is used a variable in any other statement in the code, bind as IN OUT.
    E.g.
    SQL> create or replace procedure FooProc is
      2          cnt     number;
      3          id      number := 61;
      4  begin
      5          execute immediate
      6  'declare
      7          n       number;
      8  begin
      9          select
    10                  1 into n
    11          from dual
    12          where :var1 = 61;       --// var1 is used as IN
    13 
    14          :var2 := n * :var1;     --// var2 is used as OUT and var1 as IN
    15          :var2 := -1 * :var2;    --// var2 is used as OUT and IN
    16  end;
    17  '
    18          using
    19                  in out id, in out cnt;  --// must reflect usage above
    20 
    21          DBMS_OUTPUT.put_line ( 'cnt='||cnt || ' id=' || id);
    22  end;
    23  /
    Procedure created.
    SQL>
    SQL> exec FooProc
    cnt=-61 id=61
    PL/SQL procedure successfully completed.
    SQL>

  • Using bind variable with IN clause

    My application runs a limited number of straight up queries (no stored procs) using ODP.NET. For the most part, I'm able to use bind variables to help with query caching, etc... but I'm at a loss as to how to use bind variables with IN clauses. Basically, I'm looking for something like this:
    int objectId = 123;
    string[] listOfValues = { "a", "b", "c"};
    OracleCommand command = new OracleCommand();
    command.Connection = conn;
    command.BindByName = true;
    command.CommandText = @"select blah from mytable where objectId = :objectId and somevalue in (:listOfValues)";
    command.Parameters.Add("objectId", objectId);
    command.Parameters.Add("listOfValues", listOfValues);
    I haven't had much luck yet using an array as a bind variable. Do I need to pass it in as a PL/SQL associative array? Cast the values to a TABLE?
    Thanks,
    Nick

    Nevermind, found this
    How to use OracleParameter whith the IN Operator of select statement
    which contained this, which is a brilliant solution
    http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html

  • MySQL - In a Query, Using a Variable as a Table Name

    Hello,
    The code I have attached works. However, I would like to
    replace the table name "tractors" with the variable "$result". How
    do I do this? (It doesn't work if I just type "$result" where
    "tractors" is.)
    Thanks,
    John

    ArizonaJohn wrote:
    > The code I have attached works. However, I would like to
    replace the table
    > name "tractors" with the variable "$result". How do I do
    this?
    You can't. In the code you have given $result is a MySQL
    database result
    resource. You need to extract the actual value from the
    result resource
    in the same way as you have done by using
    mysql_fetch_array().
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/

  • ORA-01722: invalid number caused with SQL using bind variable

    Hi,
    Im am hoping that someone can help me resolve a problem thats only just services and is being experienced on quite a few clients.
    our application uses C++ exes and makes OCI calls to the database.
    what has happened in the last week or so, there has been quite a few invalid number errors being received on a prod server but strangly enough we cannot reproduct the error on our UAT system.
    The sql is using bind variables and the information in the trace file shows that a number is being used for the bind variable, here is an extract from one trace file:
    for some schemas, the bind variable value is some currupted value, i think:
    oacdty=01 mxl=32(21) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=9a8d62b8 bln=32 avl=03 flg=05
    value="Â*d"
    but on another schema, the value used is:
    Bind#0
    oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=c5f92718 bln=32 avl=04 flg=05
    value="2101"
    however both produce invalid number errors.
    I am relatively inexperienced as a DBA so would appreciate as much help as i can get.

    Could you post your sql statement that is being run.
    Also post the query plan from your uat system and the one from your production system (They are likely to be different)
    You can export the stats from your production system and run them in your uat system. If you do this, then the execution plans should be the same on both systems(dbms_stats) and if you have the same data you should run into the same problem on uat as in production.
    The root cause of this type of problem is having a column in a table which holds values which are of different datatypes. Typically there is a condition in the where clause which indicates that for example only numeric columns should be retrieved from the column which holds multiple data types. However since the optimizer is free to rewrite the query any way it sees fit, (It does not necessarily execute in the order the sql statement is written) it does not filter this data first, and therefore you hit non-numeric data and run into the invalid number error.
    You can use little techniques like using an inline view with rownum in the column list, to perform the first filter. This ensures that the inline view is executed on its own, rather than being merged (materialized) with the rest of the query.
    A quick temporary solution is to use a comparison like to_char(column_name) = variable
    Make sure your comparisons are correct and it doesn't negatively impact on performance of the query

  • Using a dynamic table variable in a stored procedure

    SQL Server can do this where you declare a table variable and insert / modify / delete rows in that table without it ever being actually ON the database.
    Can Oracle do this?
    I know I can do things like pass in a unique user id, create the table in the procedure with the user ID appended, etc ...
    but this procedure is going to be accessed via two modes, a batch job as well as online. The batch job may run this procedure 500 times.
    What I'm trying to is figure out a way to return a recordset of errors that occured in the job, simple, 3 lines like so:
    LineNumber NUMBER,
    Severity VARCHAR(10),
    Error_Msg VARCHAR(200)
    is there any 3 dimensional way of storing these records when the errors occur, then returning them as a select statement at the end of the procedure?
    Thanks,

    Why not create a table
    CREATE TABLE error_log (
      job_id  NUMBER,
      line_number NUMBER,
      severity VARCHAR2(10),
      error_msg VARCHAR2(200)
    CREATE SEQUENCE seq_error_log_job_id
      START WITH 1
      INCREMENT BY 1
      CACHE 100;In your procedure, you would get a new job_id from the sequence, insert whatever records you want in the error log table using that job_id and then return a REF CURSOR where you select from the error_log table using the job_id.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Using bind variables with sql statements

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

  • Select tables filed name by using global variables

    Hi
    I try to redesign a BODI jobs for monthly statistics. At the moment, I have a job for every month because in the source system (MS Axapta) the source table have the following design:
    YEAR     JAN      FEB    MARCH ...
    2010       100      231     233
    So, if I load the data for the January, I will load only this filed from the table:
    select YEAR, JAN from STATISTICS
    For the February, I will load only this filed:
    select YEAR, FEB from STATISTICS
    otherwise, I have a lot of dublicated BODI Jobs and a lot of work for maintenance.
    In this case, I try to use a variable in the mapping field in a Query transform, but doesn't working. Also in the SQL transform, but I was not able to do that.
    I know, that I can solve that with a Pivot-Transform, but I have to load some millions of data and I have no time to wait until the Pivot is finish.
    Do anybody have a other idee to solve my problem?
    Many thanks
    Christoph

    Thanks for your answer.
    How can I do that in the SQL Transform?
    If I try the with the following SQL Code, I become a ORA-00911 Error Message:
    SELECT Year, $Periode from STATISTIK
    Any idea
    Thanks
    Christoph

Maybe you are looking for

  • New! Attachments - Upload files as part of a form submission

    You can now add multiple file attachment fields to your forms to collect  files from respondents. Almost all file formats are supported for upload including audio and video (executable and other such file types are not allowed). All files are virus s

  • Text length at selection screen

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-000.   SELECTION-SCREEN COMMENT /3(79) TEXT-001.   SELECTION-SCREEN COMMENT /3(79) TEXT-002. SELECTION-SCREEN END OF BLOCK B1. in above code I can write text upto 79 length only how can I incre

  • Can I connect via HDMI and get 1920x1080?

    Can I connect my MacBook Pro HDMI adapter up to my new Samsung Display via the HDMI connection and get 1920x1080?  Or is the 1080p the best display I can do with that connection?  Should I get the VGA adapter instead?

  • Purchase Requisition transfer from ECC to SRM via XI

    Experts, Please let me know if you have any information on  the following issue: Environment : SRM 7.0,  ECC ep4,  Extended Classic scenario The purchase requisitions have been created in ECC and released. I believe in SRM 7.0  the PR's get automatic

  • Epson Stylus C88 won't print

    I haven't printed to this printer in a while, so who knows what happened, but today, I try to print, and the print queue for my Epson Stylus C88 will show every job with a Status of "Error". The queue says "Printer Ready" The Epson Printer Utility ca