Comments on: QueryScript: SQL scripting language https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language Blog by Shlomi Noach Wed, 15 Feb 2012 12:15:03 +0000 hourly 1 https://wordpress.org/?v=5.3.3 By: shlomi https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69984 Wed, 15 Feb 2012 12:15:03 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69984 @Jouni,
It’s a mixture, partly due to limitations by the SQL syntax itself (i.e. some things have to be distinctively interpreted by the script).

]]>
By: Jouni "rautamiekka" Järvinen https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69983 Wed, 15 Feb 2012 12:09:13 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69983 The syntax looks much like PHP. At first I thought about JavaScript.

]]>
By: ik_5 https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69341 Thu, 09 Feb 2012 22:16:20 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69341 @shlomi,

There are two specific restrictions in Firebird:
1. You can not create a command that require new transactions inside an existed transactions (there is a way to solve it though, using autonomous transactions)

2. You can not change structure in execution block (stored procedures, anonymous procedure like the last link and triggers), however you can use the execute block instead.

Here is the way you suggested it that works btw, and you are right, but still I’ve created a new table inside an execution block 🙂

SET TERM !! ;

EXECUTE BLOCK AS
declare a_name varchar(10) = ‘EMPLOYEE’;
BEGIN
if (not exists(select 1 from rdb$relations where rdb$relation_name = :a_name)) then
execute statement ‘create table ‘ || :a_name ||’ ( id integer ); ‘;
END!!

SET TERM ; !!
commit;

The double pipe is the concat action.
In theory I can also create the table inside the system tables with insert, but that way, it’s cleaner.

Like all databases, it’s not perfect, but I really like the power. I really hope that Mysql based will be better in that area, instead of using external tools such as yours.

Your work is very good, but I really prefer such tools as part of the database itself, instead of external plugins.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69308 Thu, 09 Feb 2012 16:23:05 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69308 @Holger,

Thank you. I am well aware of other databases capabilities, including, for example, PostgreSQL’s python/perl/… language routines, which make for a much easier scripting capabilities.
There are some advantages to QueryScript (including some I’m still working on and are not released yet) over existing implementations. But, I would say, if I were to come from the PstgreSQL world, I would probably not have the urge to embark upon this coding mission.

I have no immediate intentions for any specific database other than MySQL. But as I created a language, I decided it should, by definition, be a general one.
I do not presume that this language will catch with other databases, but am interested in leaving this open.

Regards,
Shlomi

]]>
By: Holger Thiel https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69301 Thu, 09 Feb 2012 15:46:24 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69301 Hello Shlomi,

this is a very interesting feature for MySQL you have written. It is for sure not needed on PostgreSQL. But if you use MySQL it will be very nice indeed to do some things on the server – not in the client.

Regards,
Holger

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69287 Thu, 09 Feb 2012 11:46:28 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69287 @ik_5
firebird’s coding abilities are impressive, and are easier to handle than MySQL’s.

But to pursue the subject you present with table creation via dynamic SQL: the invocation of a ‘create table …’ string, dynamically executed. This means this ability is not integrated into the code. If you wanted the table name to be dynamic, you would have to make for text manipulation (using CONCAT() or whatever). Same goes for MySQL, and it’s one of the things that make MySQL server side scripting a mess.
Server side cursors are somewhat easier on firebird than on mysql, but still you have to declare-open-loop-fetch-check-exit-close.

That is not to say I’m arguing against the firebird coding (as I suspect you are inclined to believe). But when you say FB “has all that” – I would rather be more precise on that.

]]>
By: ik_5 https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69282 Thu, 09 Feb 2012 11:15:28 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69282 I do not know regarding creating databases, but for creating tables:
http://www.firebirdfaq.org/faq69/

Also Fb and PostgreSQL support afaik temporary tables just for the execution block that will be removed when the block is done executing

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69167 Wed, 08 Feb 2012 12:46:53 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69167 @ik_5,
Thanks.
Can you also do meta-scripting, as suggested in the 2nd and 3rd examples? i.e. dynamically create tables, databases, etc?

]]>
By: ik_5 https://shlomi-noach.github.io/blog/mysql/queryscript-sql-scripting-language/comment-page-1#comment-69155 Wed, 08 Feb 2012 10:16:29 +0000 https://shlomi-noach.github.io/blog/?p=4596#comment-69155 In PostgreSQL and Firebird we do not really need such tools.

On FB PSQL have all of that, and on Postgre, we additional programming language to use in stored procedure.

Here is how you declare a variable: http://www.firebirdsql.org/refdocs/langrefupd25-psql-declare.html

Another example, this is for flow usage:
http://www.firebirdsql.org/manual/nullguide-conditionals-loops.html

]]>