Page 1 of 1

Migration From SQL Server to UniSQL: Select top (n) clause

Posted: Mon 14 Mar 2011 14:02
by mlagasio
Hi all,

how could I translate a SQLServer Statement such as


select top 1 from mytable

into UniSQL statement ?

Many thanks in advance

Marco

Posted: Mon 14 Mar 2011 16:33
by AndreyZ
Hello,

You should not use the TUniSQL component for executing SQL statements that return rows from the database. You should execute this SQL statement in the TUniQuery component. Here is a code example:

Code: Select all

UniQuery.SQL.Text := 'select top 1 * from mytable';
UniQuery.Open;

Posted: Tue 15 Mar 2011 09:03
by mlagasio
Hi

thank you for your answer.

I'm using ms visual studio in this moment (also if I'm a Delphi developer).
I'm migrating a visual studio application linked to SQLServer to Oracle and
I'd want use your classes.

Your hint applies to BDS or RAD Studio. Is it correct?

Bye Marco

Posted: Tue 15 Mar 2011 09:54
by mlagasio
Another key point, for me.

My solution is on a virtual machine (vs 2005)

I've launched the migration wizard but the wizard do nothing (exist a log?)

Best Regard
Marco

Posted: Tue 15 Mar 2011 13:52
by mlagasio
Another info on later post: the code to be processed is in AppCode folder of some web services (server side).
I've tried to make the migration on another vc# project. It's work correctly

Bye
Marco

Posted: Tue 15 Mar 2011 13:52
by mlagasio
Another info on later post: the code to be processed is in AppCode folder of some web services (server side).
I've tried to make the migration on another vc# project. It's work correctly

Bye
Marco

Posted: Tue 15 Mar 2011 15:09
by AndreyZ
Both BDS and RAD Studio are Delphi IDEs, and my answer is correct for both of them. Migration Wizard is available only for Delphi IDE.

Posted: Tue 15 Mar 2011 15:52
by mlagasio
Excuse me,

I see Migration Wizard also in VS menu'

Regards

Posted: Wed 16 Mar 2011 11:35
by AndreyZ
UniDAC Migration Wizard allows you to convert your BDE, IBX, ADO, ODAC, SDAC, MyDAC, and IBDAC projects to UniDAC. UniDAC Migration Wizard is available only for Delphi IDE, and it doesn't have anything to do with Migration Wizard that you've found in the Visual Studio menu.

Posted: Mon 21 Mar 2011 08:25
by mlagasio
Thank you for your answer.

Ok. I'm referring exclusively to migration wizard of visual studio and to UniSql language (not a component) used with UniCommand.

My questions (relate only to this context) are

1) how could I write in unified manner "select top 1 ....". Is it possible (I use only SQLServer and Oracle)
2) the migration wizard of vs doesn't work with AppCode of web service

For question 2 I've found a radical work-around: transfer all AppCode in a normal c# project and call it from ws

For question 1 I've not answer

Best Regard
Marco

Posted: Tue 22 Mar 2011 10:25
by AndreyZ
You can use macros to implement such functionality. For example, you can write the following code:

Code: Select all

UniQuery.SQL.Text := 'select &mssql from test_table &ora';
, and for SQL Server use this code:

Code: Select all

UniQuery.MacroByName('ora').Active := false;
UniQuery.MacroByName('mssql').Active := true;
UniQuery.MacroByName('mssql').AsString := 'TOP 1';
, and for Oracle use this code:

Code: Select all

UniQuery.MacroByName('mssql').Active := false;
UniQuery.MacroByName('ora').Active := true;
UniQuery.MacroByName('ora').AsString := 'WHERE ROWNUM < 2';
For more information about macros, please read the "Working with macros" topic of the UniDAC documentation.