Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert result from a select into a table (ERR:column not allowed here)

Status
Not open for further replies.

rogerzebra

Technical User
May 19, 2004
216
SE
Hi fellas,
I'm trying to grab a result from a query and insert into a table. I get this annoying little error "column not allowed here" I would greately appreciate if anyone could have a look at my code and hopefully point out what I'm doing wrong. The table which the result is supposed to insert to has the column aliases as in the select statement.
Thanks in advance


Code:
select a.344_report as BookDate 
            ,a.23_pnum as PolicyNum 
            ,a.d42_WRITTEN as WrittenPremium
            ,0 as EarnedPremium
            ,0 as UnearnedPremium
            ,d.0002_COVERAGE as Coverage
            ,d.a988_end_no as FormName
            ,'s' as SourceSystem

,decode(d.b23_USERLINE,'10',d.C07_LIMIT_1,'70',d.C07_LIMIT_1,'36',c.C07_LIMIT_1,'37',c.C07_LIMIT_1)) as Limit1 
      
        
INSERT INTO table1
(
BookDate, PolicyNum, WrittenPremium, EarnedPremium, UnearnedPremium, Coverage, FormName,	Limit1, SourceSystem, SecondaryClass, EarnDays
)
values

(a.BookDate, a.PolicyNum, a.WrittenPremium, 'EarnedPremium',		
'UnearnedPremium', d.Coverage,		
d.FormName, 'Limit1', 'SourceSystem',		
e.SecondaryClass, 'EarnDays'
);

"I finally took the step out to start working from home, and I have never looked back" :)
You can do it too. It's fun and you will never regret it. Send me an email and check out how I'm doing in my new business to roger@workfromhomemarketing.com
 
Think of it like this: you try to INSERT the results of a SELECT. Syntax is:
Code:
INSERT INTO table1
(
BookDate, PolicyNum, WrittenPremium, EarnedPremium, UnearnedPremium, Coverage, FormName,    Limit1, SourceSystem, SecondaryClass, EarnDays
)
SELECT a.344_report as BookDate 
            ,a.23_pnum as PolicyNum 
            ,a.d42_WRITTEN as WrittenPremium
            ,0 as EarnedPremium
            ,0 as UnearnedPremium
            ,d.0002_COVERAGE as Coverage
            ,d.a988_end_no as FormName
            ,'s' as SourceSystem

,decode(d.b23_USERLINE,'10',d.C07_LIMIT_1,'70',d.C07_LIMIT_1,'36',c.C07_LIMIT_1,'37',c.C07_LIMIT_1)) as Limit1
  FROM yourTable
 WHERE yourCondition is met

Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top