java - how can i pass information from ant to sql file or procedure -


i creating user using ant target below

<target name="create_user">      <exec executable="sqlplus" dir="${basedir}/dbsetup">           <arg value="system/oracle@orcl"/>           <arg value="@create_user.sql"/>      </exec>     </target> 

and sql files follows........

create user test identified password;  grant resource, connect test ;  grant create view test ;  grant create materialized view test ;  grant create sequence test ;  grant create procedure test ;  grant create directory test ;  grant create database link test ;  alter user test  quota unlimited on users;   quit; 

at present user name hard coded in create_user.sql want prompt user name , password ant , pass sql file.

please advice how can achieve or other way can achieve

one option use &1 positional parameter in sql file, e.g.:

create user &1 identified password; 

prompt username ant input task , pass value arg sqlplus in target:

  <exec executable="sqlplus" failonerror="true">         <arg value="${userid}/${password}@${tnsalias}"/>         <arg value="yourfilenamegoeshere/>         <arg value="theusernamefrompromptgoeshere"/>   </exec> 

this has advantage of keeping sql file in form can executed other environments such sql*plus , pl/sql developer


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -