# calling macro in a model

**URL:** <https://discourse.getdbt.com/t/calling-macro-in-a-model/9481>\
**Category:** In-Depth Discussions\
**Created:** [August 9, 2023, 6:31am UTC](https://discourse.getdbt.com/t/calling-macro-in-a-model/9481 "2023-08-09T06:31:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashima](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ashima](https://discourse.getdbt.com/u/ashima)\
**Post date:** [August 9, 2023, 6:31am UTC](https://discourse.getdbt.com/t/calling-macro-in-a-model/9481/1 "2023-08-09T06:31:21Z")

</div>

hi all , i have recently started using dbt . Looking for help

this is the macro i wrote to compare mobno column.

{% macro get\_cust\_name(mobno) %}

{% set query %}  
select name from customer\_test where mobno = ‘{{ mobno }}’  
{% endset %}

{% do run\_query(query) %}  
{% endmacro %}

I am calling abov emacro in a model like so

select  
\*,  
{{ get\_cust\_name(‘00000’) }}  
from customer\_test

But when i try to build the model it gives me error  
6:19:21 1 of 1 START sql view model TEST2.macro2\_test … [RUN]  
06:19:22 1 of 1 ERROR creating sql view model TEST2.macro2\_test … [ERROR in 1.00s]  
06:19:22  
06:19:22 Finished running 1 view model in 0 hours 0 minutes and 3.24 seconds (3.24s).  
06:19:22  
06:19:22 Completed with 1 error and 0 warnings:  
06:19:22  
06:19:22 Database Error in model macro2\_test (models\macro2\_test.sql)  
06:19:22 001003 (42000): SQL compilation error:  
06:19:22 syntax error line 12 at position 0 unexpected ‘from’.  
06:19:22 compiled Code at target\run\new1\models\macro2\_test.sql  
06:19:22  
06:19:22 Done. PASS=0 WARN=0 ERROR=1 SKIP=0 TOTAL=1

waiting for responses
