Help with inserting values to sql database

Hello everyone I am having this problem with how to fill my values in my sql statement, if you look below you will notice i have set up the values to be the length of the arr (arrayList).
could someone please let me now how i should put there values in.
thanks for yr time
piper3
  try {
                                                String data = "jdbc:odbc:myProject";
                                                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                                    Connection con = DriverManager.getConnection(data,"","");
                                             StringBuffer sb = new StringBuffer();
                                             Iterator it1 = arr.iterator();
                                             while (it1.hasNext())
                                                  if (sb.length() > 0)
                                                       sb.append(",");
                                                       sb.append(it1.next());
                                                  //takes the items of the arInterim
                                                  //int iCountInterim = arInterim.size();
                                                  int er = arr.size();
                                                  String sInterim = new String();
                                                  String sql = new String();
                                                  for(int i2 = 0; i2 < er; i2++){
                                                       sInterim = sInterim + sQuestion;
                                                       if(i2 < (er-1)){
                                                            sInterim = sInterim + sComma;
                                                       sql = "INSERT into Ben (" + sb.toString() + ") values (" + sInterim + ")";
                                                       System.out.println(sql);
                                                       PreparedStatement prepStmt = con.prepareStatement(sql);
                                                       /*prepStmt.setString(1, "hello");
                                                       prepStmt.setString(2, "hi");
                                                       prepStmt.setString(3, "bye");
                                                       prepStmt.executeUpdate();
                                                       prepStmt.close();*/
                                                  con.close();               
                                             } catch (Exception e1) {
                                                         System.err.println("Got an exception! ");
                                                         System.err.println(e1.getMessage());
                                                  //System.out.println();//.size());//tempkey+"\n"+tempvalue);

you should write a prepared statement like this:
PreparedStatement updateSales = con.prepareStatement(
"UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ?");
where "?" is a placeholder for the values you want to use.
Then later when you want to actually update your database, first set the placeholders to your values (stored in your array for example) using a statement like this:
updateSales.setString(2, "Colombian");
//sets the 2. placeholder in the statement to the value "Colombian"
after having set all placeholders to a specific value, execute your statement:
updateSales.executeUpdate();
your code should like:
sql = "INSERT into Ben values (?,?,?)";
PreparedStatement prepStmt = con.prepareStatement(sql);
prepStmt.setString(1, "hello");
prepStmt.setString(2, "hi");
prepStmt.setString(3, "bye");
prepStmt.executeUpdate();
prepStmt.close();
HTH
Christine

Similar Messages

  • Help with inserting values -- ORA-00984 error

    Hello!
    This time we have a problem with inserting values and we really can't find what's wrong!
    The table was created as such
    CREATE TABLE PASSAGER
    (NO_PERSONNE INTEGER,
    NO_PASSAGER INTEGER NOT NULL,
    NO_PASSEPORT INTEGER NOT NULL,
    NATIONALITE VARCHAR2(30) NOT NULL,
    LIEU_EMISSION VARCHAR2(30) NOT NULL,
    DATE_EMISSION DATE NOT NULL,
    NO_TEL INTEGER,
    NO_CC INTEGER,
    NO_VENTE INTEGER NOT NULL,
    CONSTRAINT PK_PASSAGER PRIMARY KEY (NO_PERSONNE),
    CONSTRAINT FK_PASSAGER_PERSONNE FOREIGN KEY (NO_PERSONNE) REFERENCES PERSONNE (NO_PERSONNE),
    CONSTRAINT FK_PASSAGER_VENTE FOREIGN KEY (NO_VENTE) REFERENCES VENTE (NO_VENTE));
    We created a sequence..
    CREATE SEQUENCE NOPASS_SEQ
    START WITH 1
    INCREMENT BY 1
    NOCACHE
    NOCYCLE;
    for inserting the values, we did...
    INSERT INTO PASSAGER VALUES (500,NOPASS_SEQ.NEXTVAL, WT456789,'CANADIENNE', 'CANADA', to_date('2007/10/12','YYYY/MM/DD'),5142348756,5157981500126734,1);
    but it won't work, it's our last table and all the other worked perfectly!
    Thanks a ton!

    In your table creation, you got third column as
    NO_PASSEPORT INTEGER NOT NULL,
    where as you are passing varchar values (see bold)
    INSERT INTO PASSAGER VALUES (500,NOPASS_SEQ.NEXTVAL, WT456789,+'CANADIENNE', 'CANADA', to_date('2007/10/12','YYYY/MM/DD'),5142348756,5157981500126734,1);
    Should be like this I suppose
    INSERT INTO PASSAGER VALUES (500,NOPASS_SEQ.NEXTVAL, *456789*,'CANADIENNE', 'CANADA', to_date('2007/10/12','YYYY/MM/DD'),5142348756,5157981500126734,1);

  • Error upon inserting data in sql Database using stream analytics job: Datatye error conversion

    I have a data passed into the Event Hubs, queried by stream analytic job inserting it into sql database. Upon running the job, it becomes idle a few seconds after since it has an error:
    Message: Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64.
    Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64. Exception message at level [1], exception number [0], parent exception number [0]: Conversion from 0 to System.Boolean failed. 0 was of type - System.Int64.
    The data type in one of my field(IsHistorical) is Boolean with a value of false. The data type of the column in the sql table where this is to be inserted is of type bit. In this case, it seems that stream analytics could not convert the value "false"
    into a bit data type when inserting in sql table.
    I'm wondering if you already have encountered this problem. Could you help me resolve this problem?
    Thank you.

    Azure Stream Analytics does not have Boolean type. On input we will convert JSON Boolean value to bigint.
    Here is the list of supported types and conversions:
    https://msdn.microsoft.com/en-us/library/azure/dn835065.aspx 
    You  can fix this erro by changing column type from bit to int in SQL table schema.

  • What are the Benefits of Synchronizing/ Replicating Project Online with an on-Premise SQL Database

    Hi
    What are some of the reasons and/ or benefits that one may want to consider with regards to setting up and synchronizing Project Online with a on-Premise SQL database ?
    \Spiro Theopoulos PMP, MCITP. Montreal, QC (Canada)

    Spiro,
    Reporting via Project Online is limited to OData, and writing queries with OData starts getting complex at a certain point.
    So, if your organization in using third party BI tools, or want to use OLAP cubes, or in general want to use straight SQL queries instead of oData, it is generally beneficial to have the data in house for reporting.
    So in general, using the SQL Synchronization, will bring data into "your" organization, as opposed to being with Microsoft so you get a LOT more flexibility with reporting.
    Hope this helps your question.
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • Need help with NULL values in Crosstables

    Hello everybody,
    I need some help with NULL values and crosstables. My issue is the following:
    I have a query (BW - MDX-Query) that gives me turnover measures for each month. In Crystal Reports I choose crosstable to display this whereby I put all month in columns and all turnover-measures in rows. Each month that has a value (measures are not empty) is chown in the crosstables rows. So far so good. The problem occures when there are month that actually have no values (measures are empty). In that case these months are not chown in columns. But I need CR to display these columns and show the value 0. How can I do that?

    Hi Frank,
    Cross tab shows the data based on your column and these column fields are grouped and based on the group it will show your summaries. 
    If there is no data for any of your group it will not display that group.  In this case you will have to create a standard report which should look like cross tab and to get zero values you need to write formulas .
    Example if you want to display Moth wise sales :
    if Month() = 01 Then
    sum() else 0
    Now this formula will check if your month is Jan, then it will sum up the values else it will display zero value. 
    This is possible only through standard report not with Cross Tab.
    Thanks,
    Sastry

  • How to read the 'Input help with fixed values' of domain .

    How to read the 'Input help with fixed values' of domain .
    The domain has a Value range i want to read those values .
    Are these values stored in any table ?
    Plz help me i need it ver badly...
    Thanks in Advance...

    Hi Chandra Shekhar,
    To read the 'Input help with fixed values' of domain , you can use the function module : HR_P_GET_FIXED_VALUE_TEXT.
    iIf you enter the domain name, you will find the fixed values entered in the domain.
    These values are stored in a table DD07L(DD zero 7 L). Here the values are stored based on domain name.
    See if it works for you.
    Award points if its helpful.
    Regards,
    Bhanu

  • Insert data into sql database where the values are in an array

    Hello Experts,
    using vbscript i want to store data in MS SQL. i have prepared a script which works fine when i provide the static value but in actual i get the values in an array and now want to store values from there.
    Below is not complete code but the block in question.
    oRecordset_Working.Open "INSERT INTO tbl_work (release, version, state, Arch)" & _
    "VALUES ('5.2', '11.25' , 'Active', 'XYZ')", _
    oConnection, adOpenStatic, adLockOptimistic
    i verified the database and can see the information is feeded.
    What i really want to make work is:
    for i=0 to UBound (arrValues)
    oRecordset_Working.Open "INSERT INTO tbl_work (release, version, state, Arch)" & _
    "VALUES ('arrValues(i)')", _
    oConnection, adOpenStatic, adLockOptimistic
    Next
    logically it is incorrect as INSERT query comes inside the loop but then how can someone make it work?
    can someone help me with this?
    -KAKA-

    Here is the preferred method of inserting multiple values into multiple fields.  It is very fast and very easy to set up.
    Const adBSTR = 8
    Const adInput = 1
    Const CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\temp\test.mdb;Persist Security Info=False"
    Const SQL_INSERT = "INSERT INTO Table1(ID, Name, Notes) VALUES(?, ?, ?)"
    Set conn = CreateObject("ADODB.Connection")
    conn.Open(CONNECTION_STRING)
    Set cmd = CreateObject("ADODB.Command")
    With cmd
    .ActiveConnection = conn
    .CommandText = SQL_INSERT
    .Prepared = True
    ' create parameter object and assign to command object
    .Parameters.Append .CreateParameter("ID", adBSTR, adInput)
    .Parameters.Append .CreateParameter("Name", adBSTR, adInput)
    .Parameters.Append .CreateParameter("Notes", adBSTR, adInput)
    End With
    ' bind and insert values
    For i = 2 To 10
    cmd.Parameters("ID") = "ID" & i
    cmd.Parameters("Name") = "Joe" & i
    cmd.Parameters("Notes") = "My notes"
    cmd.Execute
    Next
    conn.Close
    ¯\_(ツ)_/¯

  • Task Total Slack Calculated values mismatching with the values in reporting database

    Hi,
    We require 'Task Total Slack' as one of the items in a report for Project Server 2010. We're developing the reports using SSRS wherein the SQL Queries are fired on the reporting database of Project Server 2010.
    We've come across a situation wherein the total slack values from reporting database for tasks are mismatching with the values that are seen in either PWA or Project Professional for total slack field. We also could not find a consistent factor by which
    the slack is multiplied for reflecting in the database in case the Slack in days was being converted into Hours in reporting databse.
    Is there a definite way that these values are being represented in reporting database which is quite different from the way these values are seen in Project Professional? Please help resolving this issue.

    Hi Abhijit PS,
    Can you give an example of the mismatch? Also you could tell us if this is happening for all tasks and all projects. Your concern may be seen from 2 different points of view:
    Either this is indeed a bug with a slack of 2 days for example in Project Pro and 4 days in your report from the reporting DB. In this case, you should check if the projects have been published correctly and if the Reporting DB is correctly sync'ed with
    the draft DB.
    Or it could be the normal behavior and it is just a matter of finding why. For example, the durations are stored in the DB in minutes, meaning that a 1day duration might be stored as 480 if you have 8 working hours in a day (8*60).
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Need help with inserting rows in ResultSet and JTable

    hello Guru!
    i have inserted a row in my result set and i want that my table shows this row promptly after i have inserted it in my result set...
    but when i use following code for my resultset:
    rs.moveToInsertRow();
    rs.updateInt(1,nr);
    rs.updateString(2, name);
    rs.insertRow();
    Record are inserted in resultset and database but not shown in my JTable??
    Anyone a Clue to without reexecuting the query how can i display inserted row in JTable
    http://download-west.oracle.com/docs/cd/A87860_01/doc/java.817/a83724/resltse7.h
    I have refrered the following links but still clue less help Guruuuuuuu
    i m really in trobble??????

    i am just near by the Solution using the Database Metadata
    by couldn't get the ideaaaa
    ==================================================
    http://download-west.oracle.com/docs/cd/A87860_01/doc/java.817/a83724/resltse7.htm
    Seeing Database Changes Made Internally and Externally
    This section discusses the ability of a result set to see the following:
    its own changes (DELETE, UPDATE, or INSERT operations within the result set), referred to as internal changes
    changes made from elsewhere (either from your own transaction outside the result set, or from other committed transactions), referred to as external changes
    Near the end of the section is a summary table.
    Note:
    External changes are referred to as "other's changes" in the Sun Microsystems JDBC 2.0 specification.
    Seeing Internal Changes
    The ability of an updatable result set to see its own changes depends on both the result set type and the kind of change (UPDATE, DELETE, or INSERT). This is discussed at various points throughout the "Updating Result Sets" section beginning on , and is summarized as follows:
    Internal DELETE operations are visible for scrollable result sets (scroll-sensitive or scroll-insensitive), but are not visible for forward-only result sets.
    After you delete a row in a scrollable result set, the preceding row becomes the new current row, and subsequent row numbers are updated accordingly.
    Internal UPDATE operations are always visible, regardless of the result set type (forward-only, scroll-sensitive, or scroll-insensitive).
    Internal INSERT operations are never visible, regardless of the result set type (neither forward-only, scroll-sensitive, nor scroll-insensitive).
    An internal change being "visible" essentially means that a subsequent getXXX() call will see the data changed by a preceding updateXXX() call on the same data item.
    JDBC 2.0 DatabaseMetaData objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_SENSITIVE, or ResultSet.TYPE_SCROLL_INSENSITIVE).
    boolean ownDeletesAreVisible(int) throws SQLException
    boolean ownUpdatesAreVisible(int) throws SQLException
    boolean ownInsertsAreVisible(int) throws SQLException
    Note:
    When you make an internal change that causes a trigger to execute, the trigger changes are effectively external changes. However, if the trigger affects data in the row you are updating, you will see those changes for any scrollable/updatable result set, because an implicit row refetch occurs after the update.
    Seeing External Changes
    Only a scroll-sensitive result set can see external changes to the underlying database, and it can only see the changes from external UPDATE operations. Changes from external DELETE or INSERT operations are never visible.
    Note:
    Any discussion of seeing changes from outside the enclosing transaction presumes the transaction itself has an isolation level setting that allows the changes to be visible.
    For implementation details of scroll-sensitive result sets, including exactly how and how soon external updates become visible, see "Oracle Implementation of Scroll-Sensitive Result Sets".
    JDBC 2.0 DatabaseMetaData objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_SENSITIVE, or ResultSet.TYPE_SCROLL_INSENSITIVE).
    boolean othersDeletesAreVisible(int) throws SQLException
    boolean othersUpdatesAreVisible(int) throws SQLException
    boolean othersInsertsAreVisible(int) throws SQLException
    Note:
    Explicit use of the refreshRow() method, described in "Refetching Rows", is distinct from this discussion of visibility. For example, even though external updates are "invisible" to a scroll-insensitive result set, you can explicitly refetch rows in a scroll-insensitive/updatable result set and retrieve external changes that have been made. "Visibility" refers only to the fact that the scroll-insensitive/updatable result set would not see such changes automatically and implicitly.
    Visibility versus Detection of External Changes
    Regarding changes made to the underlying database by external sources, there are two similar but distinct concepts with respect to visibility of the changes from your local result set:
    visibility of changes
    detection of changes
    A change being "visible" means that when you look at a row in the result set, you can see new data values from changes made by external sources to the corresponding row in the database.
    A change being "detected", however, means that the result set is aware that this is a new value since the result set was first populated.
    With Oracle8i release 8.1.6 and higher, even when an Oracle result set sees new data (as with an external UPDATE in a scroll-sensitive result set), it has no awareness that this data has changed since the result set was populated. Such changes are not "detected".
    JDBC 2.0 DatabaseMetaData objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_SENSITIVE, or ResultSet.TYPE_SCROLL_INSENSITIVE).
    boolean deletesAreDetected(int) throws SQLException
    boolean updatesAreDetected(int) throws SQLException
    boolean insertsAreDetected(int) throws SQLException
    It follows, then, that result set methods specified by JDBC 2.0 to detect changes--rowDeleted(), rowUpdated(), and rowInserted()--will always return false with the 8.1.6 Oracle JDBC drivers. There is no use in calling them.
    Summary of Visibility of Internal and External Changes
    Table 12-1 summarizes the discussion in the preceding sections regarding whether a result set object in the Oracle JDBC implementation can see changes made internally through the result set itself, and changes made externally to the underlying database from elsewhere in your transaction or from other committed transactions.
    Table 12-1 Visibility of Internal and External Changes for Oracle JDBC
    Result Set Type Can See Internal DELETE? Can See Internal UPDATE? Can See Internal INSERT? Can See External DELETE? Can See External UPDATE? Can See External INSERT?
    forward-only
    no
    yes
    no
    no
    no
    no
    scroll-sensitive
    yes
    yes
    no
    no
    yes
    no
    scroll-insensitive
    yes
    yes
    no
    no
    no
    no
    For implementation details of scroll-sensitive result sets, including exactly how and how soon external updates become visible, see "Oracle Implementation of Scroll-Sensitive Result Sets".
    Notes:
    Remember that explicit use of the refreshRow() method, described in "Refetching Rows", is distinct from the concept of "visibility" of external changes. This is discussed in "Seeing External Changes".
    Remember that even when external changes are "visible", as with UPDATE operations underlying a scroll-sensitive result set, they are not "detected". The result set rowDeleted(), rowUpdated(), and rowInserted() methods always return false. This is further discussed in "Visibility versus Detection of External Changes".
    Oracle Implementation of Scroll-Sensitive Result Sets
    The Oracle implementation of scroll-sensitive result sets involves the concept of a window, with a window size that is based on the fetch size. The window size affects how often rows are updated in the result set.
    Once you establish a current row by moving to a specified row (as described in "Positioning in a Scrollable Result Set"), the window consists of the N rows in the result set starting with that row, where N is the fetch size being used by the result set (see "Fetch Size"). Note that there is no current row, and therefore no window, when a result set is first created. The default position is before the first row, which is not a valid current row.
    As you move from row to row, the window remains unchanged as long as the current row stays within that window. However, once you move to a new current row outside the window, you redefine the window to be the N rows starting with the new current row.
    Whenever the window is redefined, the N rows in the database corresponding to the rows in the new window are automatically refetched through an implicit call to the refreshRow() method (described in "Refetching Rows"), thereby updating the data throughout the new window.
    So external updates are not instantaneously visible in a scroll-sensitive result set; they are only visible after the automatic refetches just described.
    For a sample application that demonstrates the functionality of a scroll-sensitive result set, see "Scroll-Sensitive Result Set--ResultSet5.java".
    Note:
    Because this kind of refetching is not a highly efficient or optimized methodology, there are significant performance concerns. Consider carefully before using scroll-sensitive result sets as currently implemented. There is also a significant tradeoff between sensitivity and performance. The most sensitive result set is one with a fetch size of 1, which would result in the new current row being refetched every time you move between rows. However, this would have a significant impact on the performance of your application.
    how can i implement this using
    JDBC 2.0 DatabaseMetaData objects include the following methods to verify this. Each takes a result set type as input (ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_SENSITIVE, or ResultSet.TYPE_SCROLL_INSENSITIVE).
    boolean deletesAreDetected(int) throws SQLException
    boolean updatesAreDetected(int) throws SQLException
    boolean insertsAreDetected(int) throws SQLException

  • Unable to insert values thru SQL driver

    Hi , I am having problem regarding inserting the values in SQL server,but an exception is generated.i.e..SQLException.I hav mentioned below the code,plz look over it if there is any mistake as values not being to inserted thru url statement .
    If  any changes to be made plz mention it.
    Try
    mgr.reportWarning("starting.....");
      mgr.raiseException("ur herer",false);
         String drivername="com.sap.portal.jdbc.sqlserver.SQLServerDriver";
         Class.forName(drivername);          
    mgr.reportWarning("Driver loaded");               
    mgr.raiseException("Driver loaded",false);
          String url="jdbc:sap:sqlserver:// ... / *:*;DatabaseName=dbname";
       conn=DriverManager.getConnection(url,"username","password");
         mgr.reportSuccess("you r here");     
      Statement stmt=conn.createStatement();
      String stmt1="insert into tablename(col)".concat("values('"wdContext.currentSurveyElement().getQuestion1()"')");                                           
      //PreparedStatement pstmt=conn.prepareStatement(stmt1);
           ResultSet rs=stmt.executeQuery("insert into test""(Column1)" "values('wdContext.currentSurveyElement().getQuestion1()')");
         stmt.close();
         conn.close();
    Regards:
    hanif

    HI,
    use drivername:
    com.microsoft.sqlserver.jdbc.SQLServerDriver
    Connectiion object:
    jdbc:sqlserver://<serverhost which has the sqldriver>
    SQLEXPRESS:1433;database=<databaseName>;user=<usedname>;password=<password>
    try with this details.
    regards,
    Kathiresan R

  • Need help with INSERT and WITH clause

    I wrote sql statement which correctly work, but how i use this statment with INSERT query? NEED HELP. when i wrote insert i see error "ORA 32034: unsupported use of with clause"
    with t1 as(
    select a.budat,a.monat as period,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    c.wrbtr,
    c.matnr,
    c.menge,
    a.monat,
    c.zuonr
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='D'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,t2 as(
    select a.BUKRS,a.BELNR, a.GJAHR,t1.vtweg,t1.budat,t1.monat from t1, ldw_v1.bkpf a
    where t1.zuonr=a.xblnr and a.blart='WL' and bukrs='8431'
    ,tcogs as (
    select t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    sum(bseg.wrbtr) as COGS,bseg.matnr,bseg.kunnr,sum(bseg.menge) as QUANTITY
    from t2, ldw_v1.bseg
    where t2.bukrs=bseg.bukrs and t2.belnr=bseg.BELNR and t2.gjahr=bseg.gjahr and BSEG.KOART='S'
    group by t2.budat,t2.monat,t2.vtweg, bseg.gjahr,bseg.hkont,bseg.prctr,
    bseg.matnr,bseg.kunnr
    ,t3 as
    select a.budat,a.monat,b.vtweg,
    c.gjahr,c.buzei,c.shkzg,c.hkont, c.prctr,
    case when c.shkzg='S' then c.wrbtr*(-1)
    else c.wrbtr end as NTS,
    c.matnr,c.kunnr,
    c.menge*(-1) as Quantity
    from ldw_v1.BKPF a,ldw_v1.vbrk b, ldw_v1.bseg c
    where a.AWTYP='VBRK' and a.BLART='RV' and a.BUKRS='8431' and a.awkey=b.vbeln
    and a.bukrs=c.bukrs and a.belnr=c.belnr and a.gjahr=c.gjahr and c.koart='S'
    and c.ktosl is null and c.gsber='4466' and a.gjahr>='2011' and b.vtweg='01'
    ,trevenue as (
    select t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,
    sum(t3.NTS) as NTS,t3.matnr,t3.kunnr,sum(t3.QUANTITY) as QUANTITY
    from t3
    group by t3.budat,t3.monat,t3.vtweg, t3.gjahr,t3.hkont,t3.prctr,t3.matnr,t3.kunnr
    select NVL(tr.budat,tc.budat) as budat,
    NVL(tr.monat,tc.monat) as monat,
    NVL(tr.vtweg,tc.vtweg) as vtweg,
    NVL(tr.gjahr, tc.gjahr) as gjahr,
    tr.hkont as NTS_hkont,
    tc.hkont as COGS_hkont,
    NVL(tr.prctr,tc.prctr) as prctr,
    NVL(tr.MATNR, tc.MATNR) as matnr,
    NVL(tr.kunnr, tc.kunnr) as kunnr,
    NVL(tr.Quantity, tc.Quantity) as Quantity,
    tr.NTS as NTS,
    tc.COGS as COGS
    from trevenue TR full outer join tcogs TC
    on TR.BUDAT=TC.BUDAT and TR.MONAT=TC.MONAT and TR.GJAHR=TC.GJAHR
    and TR.MATNR=TC.MATNR and TR.KUNNR=TC.KUNNR and TR.QUANTITY=TC.QUANTITY
    and TR.VTWEG=TC.VTWEG and TR.PRCTR=TC.PRCTR
    Edited by: user13566113 on 25.03.2011 5:26

    Without seeing what you tried it is hard to say what you did wrong, but this is how it would work
    SQL> create table t ( n number );
    Table created.
    SQL> insert into t
      2  with test_data as
      3    (select 1 x from dual union all
      4     select 2 x from dual union all
      5     select 3 x from dual union all
      6     select 4 x from dual)
      7  select x from test_data;
    4 rows created.
    SQL>

  • Dealing with null values from a database (easy?)

    I'm sure this should be a simple question :
    I'm creating a dynamic dropdown of my companies products that once a product is selected draws values (links) from a database and displays them (links to User guides, FAQs etc).
    My problem is dealing with blank entries in the database - i.e. if a product doesn't have a User guide I've left the database blank.
    I'd like to show 'none' or 'not available' if the entry is blank rather than the 'null' I currently get.
    I'm sure it should be a straightforward if .... else .... but I'm struggling and would appreciate any help,
    Many thanks,
    Mo

    Thanks for the message, the cut down piece of code I'm using for the output is:
    <%
    while (rs.next())
    //header row
    out.println("<tr bgcolor='#666666'>");
    out.println("<td><font style='font-family:arial;color:#ffffff;font-size:10px;'>Product Name</font></td>");
    out.println("<td><font style='font-family:arial;color:#ffffff;font-size:10px;'>FAQs</font></td>");
    out.println("<td><font style='font-family:arial;color:#ffffff;font-size:10px;'>Technical Information</font></td>");
    out.println("</tr>");
    //results
    out.println("<tr border='1' bordercolor='#CCCCCC' bgcolor='#FFFFFF'>");
    out.println("<td><font style='font-family:arial;font-size:12px;font-weight:bold;'><a style='text-decoration:none' href=" + rs.getString("ProductURL") + " target='_blank'><font color='#669999'>" + rs.getString("ProductName") + "</a></td>");
    out.println("<td><font style='font-family:arial;color:#000000;font-size:10px;'>" + rs.getString("FAQs") + "</td>");
    out.println("<td><font style='font-family:arial;color:#000000;font-size:10px;'>" + rs.getString("TechInfo") + "</td>");
    out.println("</tr>");
    stmt.close();
    conn.close();
    %>
    It's the FAQs and TechInfo strings I need to use the statement on - if there's no entry show 'none',
    Thanks again,
    Mo

  • How to dynamically populate a listbox with the values in the database

    Hi,
    How do dynamically populate the list box with the values in the oracle database. I want to load the list box at run time.Plz anybody help me out to find a solution for this problem.
    Thanks in advance...
    Regards,
    Shiva.

    u can wite code like this..on jsp page
    <%
    ResultSet rs = stmt.executeQuery("select vender_name from vendors");
    %>
    <select name = "vendorlist">
    <%
    while(rs.next()){
    String vname = rs.getString(1);
    %>
    <option value="<%=vname%>"><%=vname%></option%>
    <%
    rs.close();
    %>

  • Help with INSERT INTO ... RETURNING ... INTO ...;

    Hi,
    I have 2 tables. In 1st one, I insert a record, and a PRE-INSERT based trigger modify value of columns CODE. I then need to insert a record in my 2nd table with the value insert in TABLE1.CODE (FK/PK). I tried to use returning clause like this :
    PROCEDURE CONVERTIR_DOCVENTE(PCODE IN CHAR) IS
    VCODE TABLE1.CODE%TYPE;
    BEGIN
    INSERT INTO TABLE1 ... RETURNING CODE INTO VCODE;
    INSERT INTO TABLE2 VALUES(VCODE);
    END;
    It does not work (ORA-00933: SQL command not properly ended at line 4)
    any idea ?
    null

    TABLE1 : CODE CHAR(10) PK,DESIG VARCHAR2(100)
    TABLE2 : CODE CHAR(10) PK,TABLE1_CODE CHAR(10) FK,DESIG VARCHAR2(100)
    Both have a sequence on CODE
    I need to insert in TABLE1 'My master record' and in TABLE2 'Child record 1' and 'Child record 2'.
    When I insert 'My master record' in TABLE 1 (INSERT into TABLE1(DESIG) values('My master record')), a trigger query my sequence and fetch CODE column. When I then insert 'Child record 1' and 'Child record 2', I need to know the value inserted in TABLE1.CODE to insert it in TABLE2.TABLE1_CODE (INSERT into TABLE2(TABLE1_CODE,DESIG) values(??????,'Child record X')). That's why I need to use RETURNING clause in the first INSERT order.
    But it doesn't works (ORA-00933: SQL command not properly ended at line 4)
    Note : All my orders are in a stored procedure.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Riaz Shahid ([email protected]):
    Hi!
    Would u clearifiy ur point please so that i can advise you. Feel free to mail me.
    Regards
    <HR></BLOCKQUOTE>
    null

  • Need Help with Inserting Timeline Markers

    Friends,
    I have not use my premiere element 3.2 since 2008 and forgot some of the procedures. now, I need help with the insertion of Timeline Markers. I did what the Help Page showed me. But the markers were not effective in the resulting DVD, or, even when viewing the video in the editing page as if thye were not there! Here is what I did:.
    1)  Click the Timeline button.
    2)  Click in an empty space in a video or audio track in the Timeline to make the Timeline active and deselect any clips.
    3)  Move the current-time indicator in the Timeline to the frame where I need the marker.
    4)  Click the Add Marker icon in the Timeline to place the Marker 5 times where I want them.
    5)  Verified that each Timeline Marker is present at the intended place.
    6)  Burned DVD
    7)  Can NOT jump to any of the intended Marker in the Resulting DVD during playback.
    The question is "What did I do wrong or didn't do?" It seems that I did the same before and worked! Please advise!
    Also, what are the significance of the Red line just below the Timeline and the yellow bars inside the video and audio frames. But after preforming Timeline/Render Work Area, they were all gone? What purposes do they serve and what is the significance of Rendering? Thank you for your help!
    I repeat the process and did a Rendering before making the DVD also. It did not help!
    Andy Lim

    Steve,
    Long time no talk! You used to help me out many times when the PE-1 through PE-3 came out. I was HOPING you would still be around and you are! You came through again this time! Many thanks to you.
    I use the Add DVD Scene button to insert the Markers. They are Green. Made a DVD and the markers work OK although ythey are "effective" during play back using the editing window.
    While that problem was solved, will you come back and answer the other two questions concerning Rendering and the Red/Yellow lines? I would appreciate it very much!
    Andy Lim
    ~~~~~~~~~~~~~~~~

Maybe you are looking for

  • N97 Fm transmitter BUG

    Hello i'm the owner of a nokia n97,laster sofware version 21.0.0.045v.I can't activate the fm transmitter.I selecte it and it asks me if i want to activate it (yes/no )but i select yes and nothing i mean nothing happens it just stays turned off is it

  • Apps crash very often. System reboots.

    Hello, Problem is that applications very often crash. The most: Safari, iBooks, GoodReader, Numbers, Pages. App closes and the system returns to the main screen, not saving the changes that took place during use of the application. Very often when pd

  • Urgent issue, BW Data extraction

    Hi,   I have an urgent issue and need help.   We were loading data after activating business content. Every thing worked fine and the delta load was also smooth.   However, in order to start everything fresh. I deleted all the info package, deleted t

  • When I try to update my iPod touch, a message saying there isn't enough space on my computer appears and all media on my iPod will be lost, should I proceed with the update?

    When I try to update my iPod touch, a message saying there isn't enough space on my computer appears and all media on my iPod will be lost, should I proceed with the update? My iTunes Library is on my computer, I have done a backup manually, and all

  • CRM upgrade Java component 7.01 needed

    Hi, Anyone could tell me where can I find the java component CD : 51035773 and 51033733. These CD's are included in the media list but I am unable to find them on service site. Any one can hep !! Thanks,