Convert Oracle SQL Query to SQLite Query

Hi,
I am new to SQLite and have requirement to write quries in SQLite format. As table structure is same in both the Oracle and SQLite database i have created queries in Oracle SQL. Now wanted to know is there any tool or package available which will convert my simple Oracle queries into SQLite format???
Please guide..
Regards,
Priyanka

with tree as (
select
level lev
,id
,parent_id
,sys_connect_by_path(id, '-') p
from test_temp
connect by
parent_id = prior id
start with parent_id is null
select
from tree t1
where exists (
select 1
from tree t2
where substr(t2.p, 1, length(t1.p)) = t1.p
  and regexp_count(t2.p, '-') = regexp_count(t1.p, '-') + 2
  -- if regexp_count is not available in your version or performs not well, below is an alternative
  -- and length(t2.p) - length(replace(t2.p, '-')) = length(t1.p) - length(replace(t1.p, '-')) + 2
LEV
ID
PARENT_ID
P
1
1
-1
2
3
1
-1-3
2
5
1
-1-5
1
2
-2
2
6
2
-2-6
3
14
6
-2-6-14

Similar Messages

  • Convert Oracle SQL line to SQL Server SQL

    Hi All,
    I'm trying to convert this Oracle SQL to SQL that will work with SQL Server 2008 and am having some trouble with the MOD function. Anyone have any SQL Server chops?
    Oracle SQL
    TBL_MAIN.AuthoredDate- MOD (TBL_MAIN.AuthoredDate - to_date ('2012-01-01', 'fxYYYY-MM-DD'), 7) + 6 AS "Week Ending"
    SQL Server Code
    TBL_MAIN.AuthoredDate - ((Cast(TBL_MAIN.AuthoredDate as DATE) % CAST('2012-01-01' AS DATE)), 7) + 6 AS "Week Ending" Thanks,
    John
    Edited by: Johnbr (Oracle10G) on Mar 1, 2013 8:41 AM

    ahhh.. I just had to change my thinking... I got it now:
    SQL Server SQL
    DATEADD(dd, 7-(DATEPART(dw, TBL_MAIN.AuthoredDate)), TBL_MAIN.AuthoredDate) AS 'Week Ending'

  • Convert Oracle sql to TimesTen sql please?

    Hello,
    I have the following statement that is puking in TimesTen. Can anyone help me convert it from Oracle sql to TimesTen sql?
    select
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60)),
    max(metric),avg(metric),min(metric)
    from fc_data
    where creation_date>sysdate-1 and suite_id='web-pac-hk-symantecstore'
    group by
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60))
    order by
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60))

    Chris,
    Thanks for looking into this. The version of TT is 7.0.1. I'm pretty sure the sysdate - 1 is a problem but there also seems to be another issue. Here are the results. The creation_date column is a date type column.
    Table FC_ADMIN.FC_DATA:
    Columns:
    *DATA_ID                         NUMBER (38) NOT NULL
    SUITE_ID VARCHAR2 (64) INLINE NOT NULL
    STATUS VARCHAR2 (16) INLINE
    INFO VARCHAR2 (2000) NOT INLINE
    DETAILS VARCHAR2 (4000) NOT INLINE
    METRIC NUMBER (20,10)
    METRIC_UNITS VARCHAR2 (16) INLINE
    DURATION_MILLIS NUMBER (38)
    CREATION_DATE DATE
    CREATOR VARCHAR2 (64) INLINE
    *MONTH_OF_YEAR                   NUMBER (38) NOT NULL
    TIMELINE VARCHAR2 (4000) NOT INLINE
    select
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60)),
    max(metric),avg(metric),min(metric)
    from fc_data
    where creation_date>sysdate-1 and suite_id='web-pac-hk-symantecstore'
    group by
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60))
    order by
    (trunc(creation_date,'HH24')+(round(to_number(to_char(creation_date,'mi'))/10.,0)*10.)/(24*60))
    ;1001: Syntax error in SQL statement before or at: "(", character position: 44
    select (trunc(creation_date,'HH24')+(round(to_number(to_char(creation...
    ^
    The command failed.
    How does one do a sysdate - 1 in TT?
    Thanks,
    Brian

  • Convert Oracle SQL query to single column output

    Hello All,
    I need to build the query to have multiple columns in a single column with multiple rows.
    select a.customer_trx_id,a.previous_customer_trx_id
    from ra_customer_trx_all a
    where a.customer_trx_id = :customer_trx_id
    here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to bring them into a single column.
    Say: the above output is
    a.customer_trx_id a.previous_customer_trx_id
    123456 87654
    Need to have single column
    As
    123456
    87654
    Please do the needful.
    Thanks,
    Abdul

    Hi,
    Post your question in [SQL and PL/SQL|http://forums.oracle.com/forums/forum.jspa?forumID=75] forum, you would probably get a better/faster response.
    Regards,
    Hussein

  • How to convert Oracle Queries into SQLite Queries

    Hi..
    Is it possible to convert Oracle Sql queries into SQLite queries using java ?
    Regards,
    Ajay

    >
    Is it possible to convert Oracle Sql queries into SQLite queries using java ?
    >
    No - assuming you mean automagically.
    No - assuming you mean all possible queries.
    Yes - assuming you mean queries where the syntax is compatible.
    Not needed if you mean queries that have the same syntax.
    Even queries that use the same supported syntax will likely perform quite differently.
    There is no tool I am aware of that will do the conversion at an acceptable level.

  • Converting MS SQL Server Query to Oracle Query

    Hi There,
    I've a strange problem. My project uses both MS SQL Server and Oracle server at run time. I've lot of queries which are written in MS SQL Style. Now, iam planning to write a helper class whic converts MS SQL Query to Oracle Query. Please Help me if any one has that kind of Helper with you.
    Thanks And Regards,
    Sasi Kanth

    That is why persistence applications like Hibernate or
    CMP get used for apps that will use more than one DB,
    but it takes upfront planning.
    If you have a set of automated unit tests that work
    with SQL Server, they will be a big help in getting
    your Oracle code up and running.Indeed - JUnit and Ant would be a big help here.
    It sounds like you have SQL in your JSPs, that will
    work against you as well if so. If you are using a
    DAO pattern, this will be much easier, as you can
    re-implement each DAO for Oracle.If you'd layered this app properly, you might just implement an OracleDAOFactory and be done with it. Interfaces and a DAO layer would go a long way.
    This is why layering is such a good idea. It isolates changes in a smaller subset of classes.
    But your problem sounds pretty big. It'd be daunting even if it were well designed.

  • Sqlite query want to convert in MS Sql server 2008

    Hi 
    Please let me know how to write MS SQL server query for the below:
    Sqlite query :
    SELECT strftime('%s',event_time_gmt,'unixepoch','330 minutes') as time;
    Regards,
    Vijjivinayaka

    Declare @dt0 datetime, @dt datetime, @LocalTimeOffset int=5.5*60*60, @epochdt bigint=1389595157, @AdjustedLocaldt bigint;
    SET @AdjustedLocaldt = @epochdt + @LocalTimeOffset
    SELECT @dt0=DATEADD(second,@epochdt, CAST('1970-01-01 00:00:00' AS datetime))
    ,@dt=DATEADD(second,@AdjustedLocaldt, CAST('1970-01-01 00:00:00' AS datetime))
    ; with mycte as (SELECT @epochdt as epochdt, @dt0 as gmtdt , @dt as localdt
    , DATEADD(minute, DATEDIFF(minute,0,@dt),0) as StartOftheMinute
    ,DATEADD(hour, DATEDIFF(hour,0,@dt),0) as StartOftheHour
    , DATEADD(day, DATEDIFF(day,0,@dt),0) as StartOftheday
    , DATEADD(mm, DATEDIFF(mm,0,@dt),0) as StartOfThisMonth
    , DATEADD(year, DATEDIFF(year,0,@dt),0) as StartOftheYear
    , DATEADD(wk, DATEDIFF(wk,0,@dt),0) as StartOftheWeek)
    select epochdt,
    Left(datename(weekday,localdt),3) +' '+ CONVERT(varchar(26),localdt,109) as localdt
    ,Left(datename(weekday,gmtdt),3) +' '+ CONVERT(varchar(26),gmtdt,109) as gmtdt
    ,Left(datename(weekday,StartOftheMinute),3) +' '+ CONVERT(varchar(26),StartOftheMinute,109) as StartOftheMinute
    ,Left(datename(weekday,StartOftheHour),3) +' '+ CONVERT(varchar(26),StartOftheHour,109) as StartOftheHour
    ,Left(datename(weekday,StartOftheday),3) +' '+ CONVERT(varchar(26),StartOftheday,109) as StartOftheday
    ,Left(datename(weekday,StartOfThisMonth),3) +' '+ CONVERT(varchar(26),StartOfThisMonth,109) as StartOfThisMonth
    ,Left(datename(weekday,StartOftheYear),3) +' '+ CONVERT(varchar(26),StartOftheYear,109) as StartOftheYear
    ,Left(datename(weekday,StartOftheWeek),3) +' '+ CONVERT(varchar(26),StartOftheWeek,109) as StartOftheWeek
    from mycte
    --http://msdn.microsoft.com/en-us/library/ms187928.aspx

  • Converting Oracle XML Query Result in Java String by using XSU

    Hi,
    I have a problem by converting Oracle XML Query Result in Java
    String by using XSU. I use XSU for Java.
    For example:
    String datum=new OracleXMLQuery(conn,"Select max(ps.datum) from
    preise ps where match='"+args[0]+"'");
    String datum1=datum;
    I become the following error:
    Prototyp.java:47: Incompatible type for declaration. Can't
    convert oracle.xml.sql.query.OracleXMLQuery to java.lang.String.
    Can somebody tell me a method() for converting to solve my
    problem??????
    Thanks

    Hmmm.. Pretty basic just look at the example:
    OracleXMLQuery qry = new OracleXMLQuery(conn,"Select max(ps.datum) from preise ps where match='"+args[0]+"'");
    String xmlString = qry.getXMLString();
    Hi,
    I have a problem by converting Oracle XML Query Result in Java
    String by using XSU. I use XSU for Java.
    For example:
    String datum=new OracleXMLQuery(conn,"Select max(ps.datum) from
    preise ps where match='"+args[0]+"'");
    String datum1=datum;
    I become the following error:
    Prototyp.java:47: Incompatible type for declaration. Can't
    convert oracle.xml.sql.query.OracleXMLQuery to java.lang.String.
    Can somebody tell me a method() for converting to solve my
    problem??????
    Thanks

  • Converting Oracle query to Hibernate

    0 down vote favorite
    share [fb] share [tw]
    considering I have Txn_Summ_Dec as a domain object (Entity) with all the fields used in the query how would I convert the SQL query below to Hibernate Query (ether HQL or Criteria api)..
    What the query does: Given a date range as input the query counts distinct users grouped by date, eventdesc and left joins with all the dates in the date range so resultset contains user counts for all dates in the range for all events.
    select
        d.dateInRange as dateval,
        eventdesc,
        nvl(td.dist_ucnt, 0) as dist_ucnt
    from (
        select
            to_date('03-NOV-2011','dd-mon-yyyy') + rownum - 1 as dateInRange
        from all_objects
        where rownum <= to_date('31-DEC-2011','dd-mon-yyyy') - to_date('03-NOV-2011','dd-mon-yyyy') + 1
    ) d
    left join (
        select
            currentdate,
            count(distinct(grauser_id)) as dist_ucnt,
            eventdesc
        from
            txn_summ_dec
        group by currentdate, eventdesc
    ) td on td.currentdate = d.dateInRange order by d.dateInRange ascThe query runs successfully on oracle returning the required result
    Edited by: EJP on 30/01/2012 20:12: added {noformat}{noformat} tags on your behalf, to make your code legible.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    ow006921 wrote:
    I think the question is, why would you want to convert a complex query like that to Hibernate syntax? Hibernate is an application layer superimposed over SQL and JDBC, intended to simplify your coding and provide a more object-oriented interface, best suited to simple cases of table i/o. It does not improve upon or substitute for the power of SQL.
    For something this complex, I would capture the SQL in a view or stored procedure on the database and call that from the client, either with Hibernate or straight JDBC.
    Just my opinion.
    Howard HydeYour opinion is very valid, but moot in this case. Upon my reply I expected one of two things:
    - silence (what I got; the OP looks for an easier way to make someone else solve his problems)
    - a second attempt at outsourcing work by posting something along the lines of "Please. I read the linked article but I couldn't figure it out. Can you please post some sample code?"
    When you've been around this forum for a while, you learn to identify the people who don't have a real problem other than being lazy.

  • Unable to display results of multiple query in grid in Oracle SQL Developer

    Hi, I am a newbie to this forum and couldn't find the Oracle SQL Developer forum so posting it here.
    My question: How to display multiple query results in grid in Oracle SQL Developer.
    Example:
    select * from Employee;
    select * from Department;
    - when I select both the queries and hit F5 in Oracle sql developer. By default it displays in output window.
    - How to display result of both the queries in Grid.
    Any thoughts on this would be really helpful.
    Thanks in advance.
    Harsh

    Hi Harsh,
    I'd say that the Results grid is designed to only show the results of 1 query at a time. I don't know/can't see how it would display multiple queries at a time.
    I would suggest either joining your tables to create a single query or opening another SQL Worksheet for one of the queries so that you can display the results side-by-side.
    Maybe you could explain what you're trying to do. Why are you trying to display multiple results in the same query grid?

  • Query to find the memory of database in oracle,sql

    Hi All,
    Please let me know the query to find the memory of database in oracle,sql.
    Thanks,
    sajith

    How do I find the overall database size?
    The biggest portion of a database's size comes from the datafiles. To find out how many megabytes are allocated to ALL datafiles:
    select sum(bytes)/1024/1024 "Meg" from dba_data_files;
    To get the size of all TEMP files:
    select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
    To get the size of the on-line redo-logs:
    select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
    Putting it all together into a single query:
    select a.data_size+b.temp_size+c.redo_size "total_size"
    from ( select sum(bytes) data_size
    from dba_data_files ) a,
    ( select nvl(sum(bytes),0) temp_size
    from dba_temp_files ) b,
    ( select sum(bytes) redo_size
    from sys.v_$log ) c;
    Another query ("Free space" reports data files free space):
    col "Database Size" format a20
    col "Free space" format a20
    select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size"
    , round(free.p / 1024 / 1024) || ' MB' "Free space"
    from (select bytes from v$datafile
    union all
    select bytes from v$tempfile
    union all
    select bytes from v$log) used
    , (select sum(bytes) as p from dba_free_space) free
    group by free.p
    This is what I use :P From http://www.orafaq.com/wiki/Oracle_database_FAQ#How_do_I_find_the_overall_database_size.3F

  • Oracle SQL Developer O/P and Toad O/P is Different for Same QUERY.

    Hi,
    can any one calrify me why i'm getting different result when i run the same QUERY in Oracle Developer and TOAD.
    When i Ran a Query in TOAD i could see Null&Data in a column called Customer_Category but when i Ran the same Query in Oracle SQL Developer i'm getting all Null N i couldnt see any data in the column.
    i have not performed any DDL r DML statement, just i got the Query and i Ran it in TOAD & Oracle SQL Developer.
    I found that the OUT PUT is different for perticular column.
    Thanks in Advance....

    > I found that the OUT PUT is different for perticular column.
    The RENDERING of data from Oracle (or any other server such as a POP3 server, web server, etc) IS DONE BY THE CLIENT.
    So to repeat - RENDERING IS DONE BY THE CLIENT.
    If one client selects to display the output received from the server differently than another client, it is a CLIENT ISSUE.
    It is not a server issue. It is not a SQL issue. It is not a PL/SQL issue.
    In other words, wrong forum for this question. You have a pure client side rendering problem which has absolutely nothing to do with SQL and/or PL/SQL.

  • Optimizing an SQL Query using Oracle SQL Developer

    Hi ,
    Currently i am using Oracle SQL Developer as my Database IDE .
    Is it possible to use Orqcles SQLDeveloper for the purpose of Optimizing an SQL Query ??
    For example assume i am having a query as :
    Select from Tranac_Master where CUST_STATAUS='Y' and JCC_REPORT='N'*
    Could anybody please tell me how can i use Oracle SQL Developer to optimize this query or any other SQL queries ??
    Please share your ideas , thanks in advance .

    1. Your query looks very simplistic as it is, so I fail to see how you can better optimise it (unless 'Tranac_Master' is a view, in which case I'd need to see the view details).
    2. No tool can automagically optimise your SQL to any degree of practical use. Very minor adjustments may be possible automatically, but really it is a question of you knowing your data & database design accurately, and then you applying your expert knowledge to tune it.

  • Why does Oracle SQL query returning a date field without the time component

    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!

    hokim wrote:
    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!http://edstevensdba.wordpress.com/category/nls_date_format/

  • Oracle sql STRUCT query

    Hi all. I have a simple program running in JDeveloper using JDBC for retrieving SDO_Geometry values from various spatial tables. The program works fine but when I run the following SQL statement to retrieve the geometry column from a table states it is returning the sdo_geometry values in the following format:
    spatialQuery = "select a.geom from states a";oracle.sql.STRUCT@e2dae9,     
    oracle.sql.STRUCT@19209ea,     
    oracle.sql.STRUCT@c8f6f8,     
    oracle.sql.STRUCT@1ce2dd4,     
    oracle.sql.STRUCT@122cdb6,     
    I know the program works but can anyone tell me how to interpret these results or even how to translate them into a more useful format. Cheers Joe

    I assume you are getting back a List (Vector) with the Struct inside it. Try ((List)query.getSingleResult()).get(0).
    In JPA you should get the Struct back directly if the result size was 1, otherwise an Object[], this was a bug in EclipseLink 1.0 that was fixed in EclipseLink 1.1.
    You should probably upgrade to EclipseLink 1.1.
    James : http://www.eclipselink.org

Maybe you are looking for