Need Sql Help

Hi , I need some help !
I have X table and some 1000 records .
Some example :Each record has ID , firstname ,lastname ,Monday,tuesday,Wed,Thurs,Fri,Sat,Sunday .
Now , Employer who works for Monday to Friday - has values in the record and Saturday ,Sunday - null values (due to off)
Now, i need sql query logic . For all the employers , Sat and Sunday values should be changed by Monday values .
Please,its kind of urgent .Hopefully my question clear .
Thanks :)

For this type of question, it is always a good idea to post:
1) CREATE TABLE statements for your table(s).
2) INSERT statements with sample data.
3) The desired result given the sample.
4) A short description of the business rules which explains why want that particular result.
5) Which version of SQL Server you are using.
This helps to clarify ambuiguities in your post and makes it simple to copy and paste into a query window to develop a tested query.
Since you said that this is urgent, I really recommend that you compose test data that covers all aspect of the problem, so that you can get a solution quickly.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Need SQL help in select data from 2 table..

    hi,
    i need some help here as i am new to sql statement
    I have 3 tables.
    Table1 :- TeamID, Team_Name, Team_Logo
    Table2:- TeamID, PlayerID
    Table3:- PlayerID, Player_Name
    How do i do a single select statement that select all information from table1 and the count of playerID from table2?
    My MS access table has relationships.
    One team can have many players. So how do it get the numbers of player in my team?
    Thanks.

    Thanks.
    but may i know why i have to max (a.team_name)???Actually there is no need of max() here, but it must be an aggregate function to use in this context. There is no harm in using it like this. This is a work around, I didn't get enough time to work on it.
    But as long as it gives correct result, don't worry about it.
    btw, how do i assign duke $$ to u?
    i am new to this forum.You can read at http://forum.java.sun.com/rewardFaq.jsp#assign
    Have a nice weekend.
    Sudha

  • Need SQL help to pull the accounts

    I have a table with account and publications(300 to 305). Each account is associated with more 1 to 5 publications. Now i want accounts that are associated with greater than or equal to 2 publications. I need your help with the SQL. Thanks.

    Maybe
    select account
      from accounts
    group by account
    having count(publication) > 1Regards
    Etbin
    Edited by: Etbin on 1.11.2011 21:59
    or
    select a.account
      from accounts a,publications p
    where a.account = p.account
    group by a.account
    having count(p.publication) > 1

  • Friends need sql help

    Dear Friends,
    I have two selects running something like this:
    select <column-names> from <table-names> where <conditions>
    union
    select <column-names> from <table-names> where <conditions>.
    there are three outer-join conditions in the first select and
    three outer joins in the second like:
    c=l(+)[in the first select]
    d=m(+)
    e=n(+)
    and
    f=l(+) [in the second select]
    g=m(+)
    h=n(+)
    The result here generates 52 rows which is correct.
    Now the case is that I am removing the union clause from the above SQL
    and converting it like this.
    select <column-names[1]>+<column-names[2]> from <table-names[1]>+<table-names[2]> where <conditions[1]>+<conditions[2]>
    but i get the error:
    same table cannot be outerjoined to two tables in the same query because i now have this
    in the new query :
    c=l(+)[from the first select]
    d=m(+)
    e=n(+)
    f=l(+) [from the second select]
    g=m(+)
    h=n(+)
    if I remove the join like:
    c=l[from the first select]
    d=m
    e=n
    f=l(+) [from the second select]
    g=m(+)
    h=n(+)
    the query executes but results into 160 rows too much of unneeded redundancy, which is wrong.
    My question is that:"Is there any way to do this? I mean to remove the union and combine the two selects into one without affecting the result of the Query which should be 52 rows only (while not affecting the joins I think this should also be the case)".
    Need your suggestions.
    Thanks,
    Vishal

    Vishal,
    What exactly are you trying to achieve? Removing/replacing the “union” is not really a goal.
    You are comparing apples with oranges here.
    select <column-names> from <table-names> where <conditions>
    union
    select <column-names> from <table-names> where <conditions>does one thing and …select <column-names[1]>+<column-names[2]> from <table-names[1]>+<table-names[2]> where <conditions[1]>+<conditions[2]>does another.
    The results set cannot even be considered equivalent since one returns X columns and the other 2*X. Even if you ignore this aspect (how could you?) and compare the number of rows returned … first query returns N+M-D1 (where N is rows returned from sql1, M is rows returned from sql2 and D1 is some number determined by the implicit distinct done by the “union”) … the second query returns N*M-D2 (that is, the Cartesian product of sql1 and sql2 minus some D2 number if sql1 and sql2 have tables in common). N+M-D1 would be equal to N*M-D2 only by fluke.
    Maybe, as Laurent put it, a concrete example with sample data and a proper stated goal are what you need to provide.

  • Need a help in SQL query

    Hi,
    I need a help in writing an SQL query . I am actually confused how to write a query. Below is the scenario.
    CREATE TABLE demand_tmp
    ( item_id  NUMBER,
      org_id   NUMBER,
      order_line_id NUMBER,
      quantity NUMBER,
      order_type NUMBER
    CREATE TABLE order_tmp
    ( item_id  NUMBER,
       org_id   NUMBER,
       order_line_id NUMBER,
       open_flag  VARCHAR2(10)
    INSERT INTO demand_tmp
    SELECT 12438,82,821,100,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,849,350,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,NULL,150,29 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,0,50,-1 FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,821,'Y' FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,849,'N' FROM dual;
    Demand_tmp:
    Item_id        org_id   order_line_id       quantity       order_type     
    12438     82                 821                 100       30     
    12438     82                 849                 350       30     
    12438     82              NULL                 150       29     
    12438     82                    0                  50       -1     
    Order_tmp :
    Item_id        org_id        order_line_id      open_flag     
    12438     82                  821                Y     
    12438     82                  849                N     I need to fetch the records from demand_tmp table whose order_line_id is present in order_tmp and having open_flag as 'Y' or if order_type in demand_tmp table is 29.
    The below query will give the records whose order line id is present in order_tmp. But, If i need records which are having order_type=29 the below query wont return any records as order_line_id is NULL. If I place outer join I will get other records also (In this example order_type -1 records) . Please help me how can we write a query for this. Expected o/p is below.
    Query :
    Select item_id,org_id,order_line_id,quantity,order_type,open_flag
    from demand_tmp dt , order_tmp ot
    where dt.order_line_id = ot.order_line_id
    AND dt.item_id=ot.item_id
    AND dt.org_id = ot.org_id
    AND ot.open_flag = 'Y';
    Expected Output :                         
    item_id     org_id     order_line_id     quantity     order_type   open_flag
    12438     82                 821               100                    30             Y
    12438     82              NULL               150                29         NULL Thanks in advance,
    Rakesh
    Edited by: Venkat Rakesh on Oct 7, 2012 6:32 PM
    Edited by: Venkat Rakesh on Oct 7, 2012 8:39 PM

    Hi Rakesh,
    the query is not working as you would like ( but IS working as expected ) since your trying to compare null to another value.
    Comparing null always results in FALSE, also if you compare null to null. This is because null means undefined.
    select 1 from dual where null=null results in no data found.
    I would suggest using a non natural key to join the tables.
    For example include a column ID in the master table which is filled with a sequence and include that field as a foreign key in the detail table.
    This way you can easily join master and detail on ID = ID, and you don't have to worry about null values in this column since it's always filled with data.
    Regards,
    Bas
    btw, using the INNER JOIN and OUTER JOIN syntax in your SQL makes it better readable, since you're separating join conditions from the where clause, just a tip ;)

  • Anybody who can help me? I really need your help

    I've tried to execute J2ee tutorial examples.
    I don't know why this sample didn't execute...I've already finished to set up J2EE and enviornment variables.
    I was trying this part from j2ee tutorial titled as "Packing Web modules".
    Whenever I type "asant create-war" to make web modules in command window. I always got error.
    Packaging Web Modules(From J2ee tutorial for your information)
    A web module must be packaged into a WAR in certain deployment scenarios and whenever you want to distribute the web module. You package a web module into a WAR using the Application Server deploytool utility, by executing the jar command in a directory laid out in the format of a web module, or by using the asant utility. This tutorial allows you to use use either the first or the third approach. To build the hello1 application, follow these steps:
    In a terminal window, go to <INSTALL>/j2eetutorial14/examples/web/hello1/.
    Run asant build. This target will spawn any necessary compilations and will copy files to the <INSTALL>/j2eetutorial14/examples/web/hello1/build/ directory.
    To package the application into a WAR named hello1.war using asant, use the following command:
    asant create-war
    This command uses web.xml and sun-web.xml files in the <INSTALL>/j2eetutorial14/examples/web/hello1 directory.
    To learn how to configure this web application, package the application using deploytool by following these steps:
    Start deploytool.
    Create a web application called hello1 by running the New Web Component wizard. Select FileNewWeb Component.
    In the New Web Component wizard:
    Select the Create New Stand-Alone WAR Module radio button.
    In the WAR File field, enter <INSTALL>/j2eetutorial14/examples/web/hello1/hello1.war. The WAR Display Name field will show hello1.
    In the Context Root field, enter /hello1.
    Click Edit Contents to add the content files.
    In the Edit Contents dialog box, navigate to <INSTALL>/j2eetutorial14/examples/web/hello1/build/. Select duke.waving.gif, index.jsp, and response.jsp and click Add. Click OK.
    Click Next.
    Select the No Component radio button and click Next.
    Click Finish.
    Select FileSave.
    A sample hello1.war is provided in <INSTALL>/j2eetutorial14/examples/web/provided-wars/. To open this WAR with deploytool, follow these steps:
    Select FileOpen.
    Navigate to the provided-wars directory.
    Select the WAR.
    Click Open Module.
    I guess this step is for checking my system about setup information. I not sure how to change it.
    the result from execution of ansnt command in dos
    D:\J2ee\j2ee-1_4-doc-tutorial_7\j2eetutorial14\examples\web\hello1>asant create- war Buildfile: build.xml
    j2ee-home-test:
    BUILD FAILED D:\J2ee\j2ee-1_4-doc-tutorial_7\j2eetutorial14\examples\common\targets.xml:10: T he j2ee.home property is not properly set in <INSTALL>/j2eetutorial14/examples/c ommon/build.properties.
    Set the j2ee.home property to the location of your Application Server installati on.
    On Windows, you must escape any backslashes in the j2ee.home property with anoth er backslash or use forward slashes as a path separator. So, if your Application Server installation is C:\Sun\AppServer, you must set j2ee.home as follows:
    j2ee.home = C:\\Sun\\AppServer
    or
    j2ee.home=C:/Sun/AppServer
    j2ee.home is currently set to:
    Total time: 0 seconds
    D:\J2ee\j2ee-1_4-doc-tutorial_7\j2eetutorial14\examples\web\hello1>
    I've installed J2ee sdk in C:\Sun\AppServer
    PATH: %J2EE_HOME%\bin;%JAVA_HOME%\bin;
    CLASSPATH: %J2EE_HOME%\lib\j2ee.jar;C:\Java\jre1.6.0_05\lib\ext\QTJava.zip;C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
    J2EE_HOME: C:\Sun\AppServer
    JAVA_HOME: C:\Sun\AppServer\jdk
    I've installed J2ee with administration 4848, HTTP: 8089 HTTP: 8090
    I guess this could refer the target.xml and build.properties. So, I've tried after changing some value, which is fit for my setup.
    but, still doesn't work.
    targets.xml
    <path id="classpath">
    <fileset dir="${j2ee.home}/lib">
    <include name="j2ee.jar"/>
    </fileset>
    </path>
    <target name="j2ee-home-test" >
    <!-- Test if j2ee.home is set properly by looking for j2ee.jar -->
    <available file="${j2ee.home}/lib/j2ee.jar" type="file" property="j2ee.jar.present" />
    <fail unless="j2ee.jar.present">
    The j2ee.home property is not properly set in <INSTALL>/j2eetutorial14/examples/common/build.properties.
    Set the j2ee.home property to the location of your Application Server installation.
    On Windows, you must escape any backslashes in the j2ee.home property with another backslash or use forward slashes as a path separator. So, if your Application Server installation is C:\Sun\AppServer, you must set j2ee.home as follows:
    j2ee.home = C:\\Sun\\AppServer
    or
    j2ee.home=C:/Sun/AppServer
    j2ee.home is currently set to: ${j2ee.home}
    </fail>
    </target>
    <target name="clean" >
    <delete dir="${build}" />
    <delete dir="${dist}" />
    <delete dir="${assemble}" />
    <delete file="${ear.name}" />
    <delete file="${war.name}" />
    <delete file="${war.file}" />
    <delete file="${client.jar.name}" />
    </target>
    <path id="db.classpath">
    <fileset dir="${db.root}/lib">
    <include name="*.jar"/>
    </fileset>
    </path>
    <target name="create-db_common"
    depends="init,start-db,delete-db"
    description="Create database tables and populate database." >
    <sql driver="${db.driver}"
    url="${db.url}"
    userid="${db.user}"
    password="${db.password}"
    classpathref="db.classpath"
    delimiter="${db.delimiter}"
    autocommit="false"
    onerror="abort" >
    <transaction src="${sql.script}"/>
    </sql>
    </target>
    <target name="delete-db"
    description="Deletes the database tables." >
    <sql driver="${db.driver}"
    url="${db.url}"
    userid="${db.user}"
    password="${db.password}"
    classpathref="db.classpath"
    delimiter="${db.delimiter}"
    autocommit="false"
    onerror="continue" >
    <transaction src="${delete.sql.script}"/>
    </sql>
    </target>
    <target name="ping-db"
    description="Checks to see if Derby is running." >
    <java classname="org.apache.derby.drda.NetworkServerControl"
    fork="yes"
    resultproperty="db.ping.result">
    <jvmarg line="${db.jvmargs}" />
    <arg line="ping" />
    <classpath refid="db.classpath" />
    </java>
    <condition property="db.running">
    <equals arg1="${db.ping.result}" arg2="0" />
    </condition>
    </target>
    <target name="start-db"
    unless="db.running"
    description="Starts the Derby databse server."
    depends="ping-db">
    <sun-appserv-admin
    explicitcommand="start-database" />
    </target>
    <target name="stop-db"
    description="Stops the Derby database server."
    depends="ping-db"
    if="db.running">
    <sun-appserv-admin
    explicitcommand="stop-database" />
    </target>
    <target name="admin_command_common">
    <echo message="Doing admin task ${admin.command}"/>
    <sun-appserv-admin
    command="${admin.command}"
    user="${admin.user}"
    passwordfile="${admin.password.file}"
    host="${admin.host}"
    port="${admin.port}"
    asinstalldir="${j2ee.home}" />
    </target>
    <target name="create-jdbc-resource_common">
    <antcall target="admin_command_common">
    <param name="admin.command"
    value="create-jdbc-resource
    --connectionpoolid ${conpool.name} ${jdbc.resource.name}" />
    </antcall>
    </target>
    <target name="delete-jdbc-resource_common">
    <antcall target="admin_command_common">
    <param name="admin.command"
    value="delete-jdbc-resource ${jdbc.resource.name}" />
    </antcall>
    </target>
    <target name="deploy-war">
    <antcall target="admin_command_common">
    <param name="admin.command"
    value="deploy ${war.file}" />
    </antcall>
    </target>
    <target name="undeploy-war">
    <antcall target="admin_command_common">
    <param name="admin.command"
    value="undeploy ${example}" />
    </antcall>
    </target>
    <property environment="env" />
    <target name="listprops"
    description="Displays values of some of the properties of this build file">
    <property file="../../common/admin-password.txt" />
    <echo message="Path information" />
    <echo message="j2ee.home = ${j2ee.home}" />
    <echo message="j2ee.tutorial.home = ${j2ee.tutorial.home}" />
    <echo message="env.Path = ${env.Path}" />
    <echo message="env.PATH = ${env.PATH}" />
    <echo message="" />
    <echo message="Classpath information" />
    <echo message="classpath = ${env.CLASSPATH}" />
    <echo message="" />
    <echo message="Admin information" />
    <echo message="admin.password = ${AS_ADMIN_PASSWORD}" />
    <echo message="admin.password.file = ${admin.password.file}" />
    <echo message="admin.host = ${admin.host}" />
    <echo message="admin.user = ${admin.user}" />
    <echo message="admin.port = ${admin.port}" />
    <echo message="https.port = ${https.port}" />
    <echo message="" />
    <echo message="Domain information" />
    <echo message="domain.resources = ${domain.resources}" />
    <echo message="domain.resources.port = ${domain.resources.port}" />
    <echo message="" />
    <echo message="Database information" />
    <echo message="db.root = ${db.root}" />
    <echo message="db.driver = ${db.driver}" />
    <echo message="db.host = ${db.host}" />
    <echo message="db.port = ${db.port}" />
    <echo message="db.sid = ${db.sid}" />
    <echo message="db.url = ${db.url}" />
    <echo message="db.user = ${db.user}" />
    <echo message="db.pwd = ${db.pwd}" />
    <echo message="url.prop = ${url.prop}" />
    <echo message="ds.class = ${ds.class}" />
    <echo message="db.jvmargs = ${db.jvmargs}" />
    </target>
    build.properties ����
    j2ee.home=
    j2ee.tutorial.home=
    asinstall.dir=${j2ee.home}
    admin.password.file=${j2ee.tutorial.home}/examples/common/admin-password.txt
    admin.host=localhost
    admin.user=admin
    admin.port=4848
    https.port=8181
    domain.resources="domain.resources"
    domain.resources.port=8080
    # Derby configuration settings
    db.delimiter=;
    db.root=${j2ee.home}/derby
    db.driver=org.apache.derby.jdbc.ClientDriver
    db.datasource=org.apache.derby.jdbc.ClientDataSource
    db.host=localhost
    db.port=1527
    db.sid=sun-appserv-samples
    db.url=jdbc:derby://${db.host}:${db.port}/${db.sid};create=true;
    db.user=APP
    db.pwd=APP
    db.jvmargs=-ms16m -mx32m
    Is there anyone who can tell me how to change it? I really need your help....
    Thank you in advance.

    ok,
    First of all make sure your tutorial folder is installed from the root:
    C:\javaeetutorial5
    or
    D:\javaeetutorial5
    it makes things so simple.
    Secondly:
    set your jee tutorial home
    JAVAEE.TUTORIAL.HOME =
    C:/javaeetutorial5
    Thirdly: check in:
    C:\javaeetutorial5\examples\bp-project
    make a copy of the build.properties.sample save it as build.propropties, as a property file,
    edit the properties file as in:
    build.properties
    As follows:
    # uncomment the property javaee.home, and add the path
    # to your GlassFish Java EE 5 SDK installation
    javaee.home=c:/Sun/SDK
    javaee.tutorial.home=c:/javaeetutorial5
    # Uncomment the property j2ee.server.username,
    # and replace the administrator username of the app-server
    javaee.server.username=admin
    # Uncomment the property j2ee.server.passwordfile,
    # and replace the following line to point to a file that
    # contains the admin password for your app-server.
    # The file should contain the password in the following line:
    AS_ADMIN_PASSWORD=admin1234and so fourth. Some of the settings as the application server name is all done for you
    and then test it again.
    Take care of editing the property file. It can give you headache.
    Note also that this is for application server 9.1 - JEE5.
    eve

  • PIVOT sql help

    Hi again
    I need some PIVOT sql help
    In this query:
    SELECT
    SUM([RATES]) as RATES
    ,SUM([CONVERSION])as CONVERSION
    FROM REPORTING
    outputs
    RATES CONVERSION
    23 234
    How would change this query to display a table like:
    Name Amount
    RATES 23
    CONVERSION 234
    Keep up the good work !

    nikos101 wrote:
    > How would change this query to display a table like:
    Do you *HAVE* to change the query... you could just display
    it in the
    desired format if that it the ultimate and only goal.
    <table>
    <tr>
    <td>name</td>
    <td>amount</td>
    </tr>
    <cfoutput query="sumQry">
    <tr><td>Rates</td><td>#rates#</td></tr>
    <tr><td>Conversion</td><td>#conversion#</td></tr>
    </cfoutput>
    </table>

  • SQL help please. !!!!!!!!!!

    hi
    i need some help on the following problem. let's say i have a sql select that return the following rows
    ME
    EL
    EO
    FA
    these are 4 rows of data returned by executing "select column1 from myTable where somecondition = true". however, i need to display these results as follow
    MW,EL,EO,FA
    which is just one row and they are concatenated as one result. is there any way to modify the sql to do it? your help is much appreciated. thanks

    hi
    i need some help on the following problem. let's say i
    have a sql select that return the following rows
    ME
    EL
    EO
    FA
    these are 4 rows of data returned by executing "select
    column1 from myTable where somecondition = true".
    however, i need to display these results as follow
    MW,EL,EO,FA
    which is just one row and they are concatenated as one
    result. is there any way to modify the sql to do it?
    your help is much appreciated. thanksit would be easier if you ahead know how many rows you going to get...
    select
    "row1" = select blah from table where blah = '1',
    "row2" = select blah from table where blah = '2',
    "row3" = select blah from table where blah = '3',
    "row4" = select blah from table where blah = '4'
    from table
    make sure the sub select must return one record only...

  • SQL help: Selecting tickets with no open tasks

    Hi Gurus,
    I'm new to SQL. I need your help in a script where I need to fetch the tickets with no open tasks.
    Say, following is the Task table
    Table: Task
    | ticketid | taskid | taskstatus |
    | 1 | 1 | O |
    | 1 | 2 | O |
    | 1 | 3 | O |
    | 2 | 4 | C |
    | 2 | 5 | C |
    | 3 | 6 | C |
    | 3 | 7 | O |
    The query should return the ticketid(s) with all its taskstatus = 'C'.
    Any help would be highly appreciated.
    Thanks

    Hi Surya,
    Here's an Oracle style example (Sorry, I just can't do that ansi stuff)
    SQL> with ticket as (select 1 ticketid, 'C' reason from dual union all
                    select 2 ticketid, 'O' reason from dual union all
                    select 3 ticketid, 'O' reason from dual union all
                    select 4 ticketid, 'C' reason from dual)
    ,taskstatus as (select 1 taskstatusid, 'O' taskstatus from dual union all
                    select 2 taskstatusid, 'C' taskstatus from dual union all
                    select 3 taskstatusid, 'P' taskstatus from dual union all
                    select 4 taskstatusid, 'F' taskstatus from dual union all
                    select 5 taskstatusid, 'O' taskstatus from dual union all
                    select 6 taskstatusid, 'C' taskstatus from dual union all
                    select 7 taskstatusid, 'P' taskstatus from dual union all
                    select 8 taskstatusid, 'F' taskstatus from dual)
          ,task as (select 1 ticketid,  1 taskid, 2 taskstatusid from dual union all
                    select 1 ticketid,  2 taskid, 3 taskstatusid from dual union all
                    select 1 ticketid,  3 taskid, 4 taskstatusid from dual union all
                    select 1 ticketid,  4 taskid, 4 taskstatusid from dual union all
                    select 2 ticketid,  5 taskid, 1 taskstatusid from dual union all
                    select 2 ticketid,  6 taskid, 1 taskstatusid from dual union all
                    select 2 ticketid,  7 taskid, 1 taskstatusid from dual union all
                    select 3 ticketid,  8 taskid, 2 taskstatusid from dual union all
                    select 3 ticketid,  9 taskid, 2 taskstatusid from dual union all
                    select 3 ticketid, 10 taskid, 6 taskstatusid from dual union all
                    select 4 ticketid, 11 taskid, 2 taskstatusid from dual union all
                    select 4 ticketid, 12 taskid, 6 taskstatusid from dual union all
                    select 4 ticketid, 13 taskid, 4 taskstatusid from dual union all
                    select 4 ticketid, 14 taskid, 8 taskstatusid from dual)
    select a.ticketid, c.taskstatus
      from  task a, ticket b, taskstatus c
    where a.ticketid = b.ticketid
       and c.taskstatusid = a.taskstatusid
       and (c.taskstatus = 'C' or c.taskstatus = 'F')
       and b.reason = 'C'     
       and not exists (select null
                         from task a1, taskstatus c1
                        where a1.ticketid = a.ticketid
                          and c1.taskstatusid = a1.taskstatusid
                          and (c1.taskstatus = 'O' or c1.taskstatus = 'P'))
    order by 1,2
      TICKETID T
             4 C
             4 C
             4 F
             4 F
    4 rows selected.Please note, how I made test data, that way is much more helpful than your tables
    Regards
    Peter

  • Need small help

    Hi,
    I need small help in sql*loader.I get data-files which has a particular identified on the 1st record( header ), based on which I've to load a constant for the 1st column of every row. How do I set in the control file.
    Appreciate if someone can give me directions on this.
    Thanks in advance,

    Hi again!
    I hope that a little shell script will do the thing for you.
    1.) Create the following BASH-Script
    #!/bin/bash
    export CUSTNO=""
    export CUSTNO=$(awk -F"," '{print NR " " $3}' datafile.csv | grep 1 | cut -d" " -f2)
    sed -i 's/#x#/'$CUSTNO'/g' controlfile.datI've use datafile.csv as the name of the datafile to load and controlfile.dat as the name of your controlfile. Please change this to fit your needs.
    This script looks for the occurrence of your constant value and stores this value in the variable CUSTNO. Then it look for a string #x# in your controlfile and changes #x# to the value of CUSTNO.
    So in your controlfile there should be a line for custno like that:
    custno                     CONSTANT '#x#'This line will be replace in your example to:
    custno                     CONSTANT '35642'To get this to work I assume that:
    1.) Your constant value is always at the third position in the header of your datafile.
    2.) You've made the change with #x# in your controlfile.
    I hope that this is really usefull to you.
    Best Regards
    Florian W.

  • We have a set of oracle clients running on T5220 zones that need some help

    Greetings all -
    We have a set of oracle clients running on T5220 zones that need some help.
    If, for example, I execute the query "select (all) from dba_objects", trace output reports 90% of the elapsed time spent under "SQLNet message from client".
    Here are OS details for the clients: Solaris 10 5/08 s10s_u5wos_10 SPARC
    Running "uname -a" from the client gives:
    (SunOS bmc-ste-app 5.10 Generic_127127-11 sun4v sparc SUNW,SPARC-Enterprise-T5220)
    Here are OS details for the dataserver: Enterprise Linux Enterprise Linux Server release 5.2
    Running "uname -a" from the dataserver gives:
    (2.6.18-92.1.6.0.2.el5 #1 SMP Thu Jun 26 17:44:55 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux)
    The RDBMS is 10.2.0.4
    Again, please note, there is no application in the picture here. We are just running a simple catalog query (select * from dba_objects) from sqlplus. Why the wait on something like this? The wait also occurs when a different query is used (select (all) from SYS.COL$ where rownum < 50000). And it doesn't matter if I used the full client or the instant client. I still get the same high-wait.
    We had thought - maybe this is a network thing - so we put a test client on the same subnet as the dataserver. This helped - but not enough. The wait is still way too high even with firewalls taken out of the equation.
    We've also looked at arraysize, SDU, kernel settings. And we've spent time going over tkprof, truss and sqlnet-tracing.
    Has anyone ever had to solve this HIGH WAIT ON CLIENT issue? Is there a work around or some tweak I'm missing.
    Is anyone configured like we are (linux dataserver, solaris clients)? If so - did you see anything like this?
    tia -
    Jim
    Edited by: jim1768 on Mar 31, 2010 1:47 PM
    Edited by: jim1768 on Mar 31, 2010 2:12 PM
    Edited by: jim1768 on Mar 31, 2010 2:13 PM

    Hello,
    We have the exact same issue. Did you ever solve this issue? We have a t5220 and have just upgraded our 11.5.10.2 11i system on it from 9.2.0.8 32-bit sparc to 11.2.0.1 64-bit sparc. Things should be faster but arent, and our consultant has tracked it down to high wait times when the apps tier using forms connects to the database tier on the same box. So even though the t5220 is both server and client, there is something about the client sql connection.through TNS that his having trouble. Thanks for any information. We've also created an S/R with Oracle.
    Note: I am well aware of the other issues with the CMT server series but this particular issue seems independent of the regular / known issues and remains a mystery to us. Other known issues with the CMT servers for SPARC:
    Metalink Note 781763.1 (Migration from fast single threaded CPU machine to CMT UltraSPARC T1 & T2)
    http://blogs.sun.com/glennf/resource/Optimizing_Oracle_CMT_v1.pdf
    http://blogs.sun.com/glennf/tags/throughput
    http://blogs.sun.com/glennf/entry/getting_past_go_with_sparc
    http://www.oracle.com/apps_benchmark/doc/E-Bus-11i-PAY_ORA_SUN-T5220.pdf (this paper has some oracle init settings at the end. The kernel settings have been included in the OS upgrade)
    http://blogs.sun.com/mandalika/entry/siebel_on_sun_cmt_hardware

  • Need urgent help in listing out checklist from DBA prespective for BI Implementation Project

    Hello Guys,
    We are in Designing phase Data Modeling of PDW/APS Implementation Project.
    I need urgent help in making a checklist from a DBA perspective.
    Like what are things ill be needing at a time of implementation/Deployment.
    Your expert comments and help will be highly appreciated.
    Thank you,
    Anish.S
    Asandeen

    You can get good summary of checklist from this article about
    DBA checklist for data warehousing.
    Which highlights on below pointers:
    New system or old. (I.e. Up-gradation vs starting from scratch)
    Complexity of SQL Server architecture 
    SQL Server storage
    Determining SQL Server processing power
    SQL Server installation consideration 
    SQL Server configuration parameter
    SQL Server security
    SQL Server Database property
    SQL Server jobs and automation
    Protecting SQL Server data
    SQL Server health monitoring and check ups
    SQL Server ownership and control 
    based on my real time experience, I will suggest you to keep an eye on 
    Load performance (It will be useful when your database(Warehouse) will have huge amount of data)
    System availability (Check for Windows update and up time configuration) 
    Deployment methodology should be planned in advance. Development of packages and respective objects should be done systematically.
    Source control mechanism 
    Disk space and memory usage
    You might or might not have full rights on production environment, so be prepared to analyze production environment via Select statements [I guess you got my point]
    Proper implementation of Landing , Staging and Mart tables.
    Column size (this can drastically decrease your database size)
    Usage of indexes (Index are good, but at what cost?)
    I hope this will assist you in building your check list.

  • Loading external (PDF)file into BLOB colum in the table.  Need urgent help.

    Hi All,
    I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
    Regards,
    Trang

    Once the PDF file is inserted in the PDM table, i am not able to read the PDF data from the below code, This code converts the binary data into the Character data i.e BLOB data into the CLOB, but still the data is not proper which is getting inserted PDF is proprietary format of Adobe. And you cant just read it from pl/sql. You need Adobe software installed in your client machine to view it.
    Here is an example of how to do it.
    [url http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006] Display PDF Stored in Database from ASKTOM 

  • Need some help with color on a column.

    Hello
    I need some help on how I can set the color on either column header or the whole column.
    I have a report with where the first row display a total sum. The rows under that are htmldb_item.text where the user may input some values.
    The sum of these textboxes should match the the total column on top. If it does not match then the header or column should be marked red.
    I have one pl/sql prosess where i check this, and i return a message for that column, can I in this prosess set the column color for the report?
    report looks like this
    total1----total2----total3....
    box1-----box2-----box3....
    box1-----box2-----box3....
    box1-----box2-----box3....
    box1-----box2-----box3....
    so if the sum of all the box1s do not match total1 then column or header is red.
    thanks,
    Anders

    Hi Anders,
    have a look at Carls example: http://htmldb.oracle.com/pls/otn/f?p=11933:7:3740381051529350
    It works with row template, but maybe you can change it for working with column templates.
    chrissy

  • Need some help with computation

    Hi, I need some help with the following:
    My page 3 is a form thats shows, among other things, a document ID (:P3_DOC_ID). Next to this item I have created a button that calls a document selection form (page 10).
    On selection this forms sets 2 items:
    P10_SELECTED (Y or N)
    P10_DOC_ID (the selected documents ID value)
    When the user selects a document he returns to the calling form.
    On page 3 I now try to capture the selected values. For a test item I managed to do this by defining this items source as:
    [PL/SQL function body]
    begin
    if V('P10_SELECTED') = 'Y'
    then
    return V('P10_DOC_ID'); -- selected value
    else
    return V('P3_TEST'); -- else the original value
    end if;
    end;
    However I want P3_DOC_ID to capture the selected value. I tried using a computation but that did not work. Any ideas?
    thanks Rene

    You might want to check if the "Source Used" attribute for P3_DOC_ID is set to always or to "only when ..." it sounds like you need it set to "only when ..."
    If that does not work try this
    Place the following in a pl/sql anonymous block and turn off your
    computation.
    if :P10_SELECTED = 'Y'
    then
    :P3_DOC_ID := :P10_DOC_ID; -- selected value
    else
    :P3_DOC_ID := :P3_TEST; -- else the original value
    end if;
    Justin

Maybe you are looking for

  • HTMLDB_APPLICATION.G_F01 has wrong value!

    HTMLDB_APPLICATION.G_F01 has wrong value! Hello again, I have a search page in my app (here the user defines the search criteria) P1. The page branches to P130, where the result is shown. This second page contains a region of type 'SQL Query (PL/SQL

  • Brand new iphone 4 with 0 bytes of storage

    I just bought a new iPhone 4 with 8G of storage but prior to any restoring, 6.4 GB are already used and 0 bytes are available. This is silly, I can't even take a picture. Can someone tell me how to free up that space? Keep in mind it has no music, vi

  • Xbox and 5.1 so

    I have creative Inspire 5200 5. speakers and the Sound Blaster Audigy 2 ZS Platinum Pro. Using the xbox advanced av pack, I have connected an optical spdif from the xbox to the optical in on the front of the external I/O hub. I have tried numerous se

  • Timer option changed to 'Stop Playing' from 'Sleep iphone'. Any idea on how to get the Sleep ipone.

    In the iPhone 4S under the Timer, for the Option, When 'Timer Ends' it used to be a 'Sleep iphone'. After the iOS 5.1 update, I think, it is now changed to 'Stop Playing', which only stops the Music. Any idea how to - put the phone to Sleep mode.

  • Plant  to Plant trasfer with valution

    Hi Dear I have very urgent requirment We Have scenrio Let say we have 2 plant , Plant A and Plant B I rasie PO in plant A , material BANANA with quantity 1 @ 10 After that i did GRN in Plant A Immidialty in trasfer  all this material to Plant B So va