Search code examples
oraclesubquerysybasedatabase-migrationsql-delete

subquery in sybase Create table clause


I have multiple Oracle queries that I want to transform to Sybase language. Since Am new to Sybase i was wondering if we can insert subquery in "create clause" or in "delete clause" in sybase ?

create table LIQ_PURGE_AK as select M_REFERENCE from LPOS_AK_DBF where M_PRIC_TYPE in (2, 3)

select distinct M_PROD_OREF from LPOS_DTL_DBF where M_REFERENCE in (select M_OBJ_DETAIL from LPOS_LQE_DBF where M_AK_CLASS = 'MEqGp44051' and M_AK_REF in (select M_REFERENCE from LIQ_PURGE_AK3)) 


delete from LPOS_DTL_DBF where M_REFERENCE in (select M_OBJ_DETAIL from LPOS_LQE_DBF where M_AK_CLASS = 'MEqGp44051' and M_AK_REF in (select M_REFERENCE from LIQ_PURGE_AK3))

Solution

  • this case:

    create table LIQ_PURGE_AK as select M_REFERENCE from LPOS_AK_DBF where M_PRIC_TYPE in (2, 3)
    

    you could change to:

    select M_REFERENCE into LIQ_PURGE_AK from LPOS_AK_DBF where M_PRIC_TYPE in (2, 3)
    

    all other case you could leave "AS IS". You could be free with subquery in the delete clause (but could be exceptions with a group by)