Sql (Select) result in string

Hi , I found this code in internet but it´s put a result in range on excel. 
I would like some code with end is some like  "MyVarString = objMySQLRecordsetResult"
For example: In my select result = "User01" , I would like put this value in a var string.
The code ends ...
        'ActiveSheet.Range("A1").CopyFromRecordset objMyRecordset
I want ...
Test01 = Recordset objMyRecordset
tks for your help !!
Public Sub GetDataFromADO()
    'Declare variables'
        Dim objMyConn As ADODB.Connection
        Dim objMyCmd As ADODB.Command
        Dim objMyRecordset As ADODB.Recordset
        Set objMyConn = New ADODB.Connection
        Set objMyCmd = New ADODB.Command
        Set objMyRecordset = New ADODB.Recordset
        Dim TESTE01 As String
    'Open Connection'
        objMyConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.15.0;Data Source="
& ActiveWorkbook.Path & "\Database.accdb" & "; Jet OLEDB:Database Password= `MY PASSWORD"
        objMyConn.Open
    'Set and Excecute SQL Command'
        Set objMyCmd.ActiveConnection = objMyConn
        objMyCmd.CommandText = "select DUSER from DUSER WHERE DUSER = 'USUR01 "
        objMyCmd.CommandType = adCmdText
   'Open Recordset'
        Set objMyRecordset.Source = objMyCmd
        objMyRecordset.Open
        objMyRecordset.OpenRecordset
    'Copy Data to Excel'
        'ActiveSheet.Range("A1").CopyFromRecordset objMyRecordset
End Sub

Try:
Public Sub GetDataFromADO()
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
'Open Connection'
Conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.15.0;Data Source=" & ActiveWorkbook.Path & "\Database.accdb" & "; Jet OLEDB:Database Password= `MY PASSWORD"
Conn.Open
'Open Recordset'
Rs.Open "select DUSER from DUSER WHERE DUSER = 'USUR01'", Conn, adOpenDynamic, adLockReadOnly
'Copy Data to Excel'
ActiveSheet.Range("A1").CopyFromRecordset Rs
Rs.Close
Conn.Close
End Sub
Rod Gill
Author of the one and only Project VBA Book
www.project-systems.co.nz

Similar Messages

  • Assign SQL select result to a java variable

    In a custom IKM, I need to check the LOGGING setting of target table, save the setting, then change the setting, then restore the setting.
    I am having problem saving the setting. I do something like the following, where tgtLogging is the current LOGGING setting of the target table. I need to save the value to sTgtLogging so that it can be accessed in a later step. I can't figure out the syntax. just saying sTgtLogging = tgtLogging does not work either in the pl/sql or the <% %> context.
    <%
    String sTgtLogging = "";
    %>
    declare
    tgtLogging varchar(5);
    begin
    select logging into tgtLogging from dba_tables where table_name='<%=odiRef.getPop("TABLE_NAME")%>';
    some other code.....
    end;
    Edited by: user611482 on Jul 8, 2010 3:34 PM

    Hi,
    we use this for saving the login time of the user. There are few therads about creating a custom login module (for example: [Custom Login Module - how to go on |http://forums.sdn.sap.com/thread.jspa?threadID=357616]).
    We have created a login module which extends AbstractLoginModule, in login() method :
    public boolean login() throws LoginException  {
    Object option = g_sharedState.get("javax.security.auth.login.name");
    if (option != null && !option.equals(""))  {
      String l_userID = (String)option;
      IUserAccount l_account = UMFactory.getUserAccountFactory().getUserAccountByLogonId(l_userID);
      IUserAccount mutableAccount = accountFactory.getMutableUserAccount(account.getUniqueID());     
      l_mutAccount.setLastSuccessfulLogonDate(new Date());
      l_mutAccount.commit();
    about login modules and login stacks start here: [http://help.sap.com/saphelp_nw04/helpdata/en/8c/f03541c6afd92be10000000a1550b0/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/8c/f03541c6afd92be10000000a1550b0/frameset.htm]
    Hope this helps,
    Romano

  • SQL SELECT result

    try {
    // Create a result set containing all data from my_table
        Statement s = connection.createStatement();
        ResultSet rs = s.executeQuery("SELECT * FROM station WHERE stationID = '" + stationID + "'");
    } catch (SQLException e) {
    }If there are no rows for that SQL statement, what will it return back to me? On my server, a client is sending a packet to me that contains the stationID. First, I want to make sure stationID already exists in the database. If it doesn't exist, I would like to run more SQL statements, but first I need to know what it will return to me.
    In guessing code, this is what I'm looking for: try {
    // Create a result set containing all data from my_table
        Statement s = connection.createStatement();
        ResultSet rs = s.executeQuery("SELECT * FROM station WHERE stationID = '" + stationID + "'");
        if (rs  == NULL) // if no rows were selected
            // if there were no rows selected from the original SELECT statement, INSERT a new row using this query
            ResultSet rs = s.executeQuery("INSERT INTO station VALUES ('stationID', 'address', 'city', 'state', zip'");
    } catch (SQLException e) {
    }Any help?
    Message was edited by:
    tristanlee85

    Why would you guess when you can just look at the API documentation? (Which specifically says the executeQuery() method never returns null.)
    If the SQL statement returns zero rows, you get a ResultSet that contains zero rows. Does that seem peculiar to you? In that case calling "rs.next()" returns false because there are zero rows.

  • Connect by - sql help : getting error ORA-01489: result of string concatena

    here is an sql query and I am trying to cook a decode but since there are many columns invloved when I am trying to run this I am getting the following error:
    ORA-01489: result of string concatenation is too long
    Any kind of help is appreciated, I need to get this going otherwise I am dead :(
    Regards
    Rahul
    SQL:
    select sys_connect_by_path(c.decode_prep,'-') decode_prep
    from (select 'DECODE(BIAPPS_11.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||','||'RAHULKALRA.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||',''1'',''0'')' decode_prep, rownum curr, rownum -1 prev
    from (select rownum rn
    from dual connect by rownum <=
    (select (length('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM')
    - length(replace('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM',',')))+1 total_cols
    from dual)) a, (select ','||'ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM'||',' all_cols from dual) b) c
    start with curr = 1
    connect by prior curr = prev
    order by length(sys_connect_by_path(c.decode_prep,'-')) desc
    same as above sql only difference is here I am pulling the first record from the result set which above query returns :
    select ltrim(replace(decode_prep,'-','||'),'||') decode_prep
    from (select sys_connect_by_path(c.decode_prep,'-') decode_prep
    from (select 'DECODE(BIAPPS_11.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||','||'RAHULKALRA.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||',''1'',''0'')' decode_prep, rownum curr, rownum -1 prev
    from (select rownum rn
    from dual connect by rownum <=
    (select (length('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM')
    - length(replace('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM',',')))+1 total_cols
    from dual)) a, (select ','||'ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM'||',' all_cols from dual) b) c
    start with curr = 1
    connect by prior curr = prev
    order by length(sys_connect_by_path(c.decode_prep,'-')) desc)
    where rownum = 1
    Edited by: Mac_Freak_Rahul on Nov 28, 2012 1:31 AM : in the first sql ')'
    removed after desc in the last line so now this query will run and throw an error.

    Clearly your error is because the string concatenation you are doing with sys_connect_by_path is exceeding the 4000 bytes permitted by SQL.
    In that case you need to concatenate your data into a CLOB datatype, for which you'll need a CLOB aggregation function...
    create or replace type clobagg_type as object
      text clob,
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number,
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number,
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number,
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number
    create or replace type body clobagg_type is
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number is
      begin
        sctx := clobagg_type(null) ;
        return ODCIConst.Success ;
      end;
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number is
      begin
        self.text := self.text || value ;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number is
      begin
        returnValue := self.text;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number is
      begin
        self.text := self.text || ctx2.text;
        return ODCIConst.Success;
      end;
    end;
    create or replace function clobagg(input clob) return clob
      deterministic
      parallel_enable
      aggregate using clobagg_type;
    SQL> select trim(',' from clobagg(ename||',')) as enames from emp;
    ENAMES
    SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'PFL' c1, 0 c2,110 c3 from dual union all
      3     select 'LHL', 0 ,111 from dual union all
      4     select 'PHL', 1, 111 from dual union all
      5     select 'CHL', 2, 111 from dual union all
      6     select 'DHL', 0, 112 from dual union all
      7     select 'VHL', 1, 112 from dual union all
      8     select 'CPHL', 0, 114 from dual union all
      9     select 'WDCL', 1, 114 from dual union all
    10     select 'AHL' ,2 ,114 from dual union all
    11     select 'NFDL', 3, 114 from dual)
    12  --
    13  -- end of test data
    14  --
    15  select trim(clobagg(c1||' ')) as c1, c3
    16  from (select * from t order by c3, c2)
    17  group by c3
    18* order by c3
    SQL> /
    C1                                     C3
    PFL                                   110
    LHL CHL PHL                           111
    DHL VHL                               112
    CPHL AHL NFDL WDCL                    114

  • Colorize report results depending on sql selects

    Hy,
    is it possible to colorize report results depending on sql selects.
    For example: select id, name from db where name = 'frankfurt' or name = 'munic'
    All Results munic in red colour.
    Thanks
    Tom

    Hi,
    I have tried using the following in a decode statement of a Region report (type is SQL Query), and all it seems to do is form the HTML text as expected, but does not actually do what I want (i.e. display the field as red):-
    SELECT a_code, a_status, decode(a_fld,a_fld,'&ltfont color=&quotFF0000&quot&gt'||a_fld||'&lt/font&gt','other') "CA" from a_table
    What appears in the report is literally (I've put in single quotes in case this line is interpretted in the forum):
    '<font color="FF0000">1234</font>'
    I'm missing something - to force the HTML to be rendered as such. The field is displayed as a Standard Report Column, but it's just taking the decode search field as an ordinary piece of text. There's something that needs setting, but I can't find it - does anyone know?
    Thanks in advance
    Dave

  • SQL Query results to CSV as two worksheets

    I'm trying to take two SQL queries and get the results sent to a CSV file on two worksheets.  Looking online I have not found a solid example of using the Excel ComObject to create a CSV then add a new worksheet to the CSV file.  An added bonus
    would be using AutoFit on the columns so everything is easily visible.
    Code found online got me the following script which does work, however it takes 12 minutes to pipe the SQL queries to Excel.  Switching to a CSV and the script executes in 5 seconds.
    This is another nice to have, I was also looking the best way to look at the results (only 1 column) and depending on the length of the data, insert what Excel would call a Cell thereby shifting cells RIGHT but so far have found no clear examples of how
    to accomplish that.  My guess would be modifying my SQL queries but I've posted a question on StackOverFlow and someone suggested modifying the PowerShell Table created from the SQL dataset.Tables
    Code:
    $docs = "C:\Scripts\Output.xlsx"
    If (Test-Path $docs){Remove-Item $docs}
    Function Run-Query {
    param([string[]]$queries,[string[]]$sheetnames)
    ## - Create an Excel Application instance:
    $xlsObj = New-Object -ComObject Excel.Application
    $xlsObj.DisplayAlerts = $false
    $xlsWb = $xlsobj.Workbooks.Add(1)
    ## - Create new Workbook and Sheet (Visible = 1 / 0 not visible)
    $xlsObj.Visible = 0
    $time = 2
    for ($i = 0; $i -lt $queries.Count; $i++){
    $percentage = $i / $time
    $remaining = New-TimeSpan -Seconds ($time - $i)
    $message = "{0:p0} complete" -f $percentage, $remaining
    Write-Progress -Activity "Creating Daily Reboot Spreadsheet" -status $message -PercentComplete ($percentage * 100)
    $query = $queries[$i]
    $sheetname = $sheetnames[$i]
    $xlsSh = $xlsWb.Worksheets.Add([System.Reflection.Missing]::Value, $xlsWb.Worksheets.Item($xlsWb.Worksheets.Count))
    $xlsSh.Name = $sheetname
    ### SQL query results sent to Excel
    $SQLServer = 'ServerName'
    $Database = 'DataBase'
    ## - Connect to SQL Server using non-SMO class 'System.Data':
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $Database; Integrated Security = True"
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $query
    $SqlCmd.Connection = $SqlConnection
    ## - Extract and build the SQL data object '$Table2':
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $SqlConnection.Close()
    $Table1 = $DataSet.Tables["Table"]
    ## - Build the Excel column heading:
    [Array] $getColumnNames = $Table1.Columns | SELECT ColumnName
    ## - Build column header:
    [Int] $RowHeader = 1
    foreach ($ColH in $getColumnNames)
    $xlsSh.Cells.item(1, $RowHeader).font.bold = $true
    $xlsSh.Cells.item(1, $RowHeader) = $ColH.ColumnName
    $RowHeader++
    ## - Adding the data start in row 2 column 1:
    [Int] $rowData = 2
    [Int] $colData = 1
    foreach ($rec in $Table1.Rows)
    foreach ($Coln in $getColumnNames)
    ## - Next line convert cell to be text only:
    $xlsSh.Cells.NumberFormat = "@"
    ## - Populating columns:
    $xlsSh.Cells.Item($rowData, $colData) = $rec.$($Coln.ColumnName).ToString()
    $ColData++
    $rowData++; $ColData = 1
    ## - Adjusting columns in the Excel sheet:
    $xlsRng = $xlsSH.usedRange
    [void] $xlsRng.EntireColumn.AutoFit()
    }#End For loop.
    #Delete unwanted Sheet1.
    $xlsWb.Sheets.Item('Sheet1').Delete()
    #Set Monday to Active Sheet upon opening Workbook.
    $xlsWb.Sheets.Item('Cert').Activate()
    ## ---------- Saving file and Terminating Excel Application ---------- ##
    $xlsFile = "C:\Scripts\Output.xlsx"
    [void] $xlsObj.ActiveWorkbook.SaveAs($xlsFile)
    $xlsObj.Quit()
    ## - End of Script - ##
    start-sleep 2
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsRng)) {'cleanup xlsRng'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsSh)) {'cleanup xlsSh'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsWb)) {'cleanup xlsWb'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsObj)) {'cleanup xlsObj'}
    [gc]::collect() | Out-Null
    [gc]::WaitForPendingFinalizers() | Out-Null
    }#End Function
    $queries = @()
    $queries += "Query1"
    $queries += "Query2"
    $sheetnames = @('Cert','Prod')
    Run-Query -queries $queries -sheetnames $sheetnames

    Here's what I ended up with that accomplishes my goal.  I learned it's not possible to create a CSV with two worksheets since Excel will allow this but the CSV cannot be saved with the second worksheet.  Instead, I create two CSV files then merge
    them into one Excel workbook, one CSV per worksheet.  In my case, this happens in 5 seconds.  There is one thing which must be mentioned, I've seen this script fail the first time it is run but will successfully run the second time.
    Also note, after much trial and error, this code correctly cleans up the Excel ComObject!!  -Thanks go to JRV.
    $docs = "D:\Scripts\MonthlyReboots.xlsx"
    IF (Test-Path $docs){Remove-Item $docs}
    $csv1 = "D:\Scripts\Cert.csv"
    IF (Test-Path $csv1){Remove-Item $csv1}
    $csv2 = "D:\Scripts\Prod.csv"
    IF (Test-Path $csv2){Remove-Item $csv2}
    Function Run-Query {
    param([string[]]$queries,[string[]]$sheetnames,[string[]]$filenames)
    Begin{
    $SQLServer = 'ServerName'
    $Database = 'DataBase'
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server = $SQLServer; Database = $Database; Integrated Security = True"
    $Excel = New-Object -ComObject Excel.Application
    $Excel.Visible = 0
    $dest = $Excel.Workbooks.Add(1)
    }#End Begin
    Process{
    For($i = 0; $i -lt $queries.Count; $i++){
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = $queries[$i]
    $SqlCmd.Connection = $SqlConnection
    $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
    $SqlAdapter.SelectCommand = $SqlCmd
    $DataSet = New-Object System.Data.DataSet
    $SqlAdapter.Fill($DataSet)
    $DataSet.Tables[0] | Export-Csv -NoTypeInformation -Path "D:\Scripts\$($sheetnames[$i]).csv" -Force
    }#end for loop.
    }#End Process
    End{
    $SqlConnection.Close()
    #Excel magic test!
    For($i = 0; $i -lt $queries.Count; $i++){
    $loopy = (Resolve-Path -Path $filenames[$i]).ProviderPath
    $Book = $Excel.Workbooks.Open($loopy)
    $next = $Excel.workbooks.Open($loopy)
    $next.ActiveSheet.Move($dest.ActiveSheet)
    $xlsRng = $dest.ActiveSheet.UsedRange
    $xlsRng.EntireColumn.AutoFit() | Out-Null
    $dest.sheets.item('Sheet1').Delete()
    $xlsFile = "D:\Scripts\MonthlyReboots.xlsx"
    [void] $Excel.ActiveWorkbook.SaveAs($xlsFile)
    $Excel.Quit()
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xlsRng)) {'cleanup xlsRng'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($next)) {'cleanup xlsSh'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($Book)) {'cleanup xlsWb'}
    While ([System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)) {'cleanup xlsObj'}
    [gc]::collect() | Out-Null
    [gc]::WaitForPendingFinalizers() | Out-Null
    }#End end block.
    }#End function run-query.
    $queries = @()
    $queries += @'
    Select * from table1
    $queries += @'
    Select * from table2
    $sheetnames = @("Cert","Prod")
    $filenames = @("D:\Scripts\Prod.csv","D:\Scripts\Cert.csv")
    Run-Query -queries $queries -sheetnames $sheetnames -filenames $filenames
    Start-Sleep -Milliseconds 50
    Invoke-Item D:\Scripts\MonthlyReboots.xlsx

  • Display results as String: dosen't work based on the example

    Hello,
    To understand how to display results as string, I tried to reproduce this:
    [http://apex.oracle.com/pls/otn/f?p=31517:84|http://apex.oracle.com/pls/otn/f?p=31517:84]
    I have my table emp
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7839  KING PRESIDENT -  81-11-17 5000 -  10
    7698 BLAKE MANAGER 7839 81-05-01 2850 -  30
    7782 CLARK MANAGER 7839 81-06-09 2450 -  10
    7566 JONES MANAGER 7839 81-04-02 2975 -  20
    7788 SCOTT ANALYST 7566 82-12-09 3000 -  20
    7902 FORD ANALYST 7566 81-12-03 3000 -  20
    7369 SMITH CLERK 7902 80-12-17 800 -  20
    7499 ALLEN SALESMAN 7698 81-02-20 1600 300 30
    7521 WARD SALESMAN 7698 81-02-22 1250 500 30
    7654 MARTIN SALESMAN 7698 81-09-28 1250 1400 30
    7844 TURNER SALESMAN 7698 81-09-08 1500 0 30
    7876 ADAMS CLERK 7788 83-01-12 1100 -  20
    7900 JAMES CLERK 7698 81-12-03 950 -  30
    7934 MILLER CLERK 7782 82-01-23 1300 -  10 I created with the wizard, on my page, a new REPORT REGION
    - selected SQL RESULT -
    - Name: Test
    - Region Source Type: SQL Query
    - Region Template: Report Region
    IN Enter SQL Query or PL/SQL function returning a SQL Query, I COPY-PASTE the following code from [http://apex.oracle.com/pls/otn/f?p=31517:84|http://apex.oracle.com/pls/otn/f?p=31517:84]
    DECLARE
       p_vc_arr2   htmldb_application_global.vc_arr2;
       p_string    VARCHAR2 (2000);
    BEGIN
       SELECT ename
       BULK COLLECT INTO p_vc_arr2
         FROM emp
        WHERE deptno = :p84_select_deptno;
       p_string :=
         HTMLDB_UTIL.table_to_string (p_vc_arr2, ':');
       HTP.p (p_string);
    END;AND I have this error:
    +1 error has occurred+
    Invalid query, no select statement found
    Is not a PL/SQP functiion??
    What do I do wrong?
    thanks,
    Roseline Paquin
    Montreal, Canada

    1 error has occurred
    Invalid query, no select statement foundWhat if you try
    DECLARE
       p_vc_arr2   htmldb_application_global.vc_arr2;
       p_string    VARCHAR2 (2000);
    BEGIN
       SELECT ename
       BULK COLLECT INTO p_vc_arr2
         FROM emp
        WHERE deptno = :p84_select_deptno;
        return 'select ''' ||  HTMLDB_UTIL.table_to_string (p_vc_arr2, ':') || ''' str from dual';
    END;??

  • SQL 'SELECT' statement

    I use LV7.1.1 to read/update an Access Database, using DB Toolset.
    When I use the Sql 'SELECT' query with LIKE operator, I do not get any results. (no error is returned).
    The statement is:
    SELECT Machine, System, AD, Query_Position, RefDesignator, Description
    FROM AllLevel
    WHERE ((Machine LIKE '*')  AND (System  LIKE '*')  AND (AD ='2000CV20012') AND (Query_Position ='AD') AND (RefDesignator='u1'))
    It seems that the LIKE '*' is not translated well by the 'Microsoft Jet 4.0 OLE DB Provider'. I must mention that the statement works just fine under Access, not using LV.
    Is there any alternative format for LIKE '*' that do the job?
    Regards,
    Joseph Moshe

    Maybe Access has different syntax, but for T-SQL, the proper syntax for LIKE is to use the % character to match any string of zero or more characters and the _ character to match a single characer. In fact, the documentation says that while * and ? are understood,
    "The % and _ (underscore) wildcard characters should be used only
    through the Jet OLE DB provider and ActiveX® Data Objects (ADO) code.
    They will be treated as literal characters if they are used though the
    Access SQL View user interface or Data Access Objects (DAO) code."

  • Ora-01489: result of string concatenation is too long

    Hello Gurus,
    i have a typical problem
    i am constructing a query in FORM and writing SQLPLUS script into a .SQL file. file will contain final data like below..
    set linesize 90
    set pagesize 0
    set echo off
    set verify off
    set termout off
    set feedback off
    set trimspool on
    set escape '^'
    spool D:\10GAPPServerappln\xxx\TEMPREP\ADA39057.sql;
    set linesize 229
    select ' IQIS# ,Cust Complaint Short Txt ,CD Short Txt ' from dual;
    set linesize 129
    select a||','||b||','||c||d from table;
    spool off;
    exit;
    After this By using HOST command i will execute the above .sql script and will write the output to text file.
    But problem is when i have clob column in any one of concatenated columns in query (a or b or c) then i am getting the error "Ora-01489: result of string concatenation is too long".
    pls suggest me how to overcome this problem..

    sybrand_b wrote:
    Obviously the || operator is concatenating strings, your CLOB is implicitly converted to a VARCHAR2, which has a 4000 bytes limit.???
    From non-experts who did read documentation:
    CLOB || VARCHAR2 = CLOB:
    SQL> CREATE OR REPLACE
      2  VIEW V1
      3  AS SELECT TO_CLOB('A') || 'A' clob_concat_varchar2 FROM dual
      4  /
    View created.
    SQL> DESC V1
    Name                                      Null?    Type
    CLOB_CONCAT_VARCHAR2                               CLOB
    SQL> SY.

  • Why sql select 'Hello'||'world012345678' from dual; cause error?

    I have problem and your help to solve it would be very much appreciated.
    Can anybody tell why the result is so different for the following two sql-sentence in SQL/PLus?
    sql>select 'Hello'||'world012345678' from dual;
    sql>select 'Hello'||'world0123456789' from dual;
    sql>select 'Hello'||'world012345678' from dual;
    Result:
    select 'Hello'||'world012345678' from dual
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [17182], [158346180], [], [], [],
    sql>select 'Hello'||'world0123456789' from dual;
    Helloworld0123456789
    I found that if the length of one string equals 14, then the sql will failed as the first sentence.

    If you need to check the validity of DUAL then you have:
    Select count(1) from DUAL ;
    NOT
    Select * from DUAL;
    If you find more than 1, then
    delete from dual;
    insert into dual values ('x') ;
    commit;
    Then, try you offending query.

  • XSU error oracle.xml.sql.OracleXMLSQLException: Conversion to String failed

    Appication Server: 10g, Database: Oracle 9i and Oracle 10g
    I have a table 'sw_icd2' in the database that has one column of XMLType.
    The code below, attempts to query this table as 'select * from sw_icd2' and display the result. I was able to execute this query in sqlplus.
    But when I run a program using XSU in JDeveloper:
    OracleXMLQuery qry = new OracleXMLQuery(conn, "select * from sw_icd2");
    XMLDocument domDoc = (XMLDocument)qry.getXMLDOM();
    domDoc.print(System.out);
    StringWriter s = new StringWriter(10000);
    domDoc.print(new PrintWriter(s));
    System.out.println(s.toString());
    qry.close();
    I get the following Error:
    "oracle.xml.sql.OracleXMLSQLException: Conversion to String failed"
    Any ideas on how I can resolve this issue? Your help would be appreciated.
    Thanks!

    Okay, it looks like the problem has something to do with the TIMESTAMP data type in tables.
    oracle.xml.sql.query.OracleXMLQuery can't seem to handle tables with the TIMESTAMP data type.
    this code ran fine on my machine :
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.query.OracleXMLQuery;
    import java.lang.*;
    import java.sql.*;
    public class testXMLSQL {
         public static void main(String[] args) {
    try {
    // Create the connection
    System.out.println("before getConnection ");
    Connection conn = getConnection("scott","tiger");
    System.out.println("after getConnection ");
    // Create the query class
    OracleXMLQuery qry = new OracleXMLQuery(conn, "SELECT * FROM EMP");
    System.out.println("after OracleXMLQuery object created ");
    // Get the XML string
    String str = qry.getXMLString();
    // Print the XML output
    System.out.println("The XML output is:\n"+str);
    // Always close the query to get rid of any resources..
    qry.close();
    } catch(SQLException e) {
    System.out.println(e.toString());
    // Get the connection given the user name and password.!
    private static Connection getConnection(String username,
    String password)
    throws SQLException
    // register the JDBC driver..
    DriverManager.registerDriver(new
    oracle.jdbc.driver.OracleDriver());
    // Create the connection using the OCI8 driver
    Connection conn =
    DriverManager.getConnection(
    "jdbc:oracle:thin:@<server_name>:1521:<sid>",
    username,password);
    return conn;
    Then I created another table :
    create table emp_test as select * from emp;
    added a timestamp to it :
    alter table emp_test add (time timestamp(6));
    and filled it with timestamp information :
    update emp_test set time = timestamp'2005-09-22 09:26:50.124';
    ran the same code but changed the SQL to :
    "SELECT * FROM EMP_TEST"
    and got the error message :
    The XML output is:
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Conversion to String failed</ERROR>
    looks like bug in OracleXMLQuery object??

  • How to send SQL query results to XML ?

    Hey Guys, I am querying a DB with huge amount of traffic. A user select a particular lot and then details of the lot will be displayed in the following page. My concern here is that it takes really LONG to retrieve back the results coz it has to requiry in the following JSP page.
    I was told to use XML to retrieve the dataset and store it. Hence, in the following query it will re-query only from the recordsets in the XML file (...Logically, should be faster rite ? ). Hence, how do parse my recordsets retrieved from the SQL query to an XML file ?
    Any sort of suggestion , help, reference would be deeply appreciated ..Thanks !

    <HTML>
    <BODY>
    <H1>Manufacturing Summary beta </H1><BR>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.text.*" %>
    <jsp:include page="/index.html" flush="true"/>
    <P><B>Returned result<B><BR>
    <B>Query String :</B><%=request.getParameter("date") %>
    <TABLE BORDER=1 cellpadding=0 cellspacing=0>
    <%!
    static double roundDouble(double toBeRounded, int fractionDigits)
    NumberFormat format = NumberFormat.getInstance();
    format.setMaximumFractionDigits(fractionDigits);
    String tempDouble = format.format(toBeRounded);
    return Double.parseDouble(tempDouble);
    %>
    <%
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@klmomnidb:1521:
    OMNIDB","omni","omni");
    Statement stmt = null;
    ResultSet rset = null;
    String S_date = new String();
    String temp = new String();
    String lot_id = new String();
    String result = new String();
    String SQL_String = new String();
    double yield;
    int bad_cnt;
    S_date = request.getParameter("date");
    lot_id = request.getParameter("lot_id");
    temp = request.getParameter("TST_TEMP");
    SQL_String = "SELECT LOT_ID, FLOW_ID, TST_TEMP, MODE_COD, RTST_COD, PART_CNT, GO
    OD_CNT, OPER_NAM, JOB_REV, PROC_ID, START_T, FACIL_ID, TSTR_TYP, NODE_NAM FROM L
    OT where START_T > TO_DATE('"+ S_date + "','MM/DD/YYYY') AND TST_TEMP <='" + tem
    p+"' order by START_T";
    out.println(SQL_String);
    stmt = conn.createStatement();
    rset = stmt.executeQuery (SQL_String);
    out.println("<TR>");
    out.println("<TD> Select Lot(s)</TD>");
    out.println("<TD>Flow </TD>");
    out.println("<TD>Temp </TD>");
    out.println("<TD>Test Mode </TD>");
    out.println("<TD>Retest</TD>");
    out.println("<TD>Total </TD>");
    out.println("<TD>Good</TD>");
    out.println("<TD>Bad</TD>");
    out.println("<TD>Yield </TD>");
    out.println("<TD>UserID</TD>");
    out.println("<TD>Program</TD>");
    out.println("<TD>Mask</TD>");
    out.println("<TD>Start Time </TD>");
    out.println("<TD>Loc </TD>");
    out.println("<TD>Tester</TD>");
    out.println("<TD>System </TD>");
    out.println("</TR>");
    if (! rset.next()) {
    result ="No records found matching seach criteria.";
    while (rset.next()) {
    bad_cnt = Integer.parseInt(rset.getString(6)) - Integer.parseInt(rset.getString(
    7));
    yield = (Double.parseDouble(rset.getString(7)) / Double.parseDouble(rset.getStri
    ng(6))) * 100;
    result= "<TR>";
    result = result + "<TD><a href=coolpage.jsp?LOT_ID=" + rset.getString(1)+ ">" +
    rset.getString(1) + "</A></TD>";
    result = result + "<TD>" + rset.getString(2) + "</TD>";
    result = result + "<TD>" + rset.getString(3) + "</TD>";
    result = result + "<TD>" + rset.getString(4) + "</TD>";
    result = result + "<TD>" + rset.getString(5) + "</TD>";
    result = result + "<TD>" + rset.getString(6) + "</TD>";
    result = result + "<TD>" + rset.getString(7) + "</TD>";
    result = result + "<TD>" + bad_cnt + "</TD>";
    result = result + "<TD>" + roundDouble(yield,2) + "% </TD>";
    result = result + "<TD>" + rset.getString(8) + "</TD>";
    result = result + "<TD>" + rset.getString(9) + "</TD>";
    result = result + "<TD>" + rset.getString(10) + "</TD>";
    result = result + "<TD>" + rset.getString(11) + "</TD>";
    result = result + "<TD>" + rset.getString(12) + "</TD>";
    result = result + "<TD>" + rset.getString(13) + "</TD>";
    result = result + "<TD>" + rset.getString(14) + "</TD>";
    result = result + "</TR>"; %>
    <%=result%>
    <% }
    rset.close();
    stmt.close();
    conn.close();
    %>
    <%=result%>
    </TABLE>
    </BODY>
    </HTML>

  • SQL Exception: Result Set Closed. Help Needed Pls...

    Hi
    I am trying to insert the name field into �TestNoName� table which is randomly retrieved from �UniqueName� table. I am getting SQL exception: result set closed. Please look at the given code and let me know what�s wrong with my code:
    Also please guide me about entering unique (serial numbers) dynamically into
    database using Java. I have to enter customer details into database at some time and some customers details after some time but the customers should be given serial numbers.
    Thank you in advance!
    Ravi
    Here is the Code:
    String query1 = "Select Name from Unique_Names";
    String query2 = "SELECT Number, Name FROM TestNoName";
    Statement stmt;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,"","");
    System.out.println("Successfully Connected to Database");
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery(query1);
    ResultSet rs2 = stmt.executeQuery(query2);
    int count=0;
    while (rs.next()) {
    count++;
    rs.beforeFirst();
    for(int i = 0; i < 10; i++) {
    int randomrow = random.nextInt(count)+ 1;
    System.out.println(randomrow);
    String Name2 = rs.getString("Name");
    rs2.moveToInsertRow();
    rs2.updateInt("Number",i);
    rs2.updateString("Name",Name2);
    rs2.insertRow();
    System.out.println("Exececuted SQL Statement- Inserted One Record");
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

    I am trying to insert the name field into
    �TestNoName� table which is randomly retrieved from
    �UniqueName� table. I am getting SQL exception:
    result set closed. Please look at the given code and
    let me know what�s wrong with my code: Post the actual exception, not some paraphrase of it. Oh, and let us know which line it actually refers to in the code.

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

  • How many columns a sql selects

    I need to find out how many columns are in a sql statement like below:
    sql = "select id, decode(description,'','No decription', description), comment from my_table";
    The sql string is build dynamically so I don't know it when I write the code. I need to know before I do
    call rs.next(), because I need to set up the table header so I need to know how many columns the sql is selecting.
    Thanks inadvance.
    Botao

    You can use the interface ResultSetMetaData,below are some methods of it.
    int getColumnCount()
    Returns the number of columns in this ResultSet object.
    String getColumnName(int column)
    Get the designated column's name.
    int getColumnType(int column)
    Retrieves the designated column's SQL type.
    for more infomation ,you can refer to JDBC Online Document.

Maybe you are looking for

  • How to get multiple rows at one time in a table?

    hi I have a JTable bound with ViewObject and i use multiple selection mode setting to get selection row. My question is when i select more then one row at one time i only can get those index from JTable but can't get those rows from ViewObject.is it

  • Time contol of filterwhel​l fw102 of thorlabs with labview

    hi, I'm looking for someboby having experiences with the filterwheel fw102 of thorlabs (or something close). I just startet with labview. I want to create a sequense for the filterwheel, so that the weel changes position after a definded time and all

  • IPhoto "metadata changes" and management with possible import to Aperture 2

    Sorry for the length of this but I am trying to get to figure out which will be the best product for me without having to waste more time and money. I may already have the best for what I want/need but I am not too terribly satisfied with it in its c

  • Camcorder & firewire issues

    Hi have a new Mac Pro and I could IMOVIE HD could not see my camcorder untill I unplugged my 2 firewire drives. Are there any hints to why and how I can fix this?

  • CSS Citrix CAG Load Balancing

    Hi, I'm looking to get an opinion as to whether we should see even load balancing over two services.  The content rule is configured as follows :- content secure_cag   add service citrix_cag_1   port 443   protocol tcp   vip address 10.80.2.150   bal