0

I would like to know how to prepare a Delete statement based on the below select query.

select TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') jdedate from testdta.F5847036 WHERE TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') < (sysdate-30);

I am not able use

DELETE from TESTDTA.F5847036 where jdedate in (select TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') jdedate from testdta.F5847036 WHERE TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') < (sysdate-30));

or

DELETE from TESTDTA.F5847036 where TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') jdedate in (select TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') jdedate from testdta.F5847036 WHERE TO_DATE(TO_CHAR(OGUPMJ+1900000),'YYYYDDD') < (sysdate-30));
1
  • Please give us more background on what "not able to use" means: to you get a parser error, or a runtime error? Is it a matter of syntax or a matter of query plan choice? Commented Sep 22, 2017 at 8:17

1 Answer 1

2

The identifier jdedate is used as an alias in the SELECT query. It defines the column name in the result set. Column name aliases are not useful with delete (because there are no columns to return) and therefore not permitted by the syntax of the delete statement.

Remove the two occurences of the jdedate alias in the delete statement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.