Home » SQL & PL/SQL » SQL & PL/SQL » problem with my insert query
problem with my insert query [message #440195] Thu, 21 January 2010 09:25 Go to next message
pyscho
Messages: 134
Registered: December 2009
Senior Member
INSERT INTO INTEGRATION.VALN_CHANGES (CASH_BAL_ID)
VALUES (SELECT ACCOUNT_ID || '~' || TXN_CCY
        FROM INTEGRATION.CASH_TRANS
        GROUP BY ACCOUNT_ID || '~' || TXN_CCY);


it gives a 'missing expression' in the SELECT bit, any ideas guys?

SELECT ACCOUNT_ID || '~' || TXN_CCY
FROM INTEGRATION.CASH_TRANS
GROUP BY ACCOUNT_ID || '~' || TXN_CCY

that just gives me a list of all possible distinct accountid/ccy combination id's - and i just want to insert them into my valn_changes table
Re: problem with my insert query [message #440196 is a reply to message #440195] Thu, 21 January 2010 09:31 Go to previous messageGo to next message
TinchoGomez
Messages: 11
Registered: January 2010
Location: Santa Fe - Argentina
Junior Member

Convert to char the columns and try.
Re: problem with my insert query [message #440197 is a reply to message #440195] Thu, 21 January 2010 09:33 Go to previous messageGo to next message
cookiemonster
Messages: 12420
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you want distinct combinations use the distinct keyword - it makes your intentions clearer if nothing else.
Re: problem with my insert query [message #440198 is a reply to message #440195] Thu, 21 January 2010 09:34 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
INSERT INTO INTEGRATION.VALN_CHANGES (CASH_BAL_ID)
VALUES (SELECT ACCOUNT_ID || '~' || TXN_CCY FROM INTEGRATION.CASH_TRANS)
Re: problem with my insert query [message #440200 is a reply to message #440198] Thu, 21 January 2010 09:42 Go to previous messageGo to next message
pyscho
Messages: 134
Registered: December 2009
Senior Member
This worked Very Happy

        INSERT INTO INTEGRATION.VALN_CHANGES (CASH_BAL_ID)
            SELECT DISTINCT ACCOUNT_ID || '~' || TXN_CCY 
            FROM INTEGRATION.CASH_TRANS;
Re: problem with my insert query [message #440217 is a reply to message #440200] Thu, 21 January 2010 12:20 Go to previous message
joy_division
Messages: 4642
Registered: February 2005
Location: East Coast USA
Senior Member
As you can see, VALUES is only used for single row inserts.
Previous Topic: grouping query with an update
Next Topic: How to implement this logic in a stored procedure
Goto Forum:
  


Current Time: Thu Dec 08 06:24:38 CST 2016

Total time taken to generate the page: 0.11234 seconds