0% found this document useful (0 votes)
140 views

BODS Scripting: Select

The document describes various scripting functions that can be used in BODS including SQL commands like select, update, delete, truncate. It also describes if/then conditional logic, while loops. It provides examples of over 20 functions for scripting including aggregate functions, casting, lookups, string manipulation, date functions and more. Functions allow for complex logic and data handling in BODS scripts.

Uploaded by

yella reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views

BODS Scripting: Select

The document describes various scripting functions that can be used in BODS including SQL commands like select, update, delete, truncate. It also describes if/then conditional logic, while loops. It provides examples of over 20 functions for scripting including aggregate functions, casting, lookups, string manipulation, date functions and more. Functions allow for complex logic and data handling in BODS scripts.

Uploaded by

yella reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

BODS scripting

Select:

Sql(‘datastore name’,’select empname from emp where empid = 10’);

Update:

Sql(‘datastore name’,’update emp set loc = \’hyd\’ where empid = 10’);

Delete:

Sql(‘datastore name’,’Delete from emp where empid = 10’);

Truncate:

Sql(‘datastore name’,’ Truncate table table name’);

Ifthenelse in script :

IF ( 1 = 1)

Begin

Print(‘the condition satisfied succesfully’);

End

Else

Begin

Print(‘the not condition satisfied’);

end

While loop :

while ( $G_Count <= $G_Retry_Count )

begin

#### Checking the Zip file in InDir folder


if(exec('cmd','dir
[$G_JB_SERVER_FULLPATH_INDIR_ITK_UPDATE1]\\FILENAME_[$G_Region]_
UPDATE_[$G_ZIP_SYSDATE].zip',2)is not null)

begin

Print('############### The
FILENAME_[$G_Region]_UPDATE_[$G_ZIP_SYSDATE].zip file exist in InDir
folder');

end

$G_Count = $G_Count+1;

sleep($G_Sleep_Time);

end

Functions:

1 .Aggregate functions:

1. Avg – avg(filed) – the remaining fields will be available in group by clause


2. Min – min(field)- same as above
3. Max – max(field)-same as above
4. Count- count(field)- same as above
5. Count_distinct(field)- same as above
6. Sum- same as above

2 .Cast: Explicitly converts an expression of one data type to another.

Ex: Cast('field name','<data_type>')

3. Current_system_configuration : Returns the name of the system


configuration used at runtime.

Ex : Current_system_configuration()

4. Decode : we can write multiple if then else conditions in decode function.


Ex: decode ((EMPNO = 1), '111',
(EMPNO = 2), '222',
(EMPNO = 3), '333',
(EMPNO = 4), '444',
'NO_ID')

5. exec : we can use exec to run command line statements.

Ex: Exec(‘cmd’,’move source folder Target folder’);

6 . file_exists : Returns 1 if a file or directory is present on the disk (even if 0


bytes long), 0 otherwise.

Ex: file_exists(<file_path>)

7 . gen_row_num_by_group: Generate a column of row IDs for each ID group


in the specified column, beginning with integer value 1 and then incremented
sequentially by 1. When the group is changed, the value is reset to 1.Syntax

Ex : gen_row_num_by_group(field name)

8. gen_row_num() : it will generate sequence in specified column.

Ex: gen_row_num()

9. ifthenelse() : Allows conditional logic in expressions.

Ex : ifthenelse (1=1,’A’,’B’)

10. length : Returns the number of characters in a given string.

Ex : length(field)

11. lookup : Retrieves a value in a table or file based on the values in a


different source table or file.

Ex: lookup (<lookup_table>, <result_column>, <default_value>, <cache_spec>,


<compare_column>, <expression>)

12. lookup_ext : we can extract multiple column values from look up table.
13. lpad : lpad(<input_string>,<size>,'<pad_string>')

Ex: lpad('Tanaka', 15, ' ') – Here we are doing lpad with space (‘’)

Result ( Tanaka)

14. rpad : rpad(<input_string>,<size>,'<pad_string>')

Ex: rpad('Tanaka', 15, ' ') – Here we are doing rpad with space (‘’)

15. ltrim : The function scans <input_string> left-to-right removing all


characters that appear in <trim_string> until it reaches a character not in
<trim_string>.

Ex: ltrim('ABCABCD', 'ABC') - result is ‘D’, ltrim(field name,’values’)

16. ltrim_blanks : Removes blank characters from the start of a string.

Ex: ltrim_blanks (field name)

17. Raise_exception : for aborting the job.

Ex: raise_exception(<error_msg>)

18. sleep : Suspends the execution of the calling data flow or work flow.

Ex : sleep(<num_millisecs>)
19. sysdate() : it will generate the current system date.

Ex: sysdate()

20. To_char – if you want to change format we need to use to_char

Ex: to_char (sysdate(),’YYYY.MM.DD’)

If you want to convert above sysdate field to date format.

To_date (to_char (sysdate(),’YYYY.MM.DD’),’YYYY.MM.DD’)


21. Upper : This function will convert lowercase to uppercase.

Ex : upper('Accounting101') ----Result - 'ACCOUNTING101'

22. Word_ext :
Returns the word identified by its position in a delimited string.

Ex : input – 123,345,456

Word_ext(‘123,345,456’,1,’,’) ---- result – 123

23. get_file_attribute: To identify the file size or date modified.

You might also like