Help in PL/SQL

Hello
I have a doub whether the following is possible with PL/SQL
We have a oracle application which stores the data in the DB. We are having a request to transfer a part of this application's data to another applcation which takes care of the finances.
For that we need
1. To create a table that picks data from the DB
2. Put it in a file and
3. Filename has a sequence number – to make sure no files are missed, and files are not processed twice.
4. To have file header contains a batch number – to make sure a batch is not processed twice, and is in sequence, and that the filename has not been changed
5.create checksum for the file
6.finally to transfer the file.
Could you help me to know how to create file in PL/SQL and to create header records, sequence number generation ?
Thanks.

>I have a doub whether the following is possible with PL/SQL
An offensive comment to PL/SQL.. or you do not know PL/SQL at all.
I would not use UTL_FILE.
I would create the entire file as a CLOB (column in a table). Which means the file contents are subject to database security, audting, concurrency, archiving, and all the other good stuff.
I would not create the file directly on the o/s alone. Where it can be accidentally deleted from the o/s by nobody (something which I have seen happening more than once).
Thus I will construct the file as a CLOB and keep it as the master copy. For the file transfer, whether an actual o/s file copy is created depends on whether the transfer is a push or a pull. If a push, I would not even bother writing the CLOB to a physical o/s file - I will push it inside PL/SQL using FTP or HTTP.
If a pull.. if the pull is HTTP, then again PL/SQL wil be used (via MOD_PLSQL) and no physical o/s file will be created. If the pull is FTP or SFTP, then an o/s file may need to be created. But I would first consider using XMLDB for that and the raw FTP session interface - which means the controls are all Oracle and Oracle listener based, with no reliance on o/s utilities and o/s security, and fully portable to any Oracle platform.
I have my doubts if there are anything (in the realm of standard business IS needs) that cannot be done in Oracle.. and PL/SQL.

Similar Messages

  • Help Needed in SQL QPAC

    Hi there,
    I need some help regarding the SQL QPAC which is a built in QPAC in Adobe Livecycle Workflow. The SQL QPAC takes MYSQL as the default database. Suppose if we need to connect to the SQL Server or any other database, what is the procedure to do that.
    Suraj

    Hi Suraj
    You need to deploy a second copy of the SQL QPAC, and point it at a different datasource. The datasource is defined as a deployment parameter (it will prompt you when you deploy the new version of the qpac).
    You will also need to define the datasource in your application server. This is done in different ways for different application servers - for details, please see: standards_based_qpacs.pdf (part of the Workflow SDK), page 12, "Creating a JNDI datasource".
    Alternately, you can try out our SQLPlus QPAC. This allows you to directly specify connection url, driver, username and password. The SQLPlus QPAC does a lot of other things that the regular SQL QPAC doesn't do, such as handling multiple rows, testing your query, and outputting the data in a variety of ways.
    Details at: http://www.avoka.com/avoka/qpac_library.shtml
    Howard

  • Help with an SQL Query on the Logger

    We are running UCCE 8.5(3) and need help with an SQL query. When I run the below I would also like to see skill group information(name preferably)? Any help would be greatly appreciated!
    select * from dbo.t_Termination_Call_Detail where DateTime between '10-11-2012 00:00:00:00' and
    '10-11-2012 23:59:59:59'

    David, thanks for replying.  Unfortunitly I don't know enough about SQL to put that into a query and have it return data.  Would you be able to give an example on what the query would look like?

  • Help: APEX - PL/SQL Function

    Hello,
    i need some help with a SQL statement.
    I have the follwing Table "TABF":
    ID Number,
    B_Number varchar2(10),
    G_Type varchar2(10),
    Site varchar2(50),
    Event varchar2(50),
    Date varchar(10),
    Dataset varchar2(50),
    Mode varchar2(50),
    Topic varchar2(10),
    Parameter varchar2(10),
    Value varchar2(10)The table is filled with records which, like this:
    B Number | G-Type |Site       |Event  |Date     | Dataset   | Mode    | Topic    | Parameter | Value
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 73,9015 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,6951 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,71 
    800257   |   4.2  |  USA      | Test  |18.08.08 | Post      |MBA      | Field    | F_C       | 73,7526 
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 4,5170 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,6074 
    800257   |   4.2  |  England  | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,62 
    800257   |   4.2  |  England  | Test  |18.08.08 | Post      |MBA      | Field    | F_H       | 24,4717  Now im looking for a SELECT statement or better a function that returns a SELECT under the following condition:
    If B_Number and Event and Date and Dataset are equal, then add 3 additional columns (Topic2, Paramter2, Value2) at the first aquivalent entry.
    Then the row can be delete/ignored. If there will be another record where B_Number,Event, Date are equal to a row above then Topic3, Paramter3 and Value 3 should be added as a new column at the first record where the conditions equals.
    And so on.....
    The result should look like this for the example above:
    B Number | G-Type |  Site     |Event  |Date     | Dataset   | Mode    | Topic    |Parameter   | Value    | Topic2   |  Parameter2  | Value2
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 73,9015  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,6951  | Field    | F_H          | 24,6074
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,71    | Field    | F_H          | 24,62 
    800257   |    4.2 |  USA      | Test  |18.08.08 | Post      | MBA     | Field    | F_C        | 73,7526  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 4,5170   | -        | -            | -
    800257   |    4.2 |  England  | Test  |18.08.08 | Post      | MBA     | Field    | F_H        | 24,4717  | -        | -            | -Hope you understand my problem and some1 can help me.
    Thank you
    Regards
    Chris
    Edited by: user11369135 on 09.07.2009 00:50

    user11369135 wrote:
    Hello,
    i need some help with a SQL statement.
    I have the follwing Table "TABF":
    Now im looking for a SELECT statement or better a function that returns a SELECT under the following condition:
    If B_Number and Event and Date and Dataset are equal, then add 3 additional columns (Topic2, Paramter2, Value2) at the first aquivalent entry.
    Then the row can be delete/ignored. If there will be another record where B_Number,Event, Date are equal to a row above then Topic3, Paramter3 and Value 3 should be added as a new column at the first record where the conditions equals.
    And so on.....
    Edited by: user11369135 on 09.07.2009 00:50if I understand correctly then you want a simple GROUP BY on B_number, Event, Date and Dataset.
    But you want additionaly show 3 columns from one of the rows that was grouped.
    This can be done using the little known KEEP syntax.
    Documentation: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#sthref1389
    Example from the docs
    Aggregate Example
    The following example returns, within each department of the sample table hr.employees, the minimum salary among the employees who make the lowest commission and the maximum salary among the employees who make the highest commission:
    SELECT department_id,
    MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) "Worst",
    MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct) "Best"
       FROM employees
       GROUP BY department_id;
    DEPARTMENT_ID      Worst       Best
               10       4400       4400
               20       6000      13000
               30       2500      11000
               40       6500       6500
               50       2100       8200
               60       4200       9000
               70      10000      10000
               80       6100      14000
               90      17000      24000
              100       6900      12000
              110       8300      12000
                        7000       7000

  • Help on java.sql.Types class

    Hai Friends ,
    I want some help on java.sql.Types class .
    What is the use of the above class ?
    Some details about this class.

    Good Morning Yekesa
    First of all i would like to thank U for looking into my problem.
    I am using java.sql.Types.OTHER for
    {"?=CALL(storedprocedurename.functionname(?))"}
    registerOutParameter(1,javal.sql.Types.OTHER)
    setString(2,"user")
    here the
    second parameter passes an argument to function name ( viz. username say "user")
    and the function will return the ref cursor as follows:
    // declaration in pl/sql procedure
    begin
    rc ref cursor
    open rc for select * from ss_user where login_name="user";
    return rc;
    end
    now the stored procedure has a return value (i.e. stored function) which it needs to register as
    registerOutParameter(1,javal.sql.Types.OTHER)
    and it finally results in the following errors :
    Loading driver
    Before conn stmt
    After conn stmt
    Calling Stored procedure
    Stored procedure called
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:243)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:2487)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:64)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:54)
    at sptest.<init>(sptest.java:28)
    at sptest.main(sptest.java:49)
    T couldn't understand why it is saying Invalid Column Type because its working fine with both
    java.sql.Types.INTEGER
    and
    java.sql.Types.VARCHAR
    Pl help me at the earliest as i have wasted a lot of time on it.
    pl mail me in detail at [email protected]
    bye then
    bansi
    null

  • Help in designing SQL

    Hi All,
    I need little help in designing SQL. My input and output data is given below:
    Input
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    4/25/2011 3:36:19 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    Output
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/25/2011 5:55:55 PM
    Here out of 2nd and third record of input, output is 2nd record of output and 5th and 6th record of input would come out as  4th record of output. Basically, if we overlapping duration between Date_1 and Date_2, we need to take min of Date_1 and max of Date_2 for that overlapping records. In case of no overlapping, we would simply output input record like  record 1 and 4 of input.
    Out of
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    4/25/2011 3:36:19 PM
    2/24/2011 1:48:07 PM was  min of above 2 and 5/24/20114:50:16 was max of above 2.
    Similarly in other overlapping scenario:
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    6/16/2011 3:25:42 PM  was min of above 2 and 6/25/2011 5:55:55 PM was max of above 2.
    Pls help.
    Thanks.

    Hi Frank.,
    The above logic with NVL is not working.
    My input sample is:
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    I am giving create and insert statement below for creation of above data. Please see if you can help me:
    CREATE TABLE test1
      KEY1          NUMBER     ,   
      DATE_1               DATE ,          
      date_2              DATE
    insert into test1
    values(1, TO_TIMESTAMP ('2/14/2011 5:22:35 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('2/22/2011 3:05:13 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('2/24/2011 1:48:07 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('5/24/2011 4:50:16 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('2/24/2011 1:48:59 PM', 'MM/DD/YYYY HH:MI:SS AM'), '' ) ;
    values(1, TO_TIMESTAMP ('5/24/2011 5:18:19 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/16/2011 3:17:40 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('6/16/2011 3:25:42 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/24/2011 1:33:13 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('6/17/2011 1:12:54 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/25/2011 5:55:55 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    commit;
    Expected output would be:
    Output
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/25/2011 5:55:55 PM
    Thanks....

  • Help needed for SQL query

    hello ,
    I am a beginner in terms of writing sql queries. I hope some body can help me out.
    I have two tables
    mysql> desc user_group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | userAccountId | char(8) | | PRI | | |
    | groupId | char(8) | | PRI | | |
    ---------------------------------------------------+
    2 rows in set (0.00 sec)
    mysql> desc group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | id | char(8) | | PRI | | |
    | name | char(50) | YES | | NULL | |
    | email | char(100) | YES | | NULL | |
    | description | char(254) | YES | | NULL | |
    | parentId | char(8) | YES | | NULL | |
    | creatorId | char(8) | YES | | NULL | |
    | createDate | char(20) | YES | | NULL | |
    | updateDate | char(20) | YES | | NULL | |
    | updatorId | char(8) | YES | | NULL | |
    ---------------------------------------------------+
    9 rows in set (0.00 sec)
    what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
    Any help would be greatly appreciated.
    Thanks in Advance.
    -Vasanth

    Thanks Donald,
    Actually I figured it out, with the following query:
    select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
    I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
    select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
    I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
    Thanks again.
    Vasanth

  • *URGENT HELP REQUIRED* java.sql.SQLException: Invalid Oracle URL specifed

    Hi all,
    In the middle of the last week for my final year project and having to convert to an Oracle database due to compatibility problems with university Tomcat Server and MS Access. I'm having trouble connecting to the Oracle database and would appreciate some help please.
    Running on Windows 98 in the lab here, and the Oracle 9i, release 9.2.0.2.0, J2SDK1.4.0, Classes12.zip installed OK.
    Code for connection looks like this inside the constructor of my class:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    cardSaleConnexion = DriverManager.getConnection("jdbc:oracle:[email protected]:1521:sid","user_name","pwdt");
    System.out.println("Connection Successful ");
    And I'm getting the following error when calling the constructor in a driver program:
    java.sql.SQLException: Invalid Oracle URL specified
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:188)
         at java.sql.DriverManager.getConnection(DriverManager.java:512)
         at java.sql.DriverManager.getConnection(DriverManager.java:171)
         at CardSale.<init>(CardSale.java:30)
         at Driver.main(Driver.java:11)
    Exception in thread "main"
    Please reply on a very urgent basis.
    Kind regards,
    Peter

    Try ojdbc14.jar as the JDBC driver instead of classes12.zip.
    Refer:
    http://otn.oracle.com/software/tech/java/sqlj_jdbc/htdocs/jdbc9201.html
    http://docs.sun.com/source/817-5603-10/index.html
    Database Driver
    This section describes the known database driver issues and associated solutions.
    ID      Summary
    4700531      On Solaris, an ORACLE JDBC driver error occurs.
         This new Java Database Connectivity (JDBC) driver is for Oracle (R) working with JDK1.4. The problem is caused by a combination of the Oracle 9.1 database and ojdbc14.jar. Applying the patch will fix the problem on Solaris 32-bit machine, running an Oracle 9.0.1.3 database.
         Solution
         Obtain and apply the patch to your server from the Oracle Web site for Bug 2199718. Perform the following steps:
         1.��Go to the Oracle web site.
         2.��Click the 'patches' button.
         3.��Type 2199718 in the patch number field.
         4.��Click the 32-bit Solaris OS patch.Go to Metalink.oracle.com.
         5.��Click patches.
         6.��Under patch number, enter 2199718.
         7.��Click the 32 bit Solaris OS patch.
    4707531      On Solaris, accessing an Oracle 9.1 database with an Oracle 9.2 Client may cause data corruption.
         If you use an Oracle (R) 9.2 client to access an Oracle 9.1 database, data corruption might occur when a number column follows a timestamp column.
         The problem might be caused by using the ojdbc14.jar file with an Oracle 9.1 database. Applying the patch might assist in addressing the situation on Solaris 32-bit machines, running an Oracle 9.1 database. This JDBC driver is for Oracle working with JDK1.4.
         Solution
         Obtain the patch that Oracle might make available from the Oracle web site for Bug 2199718 and apply it to your server.
    Regards,
    Pankaj D.

  • Need help in using SQL in a jsp file to compare date and time

    hi every one,
    Actually I am doing a project using JSP. I need to compare a date field in the database (MS Acess) to the current system date and time. I have to do this in a select statement.
    I have alredy defined a variable of type Date in the JSP file and I am comparing this variable to the date in the database through a select statemant.
    Here is what I am doing
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
              java.util.Date today = new java.util.Date();
              String myDate=sdf.format(today);
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= "+myDate+" ;";
    EDate is the feild in the database and it's format is (5/12/2008 5:29:47 PM) it is of type Date/Time in MS Acess.
    when I execute the query it gives the following error
    SQL error:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'EDate <= 2008-10-16 08:10:07'.
    I hope any one can help me with that error and answer my question, I've tried too many things but nothing helps
    Thanks in advance :-)

    Hi,
    When the comparision is needed to be done with the current date , we don't need to send in Java
    Date then format it and compare with MS Acess Date.
    In MS Access we have Date() function which will give you the current date.
    So you can try rewriting your query as following :
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= Date() ;"; ---------------------
    Hope this helps.
    Thanks

  • Please help with an sql to show more than one records into single row for each student

    From the following data I would like to create an sql to get the information  as the following layout
    studentid,  firstTerm,  EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
    ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
    Example
    1 First, 30,40,20,Sec,30,40,20,  simillarly next row for next row for another sudent. Please help to generate the sql for the same.
    Please help it would be very appreciate.
    With Thanks
    Pol
    polachan

    create table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
    insert into yourdata values
    (1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
    (2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
    (3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
    (1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
    (2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
    (3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
    Select studentid
    ,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
    ,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
    ,max(case when term='First' and section='Math' Then Mark End) as MathMark1
    ,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
    ,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
    ,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
    ,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
    ,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
    ,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
    From yourdata
    Group by studentid
    drop table yourdata

  • Need help on Dynamic SQL Cursor in Forms

    Hi All,
    I am trying to execute Dynamic SQL Cursor in forms using EXEC_SQL built in.
    I have a cursor for example:
    'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order
    My code is
    cur_num := Exec_SQL.Open_cursor;
    sql_order := 'select * from supplier where supplier = '||p_supplier||' and processing_order = '||p_order;
    EXEC_SQL.PARSE(cursor_number, sql_order);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,1,ln_Supp_Id);
      EXEC_SQL.DEFINE_COLUMN(cur_num ,2,ls_Suppl_Name,30);
    EXEC_SQL.DEFINE_COLUMN(cur_num ,24,ls_exchange,20);
      sql_count := EXEC_SQL.EXECUTE(cur_num );
      While EXEC_SQL.FETCH_ROWS(cur_num ) > 0 Loop
            EXEC_SQL.COLUMN_VALUE(cur_num ,1,ln_Supp_Id);
            EXEC_SQL.COLUMN_VALUE(cur_num ,2,ls_Suppl_Name);
            EXEC_SQL.COLUMN_VALUE(cur_num ,24,ls_exchange);
    End Loop;
    EXEC_SQL.CLOSE_CURSOR(cur_num );
    In this case I have to write 24 Define Columns and 24 Column value. Is there any way to assign them to %rowtype at one time as I need all coulmn of the table.
    I had similar case on multiple tables.
    Please help me
    Thanks,
    Maddy

    I need this dynamic sql because p_supplier and p_order values changes at run time
    I do not understand. Is this a simplified sample or the real thing? You do know that you can pass variables to cursors:
    cursor test is
    select * from supplier where supplier = p_supplier and processing_order = p_order;
    or does e.g. p_supplier hold other parts of the query?
    cheers

  • Help need in sql

    i have a scenario like
    bank_division sum(amount) total_percentage(calculated by : / total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
    aaaa 10000
    bbb 2000
    ccc 3000
    dddd 40000
    for above thing i have written sql like
    select bank_division,sum(amount)  from bank group by bank;
    but i am unable to calculate percentage for each bank_division..........
    .its like for aaaa correspoding percentage will be
    10000/ total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
    and for bbb it will be
    2000/ total sum of adjacent amounts i.e(10000+2000+3000+4000) *100
    so on...
    can any one help me how to write in single sql

    user632733 wrote:
    in your sql you are using lag to display from existing total_sal....which cant be possible in above scenario..??? Where did you see existing total_sal? EMP table:
    SQL> select deptno,ename,sal from emp
      2  /
        DEPTNO ENAME             SAL
            20 SMITH             800
            30 ALLEN            1600
            30 WARD             1250
            20 JONES            2975
            30 MARTIN           1250
            30 BLAKE            2850
            10 CLARK            2450
            20 SCOTT            3000
            10 KING             5000
            30 TURNER           1500
            20 ADAMS            1100
        DEPTNO ENAME             SAL
            30 JAMES             950
            20 FORD             3000
            10 MILLER           1300
    14 rows selected.
    SQL> As you can see, there are multiple employees in each department. Now look at mu solution. Inner select:
             select  deptno,
                     sum(sal) total_sal
               from  emp
               group by deptnosummarizes sal for each department. If you run it separately:
    SQL>          select  deptno,
      2                   sum(sal) total_sal
      3             from  emp
      4             group by deptno
      5  /
        DEPTNO  TOTAL_SAL
            30       9400
            20      10875
            10       8750
    SQL> Outer select calculates previous department total salary and its ratio to report.
    SY.
    P.S. And if you want to display individual employees along with department level summarization:
    select  deptno,
            ename,
            total_sal,
            prev_deptno,
            last_value(total_sal) over(order by deptno range between unbounded preceding and 1 preceding) prev_dept_total_sal,
            ratio_to_report(total_sal) over () * 100
      from  (
             select  deptno,
                     ename,
                     sum(sal) over(partition by deptno) total_sal,
                     max(deptno) over(order by deptno range between unbounded preceding and 1 preceding) prev_deptno
               from  emp
      order by deptno
        DEPTNO ENAME       TOTAL_SAL PREV_DEPTNO PREV_DEPT_TOTAL_SAL RATIO_TO_REPORT(TOTAL_SAL)OVER()*100
            10 MILLER           8750                                                           6.38569604
            10 KING             8750                                                           6.38569604
            10 CLARK            8750                                                           6.38569604
            20 ADAMS           10875          10                8750                           7.93650794
            20 FORD            10875          10                8750                           7.93650794
            20 JONES           10875          10                8750                           7.93650794
            20 SMITH           10875          10                8750                           7.93650794
            20 SCOTT           10875          10                8750                           7.93650794
            30 WARD             9400          20               10875                           6.86006203
            30 TURNER           9400          20               10875                           6.86006203
            30 ALLEN            9400          20               10875                           6.86006203
        DEPTNO ENAME       TOTAL_SAL PREV_DEPTNO PREV_DEPT_TOTAL_SAL RATIO_TO_REPORT(TOTAL_SAL)OVER()*100
            30 JAMES            9400          20               10875                           6.86006203
            30 BLAKE            9400          20               10875                           6.86006203
            30 MARTIN           9400          20               10875                           6.86006203
    14 rows selected.
    SQL>

  • Help Needed In SQL Query

    HI All,
    Oracle sql clarification required
    Sample Table:
    empno empname Job mgr_id hire_date salary deptno
    7788 SCOTT ANALYST 7566 19-APR-87 3000 20
    7902 FORD ANALYST 7566 03-DEC-81 3000 20
    7934 MILLER CLERK 7782 23-JAN-82 1300 10
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    7369 SMITH CLERK 7902 17-DEC-80 800 20
    7876 ADAMS CLERK 7788 23-MAY-87 1100 20
    Need "single / one" sql for this requirement statement:
    There will be 2 drop down boxes (1st - Job list, 2nd - empno) in the form in which the following result set is expected
    1) When user selects value from 1st drop down box (job) as "ANALYST" leaving the second drop down unselected, the result expected is 2 (no. of rows for that job)
    2) When user selects value from 1st drop down box (job) as "ANALYST" and the value from 2nd drop down box as 7902, the result expected is 1 (no of rows for that job and empno)
    Sqls which I have tried from my side (given below) didn't give the expected result and please do help me in correcting this
    select count(1) from scott.emp where job='ANALYST' and ( empno = :empno or empno is null ) ;
    Please help for this requirement. Any help is deeply appreciated.
    Thanks
    Zaheer

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    For your question the following will both work:SQL> select * from emp
    where job='ANALYST' and (empno =:empno or :empno is null)
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
    7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
    2 rows selected.
    SQL> select * from emp
    where job='ANALYST' and empno =NVL(:empno, empno)
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
    7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
    2 rows selected.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help needed in SQL Loader

    Hi,
    Am using SQL Loader to insert rows in a table.
    I have 5 cols in table A. But the data is not present in all cols always.
    Have used TRAILING NULLCOLS but with no help.. few rows are inserted and for many others it throws "ORA-01841: (full) year must be between -4713 and +9999, and not be 0" error
    (because the value is null in that particular column position)
    How do I handle such cases.Please help asap.
    FYI -
    CONTROL FILE
    load data
    infile '/home/krkanth/test_spam_20070513.dat'
    BADFILE 'sample.bad'
    DISCARDFILE 'sample.dsc'
    into table spam_rule_stats
    fields terminated by "\t"
    optionally enclosed by '"'
    TRAILING NULLCOLS
    (MAIL_DATE date 'yyyymmdd hh24:mi:ss', METRIC_TYPE, HEURISTIC_TYPE, HEURISTIC_VALUE, REJECTION_COUNT,
    RULE_START_DATE DATE 'yyyymmdd hh24:mi:ss',
    RULE_END_DATE date 'yyyymmdd hh24:mi:ss',SOURCE)
    Am getting error Rejected - Error on table SPAM_RULE_STATS, column RULE_END_DATE.
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    SAMPLE DATA
    20070513 RULE SENDER [email protected] 534 20070214 22:02:56
    SnA_ALERTS
    20070513 RULE SENDER [email protected] 6 20070503 21:19:36 200
    70518 21:19:36 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 519 20061105 05:40:44 SnA
    _ALERTS
    20070513 RULE SENDER [email protected] 332 20070509 02:44:51 20070524 02
    :44:51 JASD_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 928 20070512 14:49:14 20070527 14:49:14 JAS
    D_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 19875 20070507 22:30:01 20070522 22
    :30:01 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 3 20070509 09:08:38 20070524 09:08:38
    JASD_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 10 20070503 21:19:36 200
    70518 21:19:36 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 4 20070506 04:39:48 20070521 04
    :39:48 JASD_HP_AUTOREJECT
    Thanks.

    not sure if this will work but you may want to give it a try:
      change from:
        (MAIL_DATE date 'yyyymmdd hh24:mi:ss'
      to:
        (MAIL_DATE date 'yyyymmdd'since the first data on your file does not have the timestamps

  • Help needed in SQL statement

    Hi,
    From the SQL statement below, i need help in explaining what does the line "WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+))" do?
    This statement was written by a vendor and now i have problem displaying some new data. Only a portion of what i need is displayed.
    SELECT "LIMS_SYS"."RESULT"."DESCRIPTION",
    "LIMS_SYS"."RESULT_TEMPLATE_LIMIT"."NUMERIC_LIMIT",
    "LIMS_SYS"."RESULT"."FORMATTED_RESULT",
    "LIMS_SYS"."RESULT"."CONCLUSION",
    "LIMS_SYS"."RESULT_USER"."U_RESULT_SEQUENCE" ,
    "LIMS_SYS"."RESULT"."RESULT_ID"
    FROM "LIMS_SYS"."RESULT",
    "LIMS_SYS"."RESULT_TEMPLATE_LIMIT",
    "LIMS_SYS"."RESULT_USER",
    "LIMS_SYS"."ALIQUOT",
    "LIMS_SYS"."SAMPLE",
    "LIMS_SYS"."SDG",
    "LIMS_SYS"."TEST"
    WHERE ( lims_sys.result.result_template_id = lims_sys.result_template_limit.result_template_id (+)) and
    ( "LIMS_SYS"."RESULT"."RESULT_ID" = "LIMS_SYS"."RESULT_USER"."RESULT_ID" ) and
    ( "LIMS_SYS"."SDG"."SDG_ID" = "LIMS_SYS"."SAMPLE"."SDG_ID" ) and
    ( "LIMS_SYS"."SAMPLE"."SAMPLE_ID" = "LIMS_SYS"."ALIQUOT"."SAMPLE_ID" ) and
    ( "LIMS_SYS"."ALIQUOT"."ALIQUOT_ID" = "LIMS_SYS"."TEST"."ALIQUOT_ID" ) and
    ( "LIMS_SYS"."TEST"."TEST_ID" = "LIMS_SYS"."RESULT"."TEST_ID" ) and
    ( ( LIMS_SYS."SDG"."SDG_ID" = :sdg_id ) AND
    ( LIMS_SYS."RESULT"."STATUS" <> 'X' ) AND
    ( LIMS_SYS."RESULT"."REPORTED" = 'T' ) AND
    ( LIMS_SYS."RESULT_USER"."U_RESULT_CATEGORY" in ( 'Metal' , 'Mean Metal', 'Range Metal')) )
    Thanks for all your help.

    Hi,
    After WHERE .......... is indicates an OUTER Join condition.
    In this type of join, system retrieves the data for matched and
    as well as unmatched.
    Example:
    EMP table have a column DEPTNO with the data 10, 20, 30 (total rows=14)
    DEPT table have a column DEPTNO with the data 10, 20, 30, 40, 50 (total rows=5)
    If the WHERE clause contained EMP.DEPTNO(+) = DEPT.DEPTNO
    then the output contain the data relative to 10, 20, 30, 40, 50 (total rows = 16)
    i.e. 14 rows (with matching data) and 2 rows (with unmatching data)
    Regards,
    Sailaja

  • Need help changing from SQL dbo to mdf file

    My project was started using dbo is there a way to change this to an mdf without changing out the database.

    I think you answered my question the datasets in my project are connected to sqlexpress instance, Iwant to remove this connection and add a connection to an MDF file in my project. Maybe this will help explain my question better. 
    You cannot directly add connection to mdf file.But you can achieve this by first attching this MDF file to SQL express( this has some limitations like max of  4 Gfile can be attached to Sql server 2008 and 10 G for 2012).Is this you want to achieve ?
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

Maybe you are looking for

  • How to call javascript to map to a perticular field in the XSLT

    Hi all, Is it possible to map to my target a file with the java script ? For eg.I wish to Display the current dat eand time of the system. For this I wrote a java script which displays the date and time . Please let me know how to use the same to map

  • Make Eyebeam 1.5 work threw WRT160N with firmware 1.02.2

    Greetings: I have an eyebeam 1.5 that I have tried and tried to get to work with my WRT160N with firmware 1.02.2 with zero sucess.  The Eyebeam will work perfectly when hardwired to the cable modem but will not work via the WRT160N wireless router. 

  • WE NEED NEW LAWS TO PROTECT THE PUPLIC FROM THE BT...

    We the public need new laws to protect us from BT GREED. your spreading yourself very thin, but you expect us to still pay for 8.0mb when your only giving us 0.6 and to you its acceptable!!!!!! its nothing more than a scam and would be classed at a s

  • Setup Rate in Oracle GL R12

    Hi, Is there any setup in currency rates manager for create transaction using previous rate if we forget to define new rate For example: In Jan 22th, 2013 Rate 1 USD = IDR 9600 --> defined in daily rates In Jan 23th 2013, when create transaction the

  • EJB deployment on AIX and True64

    Hi, I heard that due to JDK licensing issues, the deployment of EJBs needs a separate download of JDK on weblogic on AIX and Tru64. Without this step, the depployment and running ejbs would fail. Can anyone please confirm that it is the case? Thanks