Home
TeamSite
DataDeploy - how to query the database
geeta
How does one query the database and use the result?
e.g. I need to run a query "SELECT ID_SEQUENCE.NEXTVAL FROM dual", how do I get the id sequence back in a DD config file.
Do I use
<database ....>
....
<sql user-action="getID" type="query">
SELECT ID_SEQUENCE.NEXTVAL FROM dual
</sql>
<dbschema>
<group name="testTable" root-group="yes" table="TESTTABLE">
<attrmap>
<column name="ID" data-type="NUMBER(28)" value-from-field="??????" allows-null="no" is-url="no"/>
....
</attrmap>
<keys>
....
</keys>
</group>
</dbschema>
</database>
what is the result stored at?
Find more posts tagged with
Comments
Migrateduser
One option is to use a feature called External Data Source. Here you can reference a java callout and then use value-from-callout to fill in your id. Specifically, you would write a java class that would make the sql query. Then DD would call your class to get the ID, and use that value for the column. See the DD admin guide for more details. The database connection information can be passed into your class by DD.
Of course, this requires writing a bit of java.. but the basic class is set up for you in the example files. The example in the doc shows how to do all this. There is also a recorded Devnet webcast that talks about this.
Mariam
boskovuk
In reply to:
One option is to use a feature called External Data Source.
You mentioned that this would be one option to get the id sequence back in a DD config file.
What would be the others?
thanks ...
Solaris 5.8:
TS 6.1
OD 6.0.2 - DD 6.02 disabled
DD 5.6
Migrateduser
None than I can think of. You basically need some way to include custom code to make this query.
Mariam
boskovuk
None than I can think of. You basically need some way to include custom code to make this query.
This is clear. However, I was wondering if there is a way to avoid External Data Source route and to extract dynamic values (by using SQL statements), as the original poster explained, by other means?
I would like to get the next value of my primary key (which is integer) and somehow, to use that within DD config file?
Solaris 5.8:
TS 6.1
OD 6.0.2 - DD 6.02 disabled
DD 5.6