Problem to store a oracle sql result into a variable

Hello everyone,
I'm working on a little project that use c#, Oracle ODT and asp.net, so here is the thing, I need to save the result of a sequence (SECNUM.NEXTVAL ) into a variable, then call that value from many inserts and querys and for last make the commit. My problem is that I don't know how to convert the string result to a number and the call it from the statements. Always brings two errors, one is invalid number because Im sending a string and the another is that if I comment the line cmd.ExecuteNonQuery(); the script runs but no commit happens.
This is my code, is attached to a button:
C# Syntax (Toggle Plain Text)
string oradb = "Data Source=BBDD;User Id=DEMO;Password=DEMO;";
string cmd1 = "SELECT SECNUM.NEXTVAL FROM DUAL";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleParameter parm = new OracleParameter();
parm.OracleDbType = OracleDbType.Decimal;
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.Parameters.Add(parm);
cmd.CommandText = "INSERT INTO DEMOINCI (CODINCI, CODCLI) VALUES (('" + cmd1 +"'), 'TEST')";
cmd.CommandText = "INSERT INTO DEMOINCILIN (CODINCI,CODLIN) VALUES (('" + cmd1 +"'),1)";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
So my problem is that the column CODINCI is a column number of (9) and not a VARCHAR and can not be changed because is already have data, so when I use the code of the example, Oracle return an error saying Invalid number (of course).
With the help of a friend I tried to put with the cast like this cmd.CommandText = "INSERT INTO DEMOINCI (CODINCI, CODCLI) VALUES (" + "CAST(" + cmd1 + "AS NUMBER), 'TEST')"; and it works but only if I comment the line cmd.ExecuteNonQuery();, so the commit never happend and of course there is no insert in the database.
¿It is so difficult to store a result of an SQL into a variable and then call it back on a statement?, on Oracle Forms you create a cursor like cursor=CVAL SELECT SECNUM.NEXTVAL VAL FROM DUAL and that it you can then use the VAL result into all other queries of the same form an retrieving with the :VAL option.
Thanks for all the help.

I just had to do something similar for my C# class, using SQL Server. The primary key for a "Customers" table was an auto-incrementing integer. After inserting a new customer I had to retrieve and display the primary key:
string selectStatement = "SELECT IDENT_CURRENT('Customers') from Customers";
SqlCommand selectCommand = new SqlCommand(selectStatement, connection);
int customerID = Convert.ToInt32(selectCommand,ExecuteScalar());
The ExecuteScalar() method of selectCommand returned the first column of the first row of the dataset, which in this case was the key of the new Customers record, as an object. Convert.ToInt32() converted the key to an integer.
Once you store SECNUM.NEXTVAL as an integer, you can use it to create a Parameter for the Command object.
HTH.

Similar Messages

  • Copying SQL Script from Oracle SQL Developer into Excel with formatting

    I need to copy a SQL Script into Excel in order to develop some VBA code. Is there any nice way that I can copy SQL Script from Oracle SQL Developer into Excel and retain its formatting? I am a stickler for having legible, readable SQL and like to have all my columns lined up and aliases lined up. When we used to use SQL Navigator, the tab formatting seemed to copy and paste just fine. Now that we have migrated to Oracle SQL Developer, the formatting seems to get all messed up.
    And suggestions are greatly appreciated and Thanks in advance for your review and am hopeful for an answer.
    Thanks.
    PSULionRP

    I suppose you want a real tabulator instead of spaces. You can configure this in the preferences (SQL Formatter - Oracle). You have to apply it then to your existing code (e.g. CTRL-F7), but new code should get it right from the start.
    Hope that helps,
    K.

  • Mapping proc output to vars gets error extracting result into a variable of type (DBTYPE_UI2)

    Hi, we run std 2012.  I have a proc (sets nocount on) whose params r shown in the first block .   My execute ssis sql task mapping is shown in the block following that (same order as shown, the param sizes are all -1).  The variable
    characteristics and initial values are shown in the 3rd block.  The execute sql task command is
    exec usp_fileArrivalStatus ?,?,?,?,?,? output,? output,? output
    when I run the proc in ssms followed by a select on the output fields, I get stat 0, instance id -1 and file name empty string (aka tick tick aka '')
    The error is:
    [Execute SQL Task] Error: Executing the query "exec usp_fileArrivalStatus ?,?,?,?,?,? output,? ou..." failed with the following error:
    "An error occurred while extracting the result into a variable of type (DBTYPE_UI2)".
    Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Does anybody know what is wrong?
    CREATE PROCEDURE [dbo].[usp_fileArrivalStatus] @NewFilePattern varchar(500),
    @PkgName varchar (257),
    @appid int,
    @MsgHistCreateDate date,
    @messageFriendlyName varchar(500),
    @arrivalStatus int output,
    @instanceId bigint output,
    @fileName varchar(500) output
    VariableName Direction DataType ParamName
    User::TranFilePattern Input VARCHAR 0
    System::PackageName Input VARCHAR 1
    User::AppID Input SHORT 2
    User::todaysDate Input DATE 3
    User::TranFileArriveStatus OUTPUT SHORT 5
    User::TranFileInstanceId OUTPUT LARGE_INTEGER 6
    User::TranFileName OUTPUT VARCHAR 7
    User::TranFileFriendlyName Input VARCHAR 4
    User::TranFilePattern,string,tranfile05-Nov-2014
    User::fileDate,string,05-Nov-2014
    System::PackageName,
    User::AppID,int32,12
    User::todaysDate,DateTime, set by select getdate()
    User::TranFileArriveStatus,int32,0
    User::TranFileInstanceId,Int64,0
    User::TranFileName,string
    User::TranFileFriendlyName,string,Tran File

    I may have gotten past this.  The ui showed the first execution of that proc as the aborting component but when I looked at my error code (-1073548784), and component name in the
    message sent with notification email, I noticed the second component name.  It too executes that proc and still had ushort for appid in sql task mapping and long for instance id.  I changed these characteristics to match what I posted and got green
    on the seq container that runs both.
    I think I go thru this kind of adventure every time I try to map proc output to ssis vars.   

  • Copy the result of Execute immediate result into a variable.

    Hi All,
    Is there any way to copy the result of execute immediate result into a variable.
    am doing following steps but am getting an error.
    varSQLstmt1:='select count(*) into'||vararch_ct||' from '||vararch_count;
    dbms_output.put_line(varSQLstmt1);
    execute immediate varSQLstmt1;
    But am getting sql statement as select count(*) into from SALES
    the variable(vararch_ct) is missing in select statement .
    please help me to solve this issue. Or is there any way to insert the count of records into any variable.
    Thanks
    Sree

    declare
    varSQLstmt1    varchar2(4000);
    v_count          number;
    begin
    varSQLstmt1:='select count(*) from '||vararch_count;
    dbms_output.put_line(varSQLstmt1);   
    execute immediate varSQLstmt1 into v_count;
    dbms_output.put_line('Coutn :: ' || v_count);
    end;

  • Problem with store ResultSet and show result in table

    Hi, I'm kind of new in ADF, I need to store ResultSet and show result in table-component. I have two problems:
    1) I get my ResultSet by calling callStoredProcedure(...) and this returns actually ref_cursor as ResultSet.
    When I try to println() contains of this result set in this method - it works OK (commented part),
    but when I want to println() somewhere else (eg. in retrieveRefCursor() method) it doesn't work.
    The problem is that the scrollability of the ResultSet is lost - it becomes a TYPE_FORWARD_ONLY ResultSet.
    Is there any way to store data from ref_cursor for a long time?
    2) My second problem is "store any result set and show this data in table". I have tried use method storeNewResultSet() but
    without result (table contains only "No rows yet" and everything seems to be OK - no exception, no warning, no error...).
    I have tried to call this method with ResultSet from select on dbs (without resultSet as ref_cursor ) - no result with createRowFromResultSet(),
    storeNewResultSet(), setUserDataForCollection()...
    I've tried a lot of ways to do this, but it doesn't work. I really don't know how to make it so it can work.
    Thanks for your help.
    ADF BC, JDev 11.1.1.0
    This is my code from ViewObjectImpl
    package tp.model ;
    import com.sun.jmx.mbeanserver.MetaData ;
    import java.sql.CallableStatement ;
    import java.sql.Connection ;
    import java.sql.PreparedStatement ;
    import java.sql.ResultSet ;
    import java.sql.ResultSetMetaData ;
    import java.sql.SQLException ;
    import java.sql.Statement ;
    import java.sql.Types ;
    import oracle.jbo.JboException ;
    import oracle.jbo.server.SQLBuilder ;
    import oracle.jbo.server.ViewObjectImpl ;
    import oracle.jbo.server.ViewRowImpl ;
    import oracle.jbo.server.ViewRowSetImpl ;
    import oracle.jdbc.OracleCallableStatement ;
    import oracle.jdbc.OracleConnection ;
    import oracle.jdbc.OracleTypes ;
    public class Profiles1ViewImpl extends ViewObjectImpl {
        private static final String SQL_STM = "begin Pkg_profile.get_profile_list(?,?,?,?);end;" ;
        public Profiles1ViewImpl () {
        /* 0. */
        protected void create () {
            getViewDef ().setQuery ( null ) ;
            getViewDef ().setSelectClause ( null ) ;
            setQuery ( null ) ;
        public Connection getCurrentConnection () throws SQLException {
            // Note that we never execute this statement, so no commit really happens
            Connection conn = null ;
            PreparedStatement st = getDBTransaction ().createPreparedStatement ( "commit" , 1 ) ;
            conn = st.getConnection () ;
            st.close () ;
            return conn ;
        /* 1. */
        protected void executeQueryForCollection ( Object qc , Object[] params , int numUserParams ) {
            storeNewResultSet ( qc , retrieveRefCursor ( qc , params ) ) ;
            // callStoredProcedure ( qc , SQL_STM ) ;
            super.executeQueryForCollection ( qc , params , numUserParams ) ;
        /* 2. */
        private ResultSet retrieveRefCursor ( Object qc , Object[] params ) {
            ResultSet rs = null ;
            rs = callStoredProcedure ( qc , SQL_STM ) ;
            return rs ;
        /* 3. */
        public ResultSet callStoredProcedure ( Object qc , String stmt ) {
            CallableStatement st = null ;
            ResultSet refCurResultSet = null ;
            try {
                st = getDBTransaction ().createCallableStatement ( stmt , 0 ) ; // call 
                st.setObject ( 1 , 571 ) ; //set id of my record to 571
                st.registerOutParameter ( 2 , OracleTypes.CURSOR ) ; // my ref_cursor
                st.registerOutParameter ( 3 , Types.NUMERIC ) ;
                st.registerOutParameter ( 4 , Types.VARCHAR ) ;
                st.execute () ; //executeUpdate
                System.out.println ( "Numeric " + st.getObject ( 3 ) ) ;
                System.out.println ( "Varchar " + st.getObject ( 4 ) ) ;
                refCurResultSet = ( ResultSet ) st.getObject ( 2 ) ; //set Cursoru to ResultSet
                //   setUserDataForCollection(qc, refCurResultSet); //don't work
                //   createRowFromResultSet ( qc , refCurResultSet ) ; //don't work
                /* this works but only one-time call - so my resultSet(cursor) really have a data
                while ( refCurResultSet.next () ) {
                    String nameProfile = refCurResultSet.getString ( 2 ) ;
                    System.out.println ( "Name profile: " + nameProfile ) ;
                return refCurResultSet ;
            } catch ( SQLException e ) {
                System.out.println ( "sql ex " + e ) ;
                throw new JboException ( e ) ;
            } finally {
                if ( st != null ) {
                    try {
                        st.close () ; // 7. Close the statement
                    } catch ( SQLException e ) {
                        System.out.println ( "sql exx2 " + e ) ;
        /* 4. Store a new result set in the query-collection-private user-data context */
        private void storeNewResultSet ( Object qc , ResultSet rs ) {
            ResultSet existingRs = getResultSet ( qc ) ;
            // If this query collection is getting reused, close out any previous rowset
            if ( existingRs != null ) {
                try {
                   existingRs.close () ;
                } catch ( SQLException s ) {
                    System.out.println ( "sql err " + s ) ;
            setUserDataForCollection ( qc , rs ) ; //should store my result set
            hasNextForCollection ( qc ) ; // Prime the pump with the first row.
        /*  5. Retrieve the result set wrapper from the query-collection user-data      */
        private ResultSet getResultSet ( Object qc ) {
            return ( ResultSet ) getUserDataForCollection ( qc ) ;
        // createRowFromResultSet - overridden for custom java data source support - also doesn't work
       protected ViewRowImpl createRowFromResultSet ( Object qc , ResultSet resultSet ) {
            ViewRowImpl value = super.createRowFromResultSet ( qc , resultSet ) ;
            return value ;
    }

    Hi I have the same problem like you ...
    My SQL Definition:
    CREATE OR REPLACE TYPE RMSPRD.NB_TAB_STOREDATA is table of NB_STOREDATA_REC
    CREATE OR REPLACE TYPE RMSPRD.NB_STOREDATA_REC AS OBJECT (
       v_title            VARCHAR2(100),
       v_store            VARCHAR2(50),
       v_sales            NUMBER(20,4),
       v_cost             NUMBER(20,4),
       v_units            NUMBER(12,4),
       v_margin           NUMBER(6,2),
       v_ly_sales         NUMBER(20,4),
       v_ly_cost          NUMBER(20,4),
       v_ly_units         NUMBER(12,4),
       v_ly_margin        NUMBER(6,2),
       v_sales_variance   NUMBER(6,2)
    CREATE OR REPLACE PACKAGE RMSPRD.NB_SALES_DATA
    AS
    v_sales_format_tab   nb_tab_storedata;
    FUNCTION sales_data_by_format_gen (
          key_value         IN       VARCHAR2,
          l_to_date         IN       DATE DEFAULT SYSDATE-1,
          l_from_date       IN       DATE DEFAULT TRUNC (SYSDATE, 'YYYY')
          RETURN nb_tab_storedata;
    I have a PLSQL function .. that will return table ..
    when i use this in sql developer it is working fine....
    select * from table (NB_SALES_DATA.sales_data_by_format_gen('TSC',
                                        '05-Aug-2012',
                                        '01-Aug-2012') )
    it returning table format record.
    I am not able to call from VO object. ...
    Hope you can help me .. please tell me step by step process...
    protected Object callStoredFunction(int sqlReturnType, String stmt,
    Object[] bindVars) {
    System.out.println("--> 1");
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement("begin ? := " +"NB_SALES_DATA.sales_data_by_format_gen('TSC','05-Aug-2012','01-Aug-2012') ; end;", 0);
    System.out.println("--> 2");
    st.executeUpdate();
    System.out.println("--> 3");
    return st.getObject(1);
    catch (SQLException e) {
    e.printStackTrace();
    throw new JboException(e);

  • Store results into a variable...

    How can I get a result I need into a variable, that I can use in a subsequent query.
    My initial thought was something like:
    select emp_id into MyVariable
    from emp where emp_NAME='Kevin';
    select * from emp
    where emp_id='&MyVariable';
    I'm doing this in TOAD, and I need to manually type the 'Kevin' once, and use the MyVariable in a series of queries; otherwise I would just use ACCEPT, and ask for the Name, and lookup the emp_id. But this is not what I need for this.
    I've tried OBG (Oracle By Google) which suggested something like:
    DECLARE
    MyVariable number;
    BEGIN
    select emp_id into MyVariable
    where emp_NAME='Kevin';
    dbms_output.put.line ('My Variable is ' || MyVariable);
    END
    But I'm getting and error on the dbms_output statement, and I can't seem to use the variable in a subsequet select statement!
    Appreciate any thoughts on this!

    I would advise putting the sql statements into a pl/sql block - then you could reuse the value
    declare
        v_my_var NUMBER;
    begin
        -- Get your value
        select ... into v_my_var from ... where name = 'Kevin' ...
        -- your first sql statement
        select  .... from .... where id = v_my_var;
        -- your second sql statement
        select .... from .... where id = v_my_var;
        etc.
    end;Toad does also provide for using the same value multiple times - for example, if you execute
    select &name from dual;   (any select statement)it will prompt you for a value for &name
    You can then have multiple statements after that in your sql tab
    select .... from .... where name = &nameand it will replace the &name with the value you previously entered. You need to use Editor -> Run as Script (F5) to run all the sql statements in your tab.
    Hope this helps.

  • Input result from a SQL-query into a Variable in ProcessFlow

    I am trying to select a value from a table with file names.
    This file name should be input to an ftp function. I use a owb function to read the file name then I try to asign the result to a variable.
    The function GET_FILENAME looks like
    f_name varchar2(30);
    BEGIN
    select distinct FILENAME_SOURCE into f_name from CTL_SOURCE_FILES
    where FILEID = (select min(FILEID) from CTL_SOURCE_FILES where status is null);
    RETURN f_name;
    END;
    When running it as a SQL-script it returns only one row/name.
    When I am running it in the ProcessFlow the following message is found:
    RPE-02040: Internal error: GET_FILENAME cannot be converted to a constant value.

    Let me talk about this in context of a mapping:
    create a mapping :
    use a function within a mapping
    assign the output of the mapping to a mapping input variable"
    use this mapping within your process flow and see if it works.
    if you are directly going to use the output of a function in a process flow , the FTP should be able to accept the filename from the outparam of the function which i am not sure how it works.
    try using the first approach as it is relatively simple and straightforward.

  • Problems when starting with oracle SQL developer

    Hello,
    I am very much new with oracle SQL developer. I use oracle 10g and have a database named 'pallabDB' with username: xxxxxx and paswd:yyyyyy. I have installed oracle SQL developer.But i am unable to start up.What i should do? If any body replies it will be a great help.Thanks in advance.

    But i am unable to
    start up.How to understand this sentence without confusion?
    Can you explain exactly what is your problem at start up of SQL Developer?

  • Problem in connection to Oracle SQL Developer

    Hi All,
    I am trying to connect to remote machine database through Oracle SQL Developer, it is giving me teh following error.
    Status: Faliure -Test failed :io connection :The Network Adapter could not establish the connection .
    I had given the hostname as the name which is assigned to that server, it didnt work.
    Later i tried with the IP address of the Server, it worked.
    Can anybody tell me how can i connect by giving hostname instead of the IP address.
    Thanks in advance,
    Vinay

    Hi Vinay,
    One way would be to add an entry in your hosts file. On windoze you can find this in
    %SystemRoot%\system32\drivers\etc
    Regards
    Peter

  • Capturing oracle error codes into a variable

    Hi
    Can someone show me how it is possible to save an Oracle defined error code into a variable? What I am trying to do is when a stored procedure fails an Oracle error is raised, such as ORA-xxxx, then pass this code into variable to be saved into a log.
    How do I achieve this?

    user633278 wrote:
    How do I achieve this?Function SQLCODE in PL/SQL exception handler returns error code. SQLERRM returns message:
    SQL> declare
      2      x number;
      3  begin
      4      x := 1/0;
      5    exception
      6      when others
      7        then
      8          dbms_output.put_line('Error code: ' || SQLCODE);
      9          dbms_output.put_line('Error message: ' || SQLERRM);
    10  end;
    11  /
    Error code: -1476
    Error message: ORA-01476: divisor is equal to zero
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Loading an Oracle SQL query into an MSSQL table

    I have a select query on an Oracle table. I want to load this data into an MSSQL table.
    Problem is that I cannot create an interim table on the Oracle database (lack of privelages)
    Is there a way to load an Oracle query into the MSSQL table without an interim table?
    Many thanks
    Z

    Yes,
    1) Create an ODI procedure
    2) Create a step inside
    3) at source tab put the oracle query
    4) at target tab put the sql insert code
    Refer to the oracle returned values like "#column_name_from_oracle_query"
    Make sense?
    Cezar Santos
    [www.odiexperts.com]

  • Problem etablishing connection between oracle SQL and JDBC

    Hi friends i have been trying this code from two days i donno whats wrong please try to sort the problem thank u in advance this is my program:
    //This is my Connection class
    package com.java.jdbc.util;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class EmployeeUtil {
         public EmployeeUtil()
         public static Connection getconnection()
              Connection con=null;
              try {
                   Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                   //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORANT","system","manager");
              // Class.forName("sun.jdbc.odbc.OracleDriver").newInstance();
              // con = DriverManager.getConnection("jdbc:odbc:Javatut","System","manager");
              } catch (ClassNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (InstantiationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              return con;
    //This is my DB class:
    package com.java.jdbc.DB;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import com.java.jdbc.info.EmployeeInfo;
    import com.java.jdbc.util.EmployeeUtil;
    public class EmployeeDB {
         Connection connection=null;
         public EmployeeDB()
              //this.connection=EmployeeUtil.getconnection();
         public void select(EmployeeInfo empinfo)
              this.connection=EmployeeUtil.getconnection();
              String stb = "select * from employee";
         try {
                   Statement stmt = connection.createStatement();
                   ResultSet rs = stmt.executeQuery(stb);
                   System.out.println(rs);
                   //EmployeeInfo empinfo = new EmployeeInfo();
                   while(rs.next())
                        empinfo.setEmpId(rs.getString(1));
                        empinfo.setEmpfName(rs.getString(2));
                        empinfo.setEmplName(rs.getString(3));
                        empinfo.setEmpAge(rs.getString(4));
                        empinfo.setEmpSalary(rs.getString(5));
                        System.out.println("The EmployeeID is : "+empinfo.getEmpfName());
                        System.out.println("The Employee First Name is : "+empinfo.getEmpfName());
                        System.out.println("The Employee Last Name is : "+empinfo.getEmplName());
                        System.out.println("The Employee Age is : "+empinfo.getEmpAge());
                        System.out.println("The Employee Salary is : "+empinfo.getEmpSalary());
                   connection.commit();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    //This is my info object
    package com.java.jdbc.info;
    public class EmployeeInfo {
         private String empId;
         private String empfName;
         private String emplName;
         private String empAge;
         private String empSalary;
         public String getEmpAge() {
              return empAge;
         public void setEmpAge(String empAge) {
              this.empAge = empAge;
         public String getEmpfName() {
              return empfName;
         public void setEmpfName(String empfName) {
              this.empfName = empfName;
         public String getEmpId() {
              return empId;
         public void setEmpId(String empId) {
              this.empId = empId;
         public String getEmplName() {
              return emplName;
         public void setEmplName(String emplName) {
              this.emplName = emplName;
         public String getEmpSalary() {
              return empSalary;
         public void setEmpSalary(String empSalary) {
              this.empSalary = empSalary;
    //This is my Controller class:
    package com.java.jdbc.controller;
    import com.java.jdbc.DB.EmployeeDB;
    import com.java.jdbc.info.EmployeeInfo;
    public class EmployeeController {
         public static void main(String args[])
              EmployeeDB empdb = new EmployeeDB();
              EmployeeInfo emp = new EmployeeInfo();
              empdb.select(emp);     
    // I got these errors:
    java.sql.SQLException: Io exception: Got minus one from a read call
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:210)
         at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at com.java.jdbc.util.EmployeeUtil.getconnection(EmployeeUtil.java:18)
         at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:20)
         at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)
    Exception in thread "main" java.lang.NullPointerException
         at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:23)
         at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)

    Are you using Oracle 10.2 in shared server configuration under Windows?
    If so it's a driver bug (BUG - Connection pooling with 10g 10.1.3 Preview 4 App Server Oracle suggest to use OCI driver.

  • Problems with debugging in Oracle sql developer

    Dear all,
    I have a stored procedure with about 3500 lines of code. The SP is calling some other SP's , so altogether around 30,000 lines of code is to executed.
    I have some delete statements in the beginning of my SP.
    Till nw i was able to debug and run this SP.
    But nw I am facing a strange problem.
    I can run the SP.
    But if i try to debug it , it gets hanged after the delete statement and does not move forward.
    So i moved all that statements to another SP and I call the new SP from my present one.
    In this way If i debug , after calling the newly created SP , my main Sp does not recognise the break points , and it just finishes execution ..
    Can any one help me on this.
    Thanks in Advance,
    Kurian Simon

    Simon,
    Did you move the breakpoint, and once you'd moved the lines of code, did you recompile, using compile for debug? Also, it's important to do compile for debug on all the program units you want to debug, otherwise SQL Developer will just step over the units not compiled for debug.
    Sue

  • XMLELEMENT/ XMLAGG functions - Fetching the result into a variable

    Hi, I have a query to generate an XML output. I have the following questions:
    1) I am typecasting the result from this query to a VARCHAR2 and I want to assign the output to a VARCHAR2 variable. Can you please help me with that. When I try to get this into a varchar variable, i get the following error:
    declare
    x varchar2(6000);
    begin
    SELECT CAST(xmlelement("itemMaster",
    xmlelement("itemNumber",lpad(d.dept_i,3,0)||lpad(d.class_i,2,0)||lpad(d.item_i,4,0)),
    xmlelement("itemDesc",NVL(d.ITEM_DESC_T,lpad(d.dept_i,3,0)||lpad(d.class_i,2,0)||lpad(d.item_i,4,0))),
    xmlelement("paltSize",p1_test),
    xmlelement("stdUOM",p1_test),
    xmlelement("sellByDayQty",d.sell_by_day_q),
    xmlelement("shflfUOM",p1_test),
    xmlelement("minShflfDayQty",d.min_shflf_day_q),
    xmlelement("itemCatgCode",NVL(d.dc_item_catg_c,'GM')),
    xmlelement("strgTempZoneCode",NVL(d.strg_tmpr_zone_c,'01')),
    xmlelement("retailAmt",retl_a),
    xmlelement("expireDateFlag",NVL(d.expire_date_f,'N')),
    xmlelement("randomWtFlag",NVL(d.rndm_wt_f,'N')),
    xmlelement("wetFlag",NVL(d.wet_f,'N')),
    xmlelement("areaCode",d.area_c),
    xmlelement("vcpQty",d.vcp_q),
    xmlelement("sspQty",d.ssp_q),
    xmlelement("hndlTypeCode",d.hndl_type_c),
    xmlelement("mstrPackTypeCode",d.mstr_pk_type_c),
    xmlelement("mstrItemTypeCode",NVL(d.mstr_item_type_c,'00')),
    xmlelement("sszCode",d.reg_ssz_excpt_c),
    xmlelement("agriFlag",NVL(d.agrl_f,'N')),
    xmlelement("itemRankCode",d.item_rank_c),
    xmlelement("hazardFlag",NVL(d.hazd_mtrl_f,'N')),
    xmlelement("createDate",to_char(d.create_d,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("updateDate",to_char(d.modf_ts,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("actvnDate",to_char(d.actvn_d,'MM-DD-YYYY HH24:MI:SS')),
    xmlelement("organicCode",d.ognc_c),
    xmlelement("lotCntlFlag",NVL(d.lot_cntl_f,'N')),
    xmlelement("flammableFlag",NVL(d.flam_c,'N')),
    xmlelement("recordMode",c.action_c),
    xmlelement("areaType",p1_test),
    xmlelement("uoms",
    xmlelement("uom",
    xmlelement("prodUOM",p1_test),
    xmlelement("ratioDen",p1_test),
    xmlelement("consldtRule",p1_test),
    xmlelement("unitWtQty",NVL(d.unit_wt_q,1)),
    xmlelement("vcpHeightQty",NVL(d.vcp_ht_q,1)),
    xmlelement("vcpWidthQty",NVL(d.vcp_wth_q,1)),
    xmlelement("vcpLengthQty",NVL(d.vcp_lgth_q,1)),
    xmlelement("layerQty",p1_test)
    (SELECT xmlelement("aliases",
    xmlagg(xmlelement("upcCode",trunc(b.bar_code_i))
    ORDER BY b.dept_i,b.class_i,b.item_i
    FROM dc_item_bar_code b,
    dc_item a
    WHERE a.dept_i = b.dept_i
    AND a.class_i = b.class_i
    AND a.item_i = b.item_i
    AND a.dept_i = c.dept_i
    AND a.class_i = c.class_i
    AND a.item_i = c.item_i
    AS VARCHAR2(4000)
    ) INTO x
    FROM dc_item d, item_wm_trigger_w c
    WHERE d.dept_i = c.dept_i
    AND d.class_i = c.class_i
    AND d.item_i = c.item_i;
    end;
    ERROR at line 1:
    ORA-06550: line 49, column 33:
    PLS-00306: wrong number or types of arguments in call to 'XMLAGG'
    ORA-06550: line 49, column 33:
    PL/SQL: ORA-00904: "XMLAGG": invalid identifier
    ORA-06550: line 4, column 1:
    PL/SQL: SQL Statement ignored
    When I run this query without the
    declare
    begin
    select....
    into...
    end
    construct, it's working perfectly fine.
    Any help would be greatly appreciated.
    Thanks,
    Nitin

    I think I confused you. The 'pre' tags are for this Oracle Forum ( not your code). If your code was formatted we can look at it better .
    For example, I have put your code in those tags(you won't see them), they are for the forum software to process.
    See, how I didn't lose the formatting?
    DECLARE
      x VARCHAR2(6000);
    BEGIN
      SELECT CAST(xmlelement("itemMaster",
                             xmlelement("itemNumber",
                                        lpad(d.dept_i, 3, 0) || lpad(d.class_i, 2, 0) ||
                                        lpad(d.item_i, 4, 0)),
                             xmlelement("itemDesc",
                                        NVL(d.ITEM_DESC_T,
                                            lpad(d.dept_i, 3, 0) ||
                                            lpad(d.class_i, 2, 0) ||
                                            lpad(d.item_i, 4, 0))),
                             xmlelement("paltSize", p1_test),
                             xmlelement("stdUOM", p1_test),
                             xmlelement("sellByDayQty", d.sell_by_day_q),
                             xmlelement("shflfUOM", p1_test),
                             xmlelement("minShflfDayQty", d.min_shflf_day_q),
                             xmlelement("itemCatgCode", NVL(d.dc_item_catg_c, 'GM')),
                             xmlelement("strgTempZoneCode",
                                        NVL(d.strg_tmpr_zone_c, '01')),
                             xmlelement("retailAmt", retl_a),
                             xmlelement("expireDateFlag", NVL(d.expire_date_f, 'N')),
                             xmlelement("randomWtFlag", NVL(d.rndm_wt_f, 'N')),
                             xmlelement("wetFlag", NVL(d.wet_f, 'N')),
                             xmlelement("areaCode", d.area_c),
                             xmlelement("vcpQty", d.vcp_q),
                             xmlelement("sspQty", d.ssp_q),
                             xmlelement("hndlTypeCode", d.hndl_type_c),
                             xmlelement("mstrPackTypeCode", d.mstr_pk_type_c),
                             xmlelement("mstrItemTypeCode",
                                        NVL(d.mstr_item_type_c, '00')),
                             xmlelement("sszCode", d.reg_ssz_excpt_c),
                             xmlelement("agriFlag", NVL(d.agrl_f, 'N')),
                             xmlelement("itemRankCode", d.item_rank_c),
                             xmlelement("hazardFlag", NVL(d.hazd_mtrl_f, 'N')),
                             xmlelement("createDate",
                                        to_char(d.create_d, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("updateDate",
                                        to_char(d.modf_ts, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("actvnDate",
                                        to_char(d.actvn_d, 'MM-DD-YYYY HH24:MI:SS')),
                             xmlelement("organicCode", d.ognc_c),
                             xmlelement("lotCntlFlag", NVL(d.lot_cntl_f, 'N')),
                             xmlelement("flammableFlag", NVL(d.flam_c, 'N')),
                             xmlelement("recordMode", c.action_c),
                             xmlelement("areaType", p1_test),
                             xmlelement("uoms",
                                        xmlelement("uom",
                                                   xmlelement("prodUOM", p1_test),
                                                   xmlelement("ratioDen", p1_test),
                                                   xmlelement("consldtRule", p1_test),
                                                   xmlelement("unitWtQty",
                                                              NVL(d.unit_wt_q, 1)),
                                                   xmlelement("vcpHeightQty",
                                                              NVL(d.vcp_ht_q, 1)),
                                                   xmlelement("vcpWidthQty",
                                                              NVL(d.vcp_wth_q, 1)),
                                                   xmlelement("vcpLengthQty",
                                                              NVL(d.vcp_lgth_q, 1)),
                                                   xmlelement("layerQty", p1_test))),
                             (SELECT xmlelement("aliases",
                                                xmlagg(xmlelement("upcCode",
                                                                  trunc(b.bar_code_i))
                                                       ORDER BY b.dept_i,
                                                       b.class_i,
                                                       b.item_i))
                                FROM dc_item_bar_code b, dc_item a
                               WHERE a.dept_i = b.dept_i
                                 AND a.class_i = b.class_i
                                 AND a.item_i = b.item_i
                                 AND a.dept_i = c.dept_i
                                 AND a.class_i = c.class_i
                                 AND a.item_i = c.item_i)) AS VARCHAR2(4000))
        INTO x
        FROM dc_item d, item_wm_trigger_w c
       WHERE d.dept_i = c.dept_i
         AND d.class_i = c.class_i
         AND d.item_i = c.item_i;
    END;
    /

  • How to pass the grep result into a variable in Unix

    I have the following statements in my unix batch script:
    JOBNAME=`grep "$1" rssc_plsbatch.txt|awk -F'~' '{print $1}'`;
    PROCNAME=`grep "$1" rssc_plsbatch.txt|awk -F'~' '{print $2}'`;
    JOBDESC=`grep "$1" rssc_plsbatch.txt|awk -F'~' '{print $3}'`;
    PARMS=`grep "$1" rssc_plsbatch.txt|awk -F'~' '{print $4}'`;
    I want to grep the the first line in the text file and pass it to a variable and then using awk programming, I want to print for each variable (JOBNAME, PROCNAME, JOBDESC and PARMS), instead of using grep 4 times.
    Can somebody please help.
    Each line of my text file is in the the following format:
    00001JOB1~PROCNAME1~This is a procedure~10,'A','B'~
    And also I want to check whether $1 passed (part of JONAME) is not fount, then it should exit with error message, if $1 (input parameter) does not match, I want to exit the program, instead of processing further statements.

    If you want to return error codes, you can do that with the return command.
    If the process name isn't found, grep will return a specific error code... from man grep
    Normally, exit status is 0 if selected lines are found and 1 otherwise.
    But the exit status is 2 if an error occurred, unless the -q or quiet or silent option is used and a selected line is found.
    So you can use the exit code of grep in an if statement to decide what return code you want to return with your own script.
    Mike

Maybe you are looking for

  • Inconstancy in Approval Workflow- Process Controlled Workflow

    Hello Experts, We are in SRM 7.0 classic scenario using process controlled workflow and facing an issue as described below:- During the approval workflow, we are observing that in Case 1: When approver3 is forwarding the work item to approver10, the

  • Bengali Unicode display distorted last 7 days

    For last 7 days, Bengali Unicode display failed. Bengali words use compound alphabets. They are getting broken up & displaying each alphabet separately like roman alphabets. No such problem in MS Word, Excel etc., or even when using Internet Explorer

  • Using two field in a same custom function

    hi experts, i have a query suppose i have a data of 3 field Name            State                   city tom              gujrat                 varoda billy              rajasthan            jaipur jeny              maharastra        mumbai jeny    

  • And put them into stand alone albums on my iPhone 4?

    I want to take some pictures off the camera roll and put them into stand alone albums on my phone...how do I do this?

  • Quicktime corrupted / iTunes won't launch / Win 7

    I've been avidly reading the posts of "b noir" to try and remedy my situation but so far to no avail. Briefly: I "broke" both QuickTime and iTunes by trying to make UbiSoft's Myst run on my Win 7: the solution there was to uninstall QuickTime (10) an