Don't get a result set from a query to mySql database

Hello everyone,
I am writing a program in which i refer to a mySql database.
I encountered a problem using the executeQuery in which i don't get a resultSet at the end of the run,
instead i get a null.
gust for the record, the api says that it will never return null(se 6), also i queried the DB with a mySql client and the data is there
and when i use execute("") everything works fine.
I just can't get my wished result.
the peace of code I am referring to is here, please feel free to say if you need more code...
public static ResultSet getAccountResSet(int id) throws SQLException {
         //String query = "SELECT acctNum, acctOwnerId, acctOwnerName, balance, acctType, creditLimit, yearlyInterest, duration, creationDate, relatedCheckingAccoun FROM accounts WHERE acctNum="+id;
         String query = "select * from accounts where id="+id;
         ResultSet rs = statement.executeQuery(query);//this line falls, rs is null and i get null pointer exception
         return rs;
    }thanks for you help :)
Edited by: gizmokaka on Mar 29, 2008 8:37 AM

Maybe it's not the function executeQuery(query) that gives you the nullpointer. I think it may be that there is no connection to the DB, in which case the statement variable is null. Call to a method through this variable will trigger a nullpointer. Could you please post the exception text here? It may tell you where the NullPointerException occurs.
//Chris

Similar Messages

  • It is required to get the result set from the last query.

    I need this SP to return the result set from the last query.
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON
    GO
    alter        proc spQ_GetASCBillingRateIDs2
    @ScheduleID CHAR(15),
    @startdate smalldatetime,
    @enddate smalldatetime
    as
    set nocount on
    truncate table tbltmpgroup
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbltmptbltest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[tbltmptbltest]
    exec sp_CreateTblTmpGroup
    insert into tbltmpgroup
    SELECT DISTINCT
    case when pd.billparent = 'N' then org.eligibleorgid
    else isnull(af.parentid, org.eligibleorgid) end as billorgid,
    pd.individualbill , pd.cobrabill, pd.billparent,
    org.eligibleorgid, org.polid, org.orgpolicyid,
    pp.planid,  pp.rateid,
    ps.ascinvoicedate,
    case when ps.ascclaimfromdate > @startdate then ps.ascclaimfromdate
    else @startdate end as premiumrundayFrom,
    case when ps.ascclaimtodate < @enddate then ps.ascclaimtodate
    else @enddate end as premiumrundayTo,
    fts.effdate, fts.termdate,
    case when fts.effdate > @startdate then fts.EffDate
    else @startdate end as ascStartDate,
    case when fts.termdate < @enddate then fts.termdate
    else @enddate end as ascEndDate
    FROM premiumschedule ps (nolock)
    inner join orgpolicy org (nolock)
    on org.ascinvoicerungroup between ps.premiumrundayfrom and ps.premiumrundayto
    inner join FundingTypeStatus fts
    on fts.orgpolicyid = org.orgpolicyid
    and fts.fundtype = 'ASC'
    and ((fts.effdate between @startdate and @enddate)
    or (fts.termdate between @startdate and @enddate)
    or (fts.effdate < @startdate and fts.termdate > @enddate))
    inner join eligibilityorg o (nolock)
    on org.eligibleorgid = o.eligibleorgid
    inner join policydef pd (nolock)
    on pd.polid = org.polid
    inner join policyplans pp (nolock)
    on pp.polid = org.polid
    inner join program p (nolock)
    on pd.programid = p.programid
    left join orgaffiliation af with (nolock)
    on org.eligibleorgid = af.childid
    WHERE ps.premiumscheduleid = @ScheduleID
    AND org.orgpolicyid <> ''
    go
    SELECT DISTINCT z.rateid, e.enrollid, z.ascstartdate, z.ascenddate
    into tbltmptbltest FROM enrollment E (nolock)
    inner join tbltmpgroup z
    on e.rateid = z.rateid
    go
    CREATE UNIQUE CLUSTERED INDEX IDXTempTable  ON tbltmptbltest(enrollid)
    create index IDXTemptableDates on tbltmptbltest(ascstartdate,ascenddate)
    go
    select distinct t.*
    from tbltmpgroup t
    where rateid in (
    select distinct t.rateid from VW_ASC_Billing)
    order by billorgid
    set nocount off
    GO
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON
    GO

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you have no idea).
    Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    What you did post is bad SQL. 
    The prefix “tbl-” is a design flaw called tibbling and we do not do it. We seldom use temp tables in RDBMS; it is how magnetic tape file programmers fake scratch tapes. 
    If the schema is correct, then SELECT DISTINCT is almost never used. 
    Your “bill_parent” looks like a assembly language bit flag; we never use those flags in SQL. 
    “Funding_Type_Status” is an absurd name for a table. A status is a state of being, not an entity. A type is an attribute property. So this table ought to be column that is either a “funding_type” or “funding_status” (with the time period for the state of being
    shown in other columns). But this hybrid is not possible in a valid data model. 
    Want to try again, with DDL and some specs? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Error in result set from join query

    I get a SQL exception from the JDBC thin driver when I make a getXXX( "string" ) call on a result set object when the query is a join. Aliases don't seem to help.
    Below is the stack trace.
    Anybody have any ideas?
    matt
    ResultSet.findColumn
    java.sql.SQLException: Invalid column name: get_column_index
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:427)
    at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java, Compiled Code)
    at oracle.jdbc.driver.OracleResultSet.findColumn(OracleResultSet.java:680)
    at person.PersonMgr.getForEdit(PersonMgr.java:114)
    at person.PersonMgr.getForView(PersonMgr.java:168)
    at person.PersonMgr.getPersonForView(PersonMgr.java:164)
    at nwsession.NWSession.login(NWSession.java:224)
    at jsp.dologin._jspService(dologin.java:241)
    at com.livesoftware.jsp.HttpJSPServlet.service(HttpJSPServlet.java:31)
    at com.livesoftware.jsp.JSPServlet.service(JSPServlet.java:129)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
    at com.livesoftware.jrun.JRun.runServlet(JRun.java, Compiled Code)
    at com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java:116)
    at com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(JRunProxyServiceHandler.java, Compiled Code)
    at com.livesoftware.jrun.service.ThreadConfigHandler.run(ThreadConfigHandler.java, Compiled Code)

    Your reference to NS.REQDATE is too deep. Oracle will only allow you to reference a column from the main query one level deep.
    I think you can just change that query into this:
    (Select AVG(((cpath.REQUESTDATETIME)- NS.REQDATE)*1440) AvgTime
    FROM usersessiondetails cpath
    Where cpath.Userkey=(Select Userkey from ods_user where userid=NS.UserId and namespace=NS.Namespace)
       and cpath.acctnum=aCCTNUM
       and cpath.transactionname IN (AUTH_LOGOFF' )
       and cpath.REQUESTDATETIME = NS.REQDATE )You do not need the extra query level to do the AVG.

  • Creating a total result set from a query

    I am having an issue trying to come up with a solution to return a table with the following stored procedure and then at the bottom being able to have a table row that shows the totals.  Do I need to run a separate query for this...here is what I have:
    Create PROCEDURE [dbo].[usp_me_totalquestion]
    @startDate datetime = NULL
    , @ENDDate datetime = NULL
    , @userid int = -1
    , @groupByScript int = 0
    , @groupByAgent int = 0
    , @groupByDate int = 0
    AS
    set nocount on
    begin
    DECLARE @sql VARCHAR(max)
    DECLARE @where VARCHAR(200)
    SELECT
    --[AgentName] = (CASE WHEN @userid > 0 THEN FullName ELSE 0 END),
    [scriptload] = count(*),
    [scriptread] = sum(CASE WHEN ScriptRead > 0 THEN 1 ELSE 0 END),
    [scriptreadpercent] = round(CASE WHEN count(*) = 0 THEN 0.00 ELSE (sum(CASE WHEN scriptread > 0 THEN 1 ELSE 0 END)/cASt(count(*) AS DECIMAL(6,2))) * 100 END,1),
    [cancelled] = sum(CASE WHEN STATUS = 'F' THEN 1 ELSE 0 END),
    [retained] = sum(CASE WHEN STATUS = 'S' THEN 1 ELSE 0 END)
    FROM ccp_customer_retention_log r
    inner join ccp_users u
    ON r.id = u.id
    WHERE r.insertdt between CAST(@startDate AS VARCHAR(15)) and CAST(@EndDate AS VARCHAR(15))
    group by
    CASE
    WHEN @GroupByScript = 1 THEN r.scriptID
    WHEN @GroupByAgent = 1 THEN u.fullname

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. 
    Please stop using “usp_” prefixes. It looks like FORTRAN I and II instead of SQL. We have DATE data type now, too! You even put commas at the front of the punchcard, like 1960's FORTRAN. 
    Why are you doing dynamic SQL? That is how you tell the world that you have no idea what you are doing. With a flip of a switch, it becomes a procedure for automobiles, squids or Lady Gaga. Then you have a generic magic “id” that makes no sense. What does it
    identify? To be is to be something in particular (remember the Law of Identity from Logic 101?). Likewise, there is no generic status – marriage? Employment? Graduation? What? I will guess “user_id”, bu that would be awful. An identifier is a tag number and
    would never be an INTEGER. Why do you want to do math with it? Think about how silly “(CASE WHEN @in_user_id > 0 THEN full_name ELSE 0 END)” is; an integer changes to a string (yes, names are strings in data models)
    Why did you cast dates to strings? Why are there no aliases on the column names? Start using “<expression> AS <column name>” instead of 1970's Sybase “<column name> = <expression>”; your code will not port, or be readable to SQL programmers. 
    I have no idea what the proc name should be, but it is a verb and the object upon which it act in a valid data model. 
    CREATE PROCEDURE <verb>_<object>
    (@in_start_date DATE = NULL, @in_end_date DATE = NULL,
       @in_user_id INTEGER = -1)
    AS
    SELECT @in_user_id, ??.script_id, ??.full_name, ??.something_status
      FROM CCP_Customer_Retention_Log AS R,
           CCP_Users AS U
     WHERE R.user_id = U.user_id
       AND @in_user_id = U.user_id
       AND AND R.insertion_date BETWEEN @in_start_date AND @in_end_date;
    But this is still awful. Create a VIEW with this data set. Then do the reports on it. As separate procedures with high cohesion. Follow Netiquette and maybe we can help you. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Need help in restricting a result set from a UNION in MERGE

    Hello,
    Would really appreciate if anybody could help me out with the issue I am facing with the below statements (I am new to Oracle ):
    merge into table_name_1 p
    using
      select p_key, value_1, value_2
      from some_tables
      UNION
      select p_key, value_1, value_2
      from some_tables
      UNION
    )t
    on (p.p_key = t.p_key)
    when matched then
      update table_name_1 with value_1 and value_2
    when not matched then
      insert table_name_1 with p_key, value_1, value_2;
    Now, the union of all those selects gives me distinct values and it works most of the times but when I get values like below, the merge fails:
    p_key-----value_1-----value_2
    100-----25-----50
    100-----NULL-----50
    I browsed the net and understood the reason behind this: the result set becomes ambiguous and merge doesn't know which row to insert first and which one to update.
    Now, my requirement is: I could have any of the below scenario/result sets from the union and I need only 1 row per p_key -
    result_set_1
    p_key-----value_1-----value_2
    100-----25-----50 ***************need this row
    100-----NULL-----50
    100-----NULL-----NULL
    result_set_2
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row
    100-----NULL-----NULL
    result_set_3
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row (p_key = 100)
    100-----NULL-----NULL
    200-----NULL-----75 ***************need this row (p_key = 200)
    200-----NULL-----NULL
    300-----90-----95 ***************need this row (p_key = 300)
    So, I basically need a way to restrict the values that I will get from the UNION of all those selects to fit the requirement above, hope I was able to explain the issue I am facing.
    Any help would be greatly appreciated.
    Thanks,
    Dpunk

    In all cases the goal is to find an order by value that will make the row you want be first.
    The query I gave is calculating a priority for each row by adding up values showing whether each column is null or not null. The case statements check whether each column is null and need to be added up to give a total priority value.
    Value_1   Value_2   Priority
    Not Null  Not Null  2 + 1 = 3
    Not Null  Null      2 + 0 = 2
    Null      Not Null  0 + 1 = 1
    Null      Null      0 + 0 = 0
    The priority value ends up being a bitmap showing whether each value is null or not null. I think that reflects my mathematics background.
    Another way of getting the same result (suggested to me by your asking why it needs the "+") would be to use two CASE expressions as separate order by items:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is null then 0 else 1 end DESC,
                        case when value_2 is null then 0 else 1 end DESC
              ) as rn
      from (your UNION query here)
    where rn = 1
    A third way is to use a more complex case statement:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is NOT null and value_2 is NOT null then 1
                             when value_1 is NOT null and value_2 is     null then 2
                             when value_1 is     null and value_2 is NOT null then 3
                             when value_1 is     null and value_2 is     null then 4
                         end  ASC
              ) as rn
      from (your UNION query here)
    where rn = 1

  • How to export result set from mysql query browser to .sql in oracle

    Hi folks:
    I was trying to export result set from MySql query browser to Oracle. I could able to do
    File->Export Result Set-> Excel format...
    What I am trying to get is .sql file so that I can run it as a script in my oracle db. Is there any way we can get .sql file with inserts and delimeters ....?
    Did you guys get my question.?
    Please throw some light on this....
    Could be very appreciable ....
    Thanks
    Sudhir Naidu

    Hi
    Create a sql statement which generates the insert statements.
    Something like this:
    select 'insert into table1 (column1, column2, column3) values (' ||
    column1 || ', ' || column2 || ', ' || column3 || ');' from table 1;
    The || sign is the string concatenation sign in Oracle, replace it the appropriate sign in MySql. Export the result set of this query into a file, and you can run it in a SqlPlus.
    Ott Karesz
    http://www.trendo-kft.hu

  • How to get the result set in batches

    I have a query which results into large data. This data i want to display in a group of 20. After every 20 records i want to add header and footer to it.
    Is it possible to get the result set data into batch of 20 ? means can i specify start and end index of query ?
    regards
    Manisha

    What I am saying is that a big query with lots of
    joins will probably be slow, and as such would be a
    ripe candidate for batching the responses, if it were
    not possible to speed/optimize it. Batching is nice
    to look at for the user, but is not a solution for
    performance problems. In essence it is irrelevant
    that it adds a little performance deficit, as it
    appears to be running a lot quicker, and gives more
    feedback to the user.Then let me say it again....
    - "Join" is a term that applies to a method of doing queries in the database....
    - Query 1 which uses a join and returns 15 rows
    - Query 2 which does not use a join and returns 1500 rows.
    Given the above then Query 1 will provide better overall performance for the system than Query 2 in a properly configured database.
    If it doesn't then the database is not set up correctly.
    And again this will be irrespective of whether the query is scrollable or not.

  • Performance to fetch result set from stored procedure.

    I read some of related threads, but couldn't find any good suggestions about the performance issue to fetch the result set from a stored procedure.
    Here is my case:
    I have a stored procedure which will return 2,030,000 rows. When I run the select part only in the dbartisan, it takes about 3 minutes, so I know it's not query problem. But when I call the stored procedure in DBArtisan in following way:
    declare cr SYS_REFCURSOR;
    firstname char(20);
    lastname char(20);
    street char(40);
    city char(20);
    STATE varchar2(2);
    begin DISPLAY_ADDRESS(cr);
    DBMS_OUTPUT.ENABLE(null);
    LOOP
    FETCH cr INTO firstname,lastname,street, city, state;
    EXIT WHEN cr%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE( firstname||','|| lastname||','|| street||',' ||city||',' ||STATE);
    END LOOP;
    CLOSE cr;
    end;
    It will take about 100 minutes. When I used DBI fetchrow_array in perl code, it took about same amount of time. However, same stored procedure in sybase without using cursor, and same perl code, it only takes 12 minutes to display all results. We assume oracle has better performance. So what could be the problem here?
    The perl code:
    my $dbh = DBI->connect($databaseserver, $dbuser, $dbpassword,
    { 'AutoCommit' => 0,'RaiseError' => 1, 'PrintError' => 0 })
    or die "couldn't connect to database: " . DBI->errstr;
    open OUTPUTFILE, ">$temp_output_path";
    my $rc;
    my $sql="BEGIN DISPLAY_ADDRESS(:rc); END;";
    my $sth = $dbh->prepare($sql) or die "Couldn't prepare statement: " . $dbh->errstr;
    $sth->bind_param_inout(':rc', \$rc, 0, { ora_type=> ORA_RSET });
    $sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
    while($address_info=$rc->fetchrow_arrayref()){
    my ($firstname, $lastname, $street, $city, $STATE) = @$address_info;
    print OUTPUTFILE $firstname."|".$lastname."|".$street."|".$city."|".$STATE;
    $dbh->commit();
    $dbh->disconnect();
    close OUTPUTFILE;
    Thanks!
    rulin

    Thanks for you reply!
    1) The stored procedure has head
    CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
    cv_1 IN OUT SYS_REFCURSOR
    AS
    err_msg VARCHAR2(100);
    BEGIN
    --Adaptive Server has expanded all '*' elements in the following statement
    OPEN cv_1 FOR
    Select ...
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg := SQLERRM;
    dbms_output.put_line (err_msg);
    ROLLBACK;
    END;
    If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
    2) But when call stored procedure, it will take 80-100 minutes .
    3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
    CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
    AS
    BEGIN
    select ..
    The select part is exact same.
    4) The perl code is almost exact same, except the query sql:
    sybase verson: my $sql ="exec DISPLAY_ADDRESS";
    and no need bind the cursor parameter.
    This is batch job, we create a file with all information, and ftp to clients everynight.
    Thanks!
    Rulin

  • JDBC Result Set from Non-Database Source

    In Java, is it possible to create a result set from a non-database data source?, for example an XML file, text file, vectors, java beans
    We have a Swing application that currently makes direct JDBC calls to the DB2 database for creating result sets. We want to replace JDBC calls with calls to web service, but want to still create result sets on the client, so the replacement of the datasource from database to web service call is transparent to the rest of the code.

    In Java, is it possible to create a result set from a
    non-database data source?, Yes.
    for example an XML file,
    text file, vectors, java beans
    We have a Swing application that currently makes
    direct JDBC calls to the DB2 database for creating
    result sets. We want to replace JDBC calls with calls
    to web service, but want to still create result sets
    on the client, so the replacement of the datasource
    from database to web service call is transparent to
    the rest of the code.You might want to think carefully about what you are doing.
    It is fairly easy, although somewhat tedious (many methods,) to create a new type of ResultSet.
    But if the above application is doing SQL via statements and expecting the result via a ResultSet then you are not just creating a ResultSet but an entire driver and one that will have to deal with SQL as well. And if you have to handle the SQL itself that means you will probably need a parser and interpreter.

  • Virtual column in the result set of the query.

    Hi folks,
    I have table , let it be, EMP. It has columns ENAME,EMPNO,JOB etc.,
    My requirement is to add an extra column, not present in the table, having NULL value at the time of diplaying the results of a query. I hope you got it. So a column that does not exists in the table should get displayed in the resultant set when we query the results from that table. so my question is, how to write the SELECT statement using that virtual column.
    I'd thought of using X column in Dummy table but what if I don't have any dummy table in my particular schema.
    Please do revert back with the solution.
    Your effort'll be genuinely appreciated.
    Cheers
    PCZ

    Hi,
    If you just wany display null values you can write query like this :
    SELECT ENAME,EMPNO,JOB , NULL DUMMY_COLUMN FROM emp;
    Regrads
    Avinash

  • [Forum FAQ] How to configure a Data Driven Subscription which get multi-value parameters from one column of a database table?

    Introduction
    In SQL Server Reporting Services, we can define a mapping between the fields that are returned in the query to specific delivery options and to report parameters in a data-driven subscription.
    For a report with a parameter (such as YEAR) that allow multiple values, when creating a data-driven subscription, how can we pass a record like below to show correct data (data for year 2012, 2013 and 2014).
    EmailAddress                             Parameter                      
    Comment
    [email protected]              2012,2013,2014               NULL
    In this article, I will demonstrate how to configure a Data Driven Subscription which get multi-value parameters from one column of a database table
    Workaround
    Generally, if we pass the “Parameter” column to report directly in the step 5 when creating data-driven subscription.
    The value “2012,2013,2014” will be regarded as a single value, Reporting Services will use “2012,2013,2014” to filter data. However, there are no any records that YEAR filed equal to “2012,2013,2014”, and we will get an error when the subscription executed
    on the log. (C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles)
    Microsoft.ReportingServices.Diagnostics.Utilities.InvalidReportParameterException: Default value or value provided for the report parameter 'Name' is not a valid value.
    This means that there is no such a value on parameter’s available value list, this is an invalid parameter value. If we change the parameter records like below.
    EmailAddress                        Parameter             Comment
    [email protected]         2012                     NULL
    [email protected]         2013                     NULL
    [email protected]         2014                     NULL
    In this case, Reporting Services will generate 3 reports for one data-driven subscription. Each report for only one year which cannot fit the requirement obviously.
    Currently, there is no a solution to solve this issue. The workaround for it is that create two report, one is used for view report for end users, another one is used for create data-driven subscription.
    On the report that used create data-driven subscription, uncheck “Allow multiple values” option for the parameter, do not specify and available values and default values for this parameter. Then change the Filter
    From
    Expression:[ParameterName]
    Operator   :In
    Value         :[@ParameterName]
    To
    Expression:[ParameterName]
    Operator   :In
    Value         :Split(Parameters!ParameterName.Value,",")
    In this case, we can specify a value like "2012,2013,2014" from database to the data-driven subscription.
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    For every Auftrag, there are multiple Position entries.
    Rest of the blocks don't seems to have any relation.
    So you can check this code to see how internal table lt_str is built whose first 3 fields have data contained in Auftrag, and next 3 fields have Position data. The structure is flat, assuming that every Position record is related to preceding Auftrag.
    Try out this snippet.
    DATA lt_data TYPE TABLE OF string.
    DATA lv_data TYPE string.
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename = 'C:\temp\test.txt'
      CHANGING
        data_tab = lt_data
      EXCEPTIONS
        OTHERS   = 19.
    CHECK sy-subrc EQ 0.
    TYPES:
    BEGIN OF ty_str,
      a1 TYPE string,
      a2 TYPE string,
      a3 TYPE string,
      p1 TYPE string,
      p2 TYPE string,
      p3 TYPE string,
    END OF ty_str.
    DATA: lt_str TYPE TABLE OF ty_str,
          ls_str TYPE ty_str,
          lv_block TYPE string,
          lv_flag TYPE boolean.
    LOOP AT lt_data INTO lv_data.
      CASE lv_data.
        WHEN '[Version]' OR '[StdSatz]' OR '[Arbeitstag]' OR '[Pecunia]'
             OR '[Mita]' OR '[Kunde]' OR '[Auftrag]' OR '[Position]'.
          lv_block = lv_data.
          lv_flag = abap_false.
        WHEN OTHERS.
          lv_flag = abap_true.
      ENDCASE.
      CHECK lv_flag EQ abap_true.
      CASE lv_block.
        WHEN '[Auftrag]'.
          SPLIT lv_data AT ';' INTO ls_str-a1 ls_str-a2 ls_str-a3.
        WHEN '[Position]'.
          SPLIT lv_data AT ';' INTO ls_str-p1 ls_str-p2 ls_str-p3.
          APPEND ls_str TO lt_str.
      ENDCASE.
    ENDLOOP.

  • Which is more efficient way to get result set from database server

    Hi,
    I am working on a project where I require to query database to fetch result set and then iterate through the resultset. Now, What I want is that I want to create one single java code that would call many different SQLs and create a list out of resultset. There are two approaches for me.
    1.) To create a txt file where I can store my queries. My java program can read this file and get the appropriate query to be used.
    2.) To create a stored procedure containing the queries and call the stored procedure from my java program. Also, not that some of the queries needs to be created dynamically depending upon the parameteters supplied.
    Out of these two approches which is optimum and why?
    Also, following things to be noted.
    1. At times I want to create where clause of the query dynamically depenending upon the parameters passed.
    2. I want one single java file that will handle all database calls.
    3. Paramters to the stored procedure can be passed using array descriptor.
    4. Conneciton I am making using JNDI.
    Please do provide me optimum way of out these two. You may also suggest some other approaches, if any.
    Thanks,
    Rajan
    Edited by: RP on Jun 26, 2012 11:11 PM

    RP wrote:
    In case of queries stored in text files. I will require to replace some pre defined placeholder with actual parameters and then pass that modified query to db engine. Even I liked the second approach as it is more easily maintainable. There are a couple of issues. Shared SQL is one. Irrespective of the method used, the SQL cursor that is created needs to have bind variables. This ensures re-usability of the cursor. This reduces the risk of Shared Pool fragmentation. This lowers hard parsing and reduces CPU utilisation.
    Another issue is flexibility. If the SQL cursors are created by stored procedures, this code resides on the server and abstracts the Java client from the complexities of SQL and SQL performance. The code can easily be updated and fine tuned to deliver faster/better SQL cursors, or modified to take new Oracle features, changes in data model, and so on, into consideration. This stored proc can be updated without having to touch or recompile a single byte of Java client code.
    There's also the security issue. What is more secure? SQL encapsulated in stored procs in a secure database and server environment? Or SQL "encapsulated" in text files on the client?
    The less code you have running on the client, the less code you have running in the wild that can be compromised without having to first compromise the server.
    Only I was worried about any performace issue might happen using this approach. Performance is not a factor of who creates the SQL cursor.
    Whether Java client creates a SQL cursor, or a PL/SQL stored proc creates a SQL cursor, or a .Net client creates a SQL cursor - that SQL cursor does not know what the client is. It does not care what the client is. The SQL cursor performs as well as it is capable of.. given the execution plan, data volumes, server resources and speed/performance of the server.
    The client language and SQL cursor interface used by the client (there are several in PL/SQL), determines the performance of the client's interaction with the cursor (e.g. round trips to the database when interfacing with the cursor). The client language (and its client interface to the cursor) does not dictate the actual performance of that SQL cursor on the database (does not make joins faster, or I/O faster)
    One more question, Will my java program close the cursor that I opened in Procedure?That you need to ask your Java code. Java code leaking ref cursors are unfortunately all too common. You need to make sure that your Java client interface to SQL cursors, closes the cursor handle when done.

  • Getting result set from stored procedures in database controls in weblogic

    I am calling a stored procedure from database control which actually returns a result set
    when i call the stored procedure like
    * @jc:sql statement="call PROC4()"
    ResultSet sampleProc() throws SQLException;
    it gives me exception saying
    "weblogic.jws.control.ControlException: Method sampleProc is DML but does not return void or int"
    I would appreciate any help
    Thanks,
    Uma

    Thanks for you reply!
    1) The stored procedure has head
    CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
    cv_1 IN OUT SYS_REFCURSOR
    AS
    err_msg VARCHAR2(100);
    BEGIN
    --Adaptive Server has expanded all '*' elements in the following statement
    OPEN cv_1 FOR
    Select ...
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg := SQLERRM;
    dbms_output.put_line (err_msg);
    ROLLBACK;
    END;
    If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
    2) But when call stored procedure, it will take 80-100 minutes .
    3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
    CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
    AS
    BEGIN
    select ..
    The select part is exact same.
    4) The perl code is almost exact same, except the query sql:
    sybase verson: my $sql ="exec DISPLAY_ADDRESS";
    and no need bind the cursor parameter.
    This is batch job, we create a file with all information, and ftp to clients everynight.
    Thanks!
    Rulin

  • Problem of getting Result Set from Oracle 9iDB

    I have Oracle 9i DB installed on Win NT system. I created a SCHEMA called SCHATTOP and created a TABLE TEAM. From Oracle SQL*Plus screen, I signed on with userID "SCHATTOP", and my password "ANU1SAL". Then at SQL> Connect SCHATTOP/ANU1SAL .. Getting msg Connected. Then I am doing Select * from SCHATTOP.TEAM; It shows the contents of the table. But when I wrote a small program like this .. when I am calling the program I am getting this msg
    java DBLookup
    Connection Successful to Oracle DataBase .. !!!!
    SQLException caughtORA-00600: internal error code, arguments: [ttcgcshnd-1], [0], [], [], [], [], [], []
    $
    This is my program :
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DBLookup {
    public static void main(String[] args) throws Exception {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String url= "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=9.5.185.229)(PROTOCOL=tcp)(PORT=1521))(CONNECT_DATA=(SID=SAL400)))";
    con = DriverManager.getConnection(url,"SCHATTOP","ANU1SAL");
    System.out.println("Connection Successful to Oracle DataBase .. !!!!");
    stmt = con.createStatement( );
    rs = stmt.executeQuery("SELECT * FROM SCHATTOP.TEAM");
    while (rs.next()) {
    System.out.println(rs.getString("FN") + " " + rs.getString("LN"));
    catch (SQLException e) {
    System.out.println("SQLException caught" + e.getMessage( ));
    finally {
    try {
    if (con != null) con.close( );
    catch (SQLException ignored) { }
    Any help will be appreciated.

    Typically this error happens if a client tries to access a 9.0.1 database with an old 8.1.7 jdbc driver.
    This should be fixed in the jdbc driver of the 8.1.7.2.1 Patchset for Windows.
    Cheers
    Stefan

  • Can I retrieve a result set from Oracle and then incorporate that result set into my main SQL Server Stored Procedure?

    So I have a chunk of data that only resides in Oracle. So I need to capture that information from Oracle. Now before you get over zealous, I did try with an OPENQUERY and it took FOREVER! And I don't know why the OPENQUERY took FOREVER but if I run the same
    query directly against Oracle it runs very quickly...like 20 seconds.
    So now I'm wondering...can I build a dataset in my SSRS Report that uses an Oracle Data source and an Oracle Stored Procedure in its Dataset that I'll create to aggregate this subset of data and then utilize its result set back in my main reporting
    Dataset that will utilize SQL Server? And how can I do that? Can I make my main Dataset reference, say, a #TemporaryTable that is created from my Oracle Dataset in its
    I'll continue to Google a few things as I await your review and hopefully a reply.
    Thanks in advance for your help.

    Hi ITBobbyP,
    According to your description you want to use data from a Oracle data source into a DataSet which retrieving data from SQL Server. Right?
    In Reporting Services, we can have multiple data sources in one project pointing to different database. And we can use separated dataset to retrieve data from different data source. However, it's not supported to combine the two datasets together
    directly. We can only use Lookup(), LookupSet() function to combine fields from different dataset into one tablix when there are common columns between two datasets. This is the only way to make tow result sets together in SSRS.
    Reference:
    Lookup Function (Report Builder and SSRS)
    LookupSet Function (Report Builder and SSRS)
    Best Regards, 
    Simon Hou
    TechNet Community Support

Maybe you are looking for

  • How to move podcasts from iTunes to iPod...nano 2nd gen with iTunes 8.2.1,

    ...that don't have the little blue dot indicating that they've not been listened to? These podcasts aren't sync'ed to iPod bec iPod thinks that they have been listed to and they haven't. How to 'restore' these podcasts to their original 'unheard' sta

  • IP Blacklisting

    Dear Team, We are mail service providers. The client send the mails by using our IP. Client get delivery failure mails with following reason.  Failed Recipient: X  Reason: Remote host said: 550 5.7.1 Service unavailable; Client host   [180.179.114.23

  • Trouble creating a MobileMe Gallery with Aperture

    I'm having trouble creating a MobileMe Gallery from within Aperture. In the past it work flawlessly but now it isn't working at all. This is what happens: I create a gallery from within Aperture by clicking on either "New/MobileMe Album, or "New From

  • Report 6i Sorting

    Hi All, I have the following query and I need to SORT on ALPHANUMEIC field SEGMENT1 field, it works fine in TOAD but when I run it in Oracle REPORTS, it does not SORTING Done, I have four groups in my report. How to sort based on Segment1 which is in

  • Strange characters when receiving mail in mail.app

    Hi, I am having an issue with certain e-mails in mail.app cannot be read due to very strange charachers. I have already seen that problem with entourage and it's just the matter of deleting a font cache but here I cannot seem to get around it.. Any i