run SQL script using Rocket Universe from AIX command line (uvsh)

1k views Asked by At

Hopefully this is a simple question. I want to write a shell script that calls a SQL script to do some queries in a Rocket UNIVERSE database. I am doing this from the Server command line (the same machine where the database resides).

In SQLSERVER I might do something like the following:

sqlcmd -S myServer\instanceName -i C:\myScript.sql

In Oracle like this:

SQL>@/dir/test.sql

In UV I can't figure it out:

uvsh ??? some.sql file

So in the test.sql file I might have something like the following:

"SELECT ID, COL1, COL2 FROM PRODUCT WHERE @ID=91;"
"SELECT ID, COL1, COL2 FROM PRODUCT WHERE @ID=92;"
"SELECT ID, COL1, COL2 FROM PRODUCT WHERE @ID=93;"

So can this be done or am I going about this the wrong way? Maybe a different method is more optimal? -- Thanks!

1

There are 1 answers

2
Mike On

You can send the list of commands to the UniVerse process with the following command.

C:\U2\UV\HS.SALES>type test.sql | ..\bin\uv

You will not need the '"' around each statement you described.

For the HS.SALES account the following SQL commands should work:

SELECT @ID, FNAME, LNAME FROM CUSTOMER WHERE @ID='2';
SELECT @ID, FNAME, LNAME FROM CUSTOMER WHERE @ID='3';
SELECT @ID, FNAME, LNAME FROM CUSTOMER WHERE @ID='4';

Note that this may not do what you want, this will display the results to standard out. Also, caution should be taken when sending commands to UniVerse in this manner. If all of the UniVerse licenses are in use the uv command will fail, and the SQL commands will never execute.