Insert data into oracle based on sql server data(here sql server acting as source to oracle and destination to oracle)

Source is Oralce. Destination is SQL Server.
Requirement - I have to fetch sql server server data (empid's) based emp table  and send this as input data to oracle to fetch and empid's are common.
I cannot use merge or loopkup or for each as oracle have too many records.
For example - In MS SQL - i have empid=1,2..Only these records, I have to fetch from oracle source into sql server destination. For this, I have adopted the below approaches...The major problem I face, when i build a empid's as a string, it is taking only
4000 chars. My string lenght is 10000. How do I breakup this string lengh and send to data flow task till all broken strings length passed to DFT.
Approach-1
created two variables - oraquery string, empid string
step1 - ms sql database - created sql task - declare @empid varchar(max)
SELECT @empid=
Stuff((SELECT ',' + empid
        FROM  
        (SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
         ) x
        For XML PATH ('')),1,1,'')
select @empid =    '(' +  @empid + ')'
select @empid
resultset=singlerow
resultset=resultname=0; variablename=User::empid (empid is declared as string)
step2 - oracle database - created data flow task
created oledb source
I put  this statemnt in oraquery expression - "select * from dept where dept in  "
+  @[User::empid] + "
expression=true
[OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available.  Source: "Microsoft OLE DB Provider for Oracle"  Hresult: 0x80040E14  Description: "ORA-00936: missing expression".
Approach-2
created three variables - oraquery string, empid  int, loop object--when I put int then it is automatically setting to 0
step1 - ms sql database - created sql task - SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
resultset=fullresult
resultset=resultname=0; variablename=User::loop
step2 - created a for each loop container
for loop editor - for each ado ennumerator
enumerator configuration - loop
variablemapping - variable=empid;index=0
step3 - oracle database - created data flow task (outside for each loop. If I put inside it is taking long time)
created oledb source
I put  this statemnt in oraquery expression - "select * from dept where dept in  "
+  @[User::empid] + "
expression=true
Data inserting in a destination table but  empid=0.

Sorry didnt understand if your step3 is outside loop how
@[User::empid] will get values for the empids from User::loop. The iteration happens inside loop so you
need to have a logic to form the delimited list inside using a script task or something and concatenating everything and storing to variable @[User::empid]
. Then only it will have full value used to be used in step3 query
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Inserting rows into table Based on Column Values.

    Hi,
    I am trying to inserting rows into a table based on Column.
    Id      Name        
    Data
    N 105.1.1
    http://www.example.com/New/105.1.1
    U 105.1.2               http://www.example.com/Used/105.1.2
    S 105.1.3               http://www.example.com/Sold/105.1.3
    I want a table like this. 
    I want to insert Data column value based on Id and Name Columns
    If Id = N and Name = 105.1.1 then Data value should be insert as   http://www.example.com/New/105.1.1
    If Id = U and Name = 105.1.2 then Data value should be  insert as  http://www.example.com/Used/105.1.2
    If Id = S and Name = 105.1.3 then Data value should be insert as   http://www.example.com/Sold/105.1.3
    Can you please help us to write query to insert above Data Column values based on Id and Name Columns.

    INSERT INTO tbl (col) SELECT
    CASE WHEN id='N' and Name='105.1.1 ' THEN 'http://www.example.com/New/105.1.1'
              WHEN id='U' and Name='105.1.2 ' THEN 'http://www.example.com/New/105.1.2'
    END col
    FROM anothertbl
    Sorry , cannot test it right now.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Move files into folders based on EXIF Creation Date

    Hi all,
    Being a novice with Applescript I have read what I can find on this forum, but are not able to find exactly what I'm looking for. I think that the posting "Using AppleScript to create folders and place files in them" is the closest I get to what I want but I want to create the folders based on EXIF creation date.
    Let me explain.
    I have a folder that contains thousands of jpg, mp4, mov and avi files; all created by different cameras. I want to bring some order to this and place files in folders based on year, month and date that the file was created (the photo taken or the video captured). This date is stored in the EXIF creation date.
         Take all files in folder A
          foreach file find the EXIF creation date
          move each file into directory tree (at same location is ok) where toplevel is YEAR, next directory level is named accoring to EXIF creation date as MMDDYY
          if no EXIF creation date can be found, fallback to creation date (file property?)
          if no good date is found, leave file alone in folder A for manual sorting; do not use modification date as this may have been altered
         this would create a structure as
         2002
                011602
                        File 1 taken Jan 16 2002
                        File 2 taken Jan 16 2002
                082002
                        File 1 taken Aug 20 2002
                        File 2 taken Aug 20 2002
          2003
                 etc 
         2004
             |   etc
         2014
                 010114
                        File 1 taken Jan 1 2014
    etc etc

    Well, technically that's correct, Frank, but the same could be said of much of AppleScript - the core functionality is limited, but there's a lot you can do.
    For example, it's actually trivial to use Image Events get any given EXIF tag of an image:
    set theFile to (choose file)
    tell application "Image Events"
              set f to open theFile
              set cD to value of metadata tag "CreationDate" of f
      close f
    end tell
    Now, cD will have the value of the CreationDate tag (assuming it exists, of course - you'll need to wrap this in a try/end try statement). Once you have that it shouldn't be too hard to extract the date components, work out the target directory name and move the file.

  • When I copy and paste the data from a web site in to excel, it comes in one big splurge - ie it is not 'delimited' - and I can't see how to delimit the data into cells. In Explorer, the data is delimited. Any clues ? John

    see above

    A couple of options:
    # When pasting the data into Excel use Paste Special, and choose either Text or Unicode Text.
    # Use the Dafizilla Table2Clipboard extension to copy the data - https://addons.mozilla.org/firefox/addon/dafizilla-table2clipboard

  • I am writing datas into a FIFO ,i am reading datas from fifo .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place .what is the reason ?

    I am writing datas into a FIFO in FPGA Target side  ,i am reading datas from fifo in windows host side  .but when i am writing datas like a a(0),a(1),a(2 like that.when i am reading dating datas a(0)comes to a(3 ) rd place, a(1) comes to a a(0) .what is the reason ?

    Please use a shorter title in your subject line and not post the entire question in therre.  (See the subject line I created.)   There is also no such word as "datas".  Data is already plural.
    Please read http://stackoverflow.com/help/how-to-ask.  Your question is hard to read because you aren't using proper punctuation and capitalization of your sentences.  It looks like one run-on sentence.
    Beyond that, it is impossible to help you solve our problem with just your question.  Please provide some more information.  Perhaps even attach code we can look at.  Show us what the data you are sending is supposed to look like, and what it actually looks like.

  • How to convert Visiprise 4.2 DB dump data into SAP ME 5.2 dump data

    Hi,
    Currently i am working in two versions of SAP ME : (1.) Visiprise 4.2  and (2.) SAP ME 5.2 . I have many Oracle DB '.dmp' files for the Visiprise 4.2 version. I want all of them to be converted to the SAP ME 5.2 version. I analyzed the DB schema for both and found lots of changes like index , data type , size , even some columns and tables are added in SAP ME 5.2 . My Visiprise 4.2 instance uses Oracle 9i and SAP ME uses Oracle 11g but that is not a big problem to convert and load . Can anyone help how i can change the Visiprise 4.2 DB dump data compatible with SAP ME 5.2 data since there is lots of change in schema?

    Hi,
    You have to run all DB upgrade and data migration scripts available in 5.2 release to make your 4.2 DB compatible with ME 5.2. These scripts should contain all the DB structure and data changes. The scripts should be available in Clients installation. For detailed process check ME 5.2 Upgrade guide that should be available on SMP.
    Regards,
    Konstantin

  • Can Bridge sort my images into folders based on an Exif date?

    All my Adobe products are pre-CS/CS2 and I don't yet have access to Adobe Bridge. My trial copy has also timed out. However, I would like to know if Bridge has the capability to take a folder of images (Canon Raw) and move them to new folders based on the original exposure date as stored in the Exif metadata (ideally creating the required target folders automatically). I'm thinking in terms of one folder per year, probably with subfolders for each month.
    I'm simply trying to avoid having all my images in a single humongous folder with Bridge re-creating (or at least re-displaying) thousands of thumbnails every time I just want to look at a few images. Sorting them into folders by date just seems a simple solution to that problem. However, I'd be very happy to hear about alternative image filing ideas.
    Once I have used Bridge to create extended metadata for image categories, etc, I'm also assuming that Bridge will let me search for images that match defined criteria no matter how many folders those images are stored in.

    I don't know of any functionality to do that in Bridge now; however, it certainly can be done via scripting.
    Perhaps one of our forum contributors might want to take on a "picture sorter" script...
    Bob
    Adobe Workflow Scripting

  • Problem inserting FLV into template based page DW8

    Error when inserting an FLV into a template based page.
    The error is: "Making this change would require changing code
    that is locked by a template or translator. The change will be
    discarded."
    I thought perhaps something was wrong with my code so I
    created a new page in DW8, with one word of text. Saved the new
    page as a template with the one word of text made into an editable
    region. Created a page based on that template and attempted to
    insert a FLV file into the editable region (using Insert > Media
    > Flash Video). I still get the error message. I've attached the
    code for this page.
    I also get the error message when I go through the tutorial
    Presenting
    Video with the Flash Video Component in Dreamweaver 8. Using
    the files provided in the tutorial.
    Is the only workaround for this the one I found here?:
    http://med.stanford.edu/irt/web/references/flash_video_installation.html.
    Steps are under heading "Workaround for Locked Code insert error"
    near bottom of page.
    Any help is appreciated.
    Jen

    > Is the only workaround for this the one I found here?:
    >
    http://med.stanford.edu/irt/web/references/flash_video_installation.html.
    > Steps
    > are under heading "Workaround for Locked Code insert
    error" near bottom
    > of
    > page.
    This workaround *will* work....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "kilmeny21" <[email protected]> wrote in
    message
    news:[email protected]...
    > Error when inserting an FLV into a template based page.
    >
    > The error is: "Making this change would require changing
    code that is
    > locked
    > by a template or translator. The change will be
    discarded."
    >
    > I thought perhaps something was wrong with my code so I
    created a new page
    > in
    > DW8, with one word of text. Saved the new page as a
    template with the one
    > word
    > of text made into an editable region. Created a page
    based on that
    > template and
    > attempted to insert a FLV file into the editable region
    (using Insert >
    > Media >
    > Flash Video). I still get the error message. I've
    attached the code for
    > this
    > page.
    >
    > I also get the error message when I go through the
    tutorial
    >
    http://www.adobe.com/devnet/flash/articles/flv_tutorial.html.
    Using the
    > files
    > provided in the tutorial.
    >
    > Is the only workaround for this the one I found here?:
    >
    http://med.stanford.edu/irt/web/references/flash_video_installation.html.
    > Steps
    > are under heading "Workaround for Locked Code insert
    error" near bottom
    > of
    > page.
    >
    > Any help is appreciated.
    > Jen
    >
    >
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    > "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="
    http://www.w3.org/1999/xhtml"><!--
    InstanceBegin
    > template="/Templates/index.dwt"
    codeOutsideHTMLIsLocked="false" -->
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    > <!-- InstanceBeginEditable name="doctitle" -->
    > <title>Untitled Document</title>
    > <!-- InstanceEndEditable -->
    > <!-- InstanceBeginEditable name="head" --><!--
    InstanceEndEditable -->
    > </head>
    >
    > <body>
    > <!-- InstanceBeginEditable name="temp"
    -->Text<!-- InstanceEndEditable -->
    > </body>
    > <!-- InstanceEnd --></html>
    >

  • How to split data into tables based on the entries in a column?

    My problem is very similar to this thread: how to link data from one numbers sheet to another sheet, however I could get it to work the way described there. I have one big table for entering data (the first one). I would like to have a few other tables populated automatically based on the entries in one of the columns of the first table. In my example below I put everything in one sheet for clarity. The selection to the other tables is to be done on the column "fruit" in the first table. (second one is "oranges", then "apples" and then "pears" -- had to cut the width of my screenshot due to the limitations of Apple's forums).
    Here is what it would look like, just cannot figure out how to make it happen automatically.
    Tried also importing similar Excel example to Numbers, but the import did not work correctly.
    Any help will be appreciated.
    LD

    Larry,
    Here's an approach that I've used...
    In the Purchases table, Aux column, the expression is:
    =COUNTIF($A$1:A2, A) & "-"&A
    Fill Down
    This expression builds a string that identifies the item and the ocurrance of that item.
    The Date column of the Summary tables, cell a3, contains:
    =IF(ROW()-3<COUNTIF(Purchases :: $A,$A$1), LOOKUP(ROW()-2&"-"&$A$1, Purchases :: $F, Purchases :: B), "")
    Fill Across, then fill down.
    Regards,
    Jerry

  • Error while loading data into BW (BW as Target) using Data Services

    Hello,
    I'm trying to extract data from SQL Server 2012 and load into BW 7.3 using Data Services. Data Services shows that the job is finished successfully. But, when I go into BW, I'm seeing the below / attached error.
    Error while accessing repository Violation of PRIMARY KEY constraint 'PK__AL_BW_RE_
    Please let me know what this means and  how to fix this. Not sure if I gave the sufficient information. Please let me know if you need any other information.
    Thanks
    Pradeep

    Hi Pradeep,
    Regarding your query please refer below SCN thread for the same issue:
    SCN Thread:
    FIM10 to BW 73- Violation of PRIMARY KEY -table AL_BW_REQUEST
    Error in loading data from BOFC to BW using FIM 10.0
    Thanks,
    Daya

  • Best way to restrict data (per consumer-based) in a generic data service

    Hi again!
    In our project, we have a big database and our data services expose data from them. So far, so good.
    However, because of the company's security business process, any consumer needs to approve all the fields they want to use before consuming the data services and also the scope of the query, and not all consumers have the same permissions.
    For example, suppose we have a big table called EMPLOYEES with the following fields (please note that in this fake"table" I am not considering joins and FK's, for the sake of simplicity):
    h3. EMPLOYEES (XML schema element employee)
    ID (not mapped in XML schema)
    NAME (element name)
    LOGIN (element login)
    SUBSIDIARY (element subsidiary)
    DEPARTMENT (element department)
    JOB (element job)
    SALARY (element salary)
    ADDRESS (element address)
    SOCIAL_SECURITY_NUMBER (element socialSecNumber)
    Suppose we have a generic public operation called getEmployeeByLogin($login as xs:string), published in the corporative oracle service bus, that retrieve an employee. Any and every consumer must have their own bus login/password and, based in it, we configure ODSI which elements each consumer will get in the response. So:
    . . . . Consumer1: restricted to see only elements name, login, department, subsidiary
    . . . . Consumer2: restricted to see only elements name, login, department, job, subsidiary
    And so on. Again, so far, so good.
    Our problem: some consumers are allowed to see elements from a specific subsidiary and/or department. Example:
    . . . . Consumer3: restricted to see only elements name, login, department, job, salary ONLY FROM subsidiary "ABC" and department "dept 2"
    . . . . Consumer4: restricted to see only elements name, login, department, job ONLY FROM subsidiaries "ABC", "DEF", "GHI"
    . . . . Consumer5: restricted to see only elements name, login, department, job, salary ONLY FROM subsidiary "MNO", departments "dept 11", "dept 12"
    What would be the best way to attend to these restrictions while using the most generic and reusable solution?
    One answer would be create an operation for each consumer, but I don't want to use this approach unless I have no other alternative.
    I was thinking in creating an abstract level of operations to apply business rules, but I do not know if this is possible or if it is the best solution, because this is kind of hardcoding the solution. Example of this solution:
    . . . . Generic public operation: getEmployeeByLogin($login as xs:string)
    . . . . Specific public operation: getEmployeeByLogin_Consumer3($login as xs:string)
    . . . . Specific public operation: getEmployeeByLogin_Consumer4($login as xs:string)
    . . . . Specific public operation: getEmployeeByLogin_Consumer5($login as xs:string)
    . . . . All public operations above would call the generic private operation: getEmployeeByLogin($login as xs:string, $restrictions as xs:string?):
    . . . . getEmployeeByLogin would call this private operation, passing $restrictions as null.
    . . . . getEmployeeByLogin_Consumer3 would call this private operation, passing $restrictions to read only data from subsidiary "ABC" and department "dept 2".
    . . . . getEmployeeByLogin_Consumer4 would call this private operation, passing $restrictions to read only data from subsidiaries "ABC", "DEF", "GHI".
    . . . . getEmployeeByLogin_Consumer5 would call this private operation, passing $restrictions to read only data from subsidiary "MNO", departments "dept 11", "dept 12"
    What do you think about this scenario? Any idea will be highly appreciated!
    Thank you very much!

    Hi again.
    I am having some difficult trying to build my own XQuery Functions for Security.
    Hitherto, I learnt how to grant permission based in username. Now, I need to implement conditions, like "if username = 'abc', do not show results from department XPTO" and so on, but I am getting erros when I try to reference my xml schema inside the XQuery Functions for Security.
    Could you please tell me where can I get the source project used in the documentation example? I think I can try to find my way if I can study the entire source project. Page 7 of the link you sent me:
    import schema namespace t1 = 'ld:DataServices/CUSTOMER_ORDER' at 'ld:DataServices/Schema/CUSTOMER_ORDER.xsd';
    declare namespace f1 = "ld:CUSTOMER_ORDER";
    declare function f1:secureOrders($order as element(f1:CUSTOMER_ORDER)) as xs:boolean {
         if (fn-bea:is-access-allowed("CUSTOMER_ORDER/LimitAccess", "ld:CUSTOMER_ORDER.ds")) then
              fn:true()
         else if ($order/TotalOrderAmount lt (fn-bea:get-property("total_order_amount", "1000000") cast as xs:decimal)) then
              fn:true()
         else
              fn:false()
    Thank you again!

  • DB Adaptor and inserting dates into Oracle DB

    Hi,
    I'm using the Oracle DB Adaptor to poll a table in one instance (using logical delete) and to invoke a DB adaptor to insert/merge a row into a separate instance.
    NOTE :both tables have different definitions.
    I am using a BPEL transform to tfrm the data received from the poll/receive step.
    I need to transform some date variables and the target date column CreatedTs is expecting to receive the date in the Oracle DD-MON-YYYY format (can't change the NLS_DATE_FORMAT value for the target).
    I'm trying to use the provided xsl:formatDateTime function with various formats but can't get anything useful to work.
    Any ideas ?

    Hi there,
    Please see the Bpel developer's guide at otn.oracle.com/bpel. There are two troubleshooting entries of interest:
    dateTime Conversion Exceptions
    and
    Issues with Oracle DATE
    Just search on these strings.
    The xsl:formatDateTime function is for converting xs:dateTimes to strings. If you already have a value in proper ISO dateTime format do not try to convert it. The database adapter likes that format only.
    If you are starting with a string like DD-MON-YYYY and have to convert it into a legal dateTime, then that is hard as functions like xsl:formatDateTime go the opposite way only, i.e. dateTime to string, not string to dateTime.
    A few days we had a customer who needed to convert MM/DD/YYYY to a dateTime. I am copying the solution here.
    Used the expression builder in the assign to build:
    orcl:format-string('{0}-{1}-{2}T00:00:00', substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 7, 4), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 4, 2), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 1, 2))
    That worked in converting i.e. 01/05/2005 to 2005-01-05T00:00:00.
    To convert DD-MON-YYYY that is tricky because you need to first convert DEC to 12, SEP to 09, and so on. I couldn't figure out how to do that but another on this forum may be able to help you out. If you are really stuck and you know the database accepts i.e DD-MON-YYYY, you could tell the adapter that the date field is a string, then it will simply pass the value as is which should work.
    To do that please see chapter 20 of the bpel dev guide, and search for
    Configuring Offline Database Tables
    Use that to change the type to basic varchar2 in the BPEL designer so the dbadapter will think the column is a string and not convert it.
    Thanks
    Steve

  • Sql/Plsql code to export data into a temporary table from a text file

    Dear all,
    I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
    i have text file like as below:
    order items : books Purchasing
    start date:
    8-11-09
    Notes: Books are selling from aug10 to aug 25
    Action performed
    Time
    Verified By
    sold out from shop, sold out date:_________
    1.
    physics _______ book sold to ravi
    2.
    social _______ book this is a good book
    sold to kiran
    aug10th
    ronald
    3.
    maths book to sal
    4.
    english book__________ this was a newbook
    to raj
    jak
    return to shop, return date:____________
    1.
    maths book return by:_____________ Verify book
    aug11th
    john
    2.
    story book by:_________ checked
    aug14th
    Now i need to create a temporary table and insert the data into the table from this text file.
    Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
    Order     status     Action_Performed     Time     Verified_By
    books Purchasing     sold     physics _______ book sold to ravi     _______     _________
    books Purchasing     sold     social _______ book this is a good book sold to kiran aug10th     ronald
    books Purchasing sold     maths book to sal     _____     __________
    books Purchasing     sold     english book__________ this was a newbook to raj __________     jak
    books Purchasing return     maths book return by:_____________ Verify book aug11th     john
    books Purchasing     return     story book by:_________ checked aug14th     _________
    Thanks in advance.

    Isn't school work marvelous?
    Create an external table.
    http://www.morganslibrary.org/reference/externaltab.html
    Getting the data into a temporary table may make sense in SQL Server ... but not in Oracle.

  • Inserting new table data into database

    Hi, im trying to find out if i can insert a row of data into a mdb table. basically i have a List of Client objects for an application, and im iterating through this list. Now i take out an object and my aim is to place the details of that Client into the relevant cells in the database. But, it is giving me a "General error" exception. Here is my code...
    Iterator i = listOfClients.iterator();
    while(i.hasNext()){
    Client c = (Client)i.next();//get the client object
    if(c!=null){
    st.executeUpdate("INSERT INTO CLIENTS("+
    "CLIENT_NO,"+
    "CLIENT_NAME,"+
    "CLIENT_DESC,"+
    "CLIENT_ADDRESS,"+
    "CLIENT_PHONE,"+
    "CLIENT_EMAIL,CLIENT_NOTES) "+
    "VALUES('"+c.getClientNumber()+
    "','"+c.getClientName()+
    "','"+c.getClientDescription()+
    "','"+c.getClientAddress()+
    "','"+c.getClientTelephone()+
    "','"+c.getClientEmail()+
    "','"+c.additionalNotes+"')");
    Can someone please tell me where the error is in this sql statement, im really gettin agitated.
    thanx

    dw i fixed it using that PreparedStatement class.

  • Query for inserting data into table and incrementing the PK.. pls help

    I have one table dd_prohibited_country. prohibit_country_key is the primary key column.
    I have to insert data into dd_prohibited_country based on records already present.
    The scenario I should follow is:
    For Level_id 'EA' and prohibited_level_id 'EA' I should retreive the
    max(prohibit_country_key) and starting from the maximum number again I have to insert them
    into dd_prohibited_country. While inserting I have to increment the prohibit_country_key and
    shall replace the values of level_id and prohibited_level_id.
    (If 'EA' occurs, I have to replace with 'EUR')
    For Instance,
    If there are 15 records in dd_prohibited_country with Level_id 'EA' and prohibited_level_id 'EA', then
    I have to insert these 15 records starting with prohibit_country_key 16 (Afetr 15 I should start inserting with number 16)
    I have written the following query for this:
    insert into dd_prohibited_country
    select     
         a.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
    from
         (select
              max(prohibit_country_key) pkey
         from
              dd_prohibited_country) a,
         (select
    prohibit_country_key pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
         from
              dd_prohibited_country
         where
              level_id = 'EA' or prohibited_level_id = 'EA') b
    My problem here is, I am always getting a.pkey as 15, because I am not incrementing it.
    I tried incrementing it also, but I am unable to acheive it.
    Can anyone please hepl me in writing this query.
    Thanks in advance
    Regards
    Raghu

    Because you are not incrementing your pkey. Try like this.
    insert
       into dd_prohibited_country
    select a.pkey+b.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
       from (select     max(prohibit_country_key) pkey
            from dd_prohibited_country) a,
         (select     row_number() over (order by prohibit_country_key)  pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
            from     dd_prohibited_country
           where level_id = 'EA' or prohibited_level_id = 'EA') bNote: If you are in multiple user environment you can get into trouble for incrementing your PKey like this.

Maybe you are looking for

  • Make a router out of a simple notebook with one NIC (buy a second NIC)

    Hello all, Before starting, I think I must say hello to you because I'm new here : this is my first post . So, in fact, I'm working with Linux since 5 years. I'm running Gentoo on my workstation and my old server, Ubuntu on my notebook and for family

  • Problem with fonts when reading PDFs

    Hi, I have just updated my PC to Windows 7 and Adobe Reader 9.2. When I open PDF files I've previously viewed OK they now are shown with Adobe fonts. Some always, some may be OK the first time but not subsequently and some don't have the problem. I a

  • Preinstalled apache, apache2 and tomcat

    Hello, I'm setting up a Sun Fire V490 running solaris 10 for use as a web server. I need to have Apache httpd version 2 and tomcat version 4.x to run. So I found that the machine comes with apache httpd 2 preinstalled and also apache httpd 1 with ful

  • MacPro with Samsung Display 4K

    Hey there, i want to buy a new MacPro (Late2013), with two AMD FirePro D500 GPUs - and a Samsung U28D590D. (Samsung 4K Display 3840x2160 resolution). Are there some issues with this display and the graphic cards - or will it work fine ? Does anybody

  • Mac Pro (early 2008) NVidia 8800GT display problems (blue/green lines)

    I see others have touched on this topic a bit but not quite the same as my problem Every 2 - 3 days, I have to reboot my Mac Pro because my display starts showing the dreaded blue green outlines and lines.. I've called Apple (of course they are not g